Update auto-generated bindings
[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 DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
11 #include <assert.h>
12 // Always run a, then assert it is true:
13 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
14 // Assert a is true or do nothing
15 #define CHECK(a) DO_ASSERT(a)
16
17 void __attribute__((constructor)) debug_log_version() {
18         if (check_get_ldk_version() == NULL)
19                 DEBUG_PRINT("LDK version did not match the header we built against\n");
20         if (check_get_ldk_bindings_version() == NULL)
21                 DEBUG_PRINT("LDK C Bindings version did not match the header we built against\n");
22         DEBUG_PRINT("Loaded LDK-Java Bindings with LDK %s and LDK-C-Bindings %s\n", check_get_ldk_version(), check_get_ldk_bindings_version());
23 }
24
25 // Running a leak check across all the allocations and frees of the JDK is a mess,
26 // so instead we implement our own naive leak checker here, relying on the -wrap
27 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
28 // and free'd in Rust or C across the generated bindings shared library.
29 #include <threads.h>
30 #include <execinfo.h>
31
32 #include <unistd.h>
33 static mtx_t allocation_mtx;
34
35 void __attribute__((constructor)) init_mtx() {
36         DO_ASSERT(mtx_init(&allocation_mtx, mtx_plain) == thrd_success);
37 }
38
39 #define BT_MAX 128
40 typedef struct allocation {
41         struct allocation* next;
42         void* ptr;
43         const char* struct_name;
44         void* bt[BT_MAX];
45         int bt_len;
46         unsigned long alloc_len;
47 } allocation;
48 static allocation* allocation_ll = NULL;
49
50 void* __real_malloc(size_t len);
51 void* __real_calloc(size_t nmemb, size_t len);
52 static void new_allocation(void* res, const char* struct_name, size_t len) {
53         allocation* new_alloc = __real_malloc(sizeof(allocation));
54         new_alloc->ptr = res;
55         new_alloc->struct_name = struct_name;
56         new_alloc->bt_len = backtrace(new_alloc->bt, BT_MAX);
57         new_alloc->alloc_len = len;
58         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
59         new_alloc->next = allocation_ll;
60         allocation_ll = new_alloc;
61         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
62 }
63 static void* MALLOC(size_t len, const char* struct_name) {
64         void* res = __real_malloc(len);
65         new_allocation(res, struct_name, len);
66         return res;
67 }
68 void __real_free(void* ptr);
69 static void alloc_freed(void* ptr) {
70         allocation* p = NULL;
71         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
72         allocation* it = allocation_ll;
73         while (it->ptr != ptr) {
74                 p = it; it = it->next;
75                 if (it == NULL) {
76                         DEBUG_PRINT("Tried to free unknown pointer %p at:\n", ptr);
77                         void* bt[BT_MAX];
78                         int bt_len = backtrace(bt, BT_MAX);
79                         backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
80                         DEBUG_PRINT("\n\n");
81                         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
82                         return; // addrsan should catch malloc-unknown and print more info than we have
83                 }
84         }
85         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
86         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
87         DO_ASSERT(it->ptr == ptr);
88         __real_free(it);
89 }
90 static void FREE(void* ptr) {
91         if ((uint64_t)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
92         alloc_freed(ptr);
93         __real_free(ptr);
94 }
95
96 void* __wrap_malloc(size_t len) {
97         void* res = __real_malloc(len);
98         new_allocation(res, "malloc call", len);
99         return res;
100 }
101 void* __wrap_calloc(size_t nmemb, size_t len) {
102         void* res = __real_calloc(nmemb, len);
103         new_allocation(res, "calloc call", len);
104         return res;
105 }
106 void __wrap_free(void* ptr) {
107         if (ptr == NULL) return;
108         alloc_freed(ptr);
109         __real_free(ptr);
110 }
111
112 void* __real_realloc(void* ptr, size_t newlen);
113 void* __wrap_realloc(void* ptr, size_t len) {
114         if (ptr != NULL) alloc_freed(ptr);
115         void* res = __real_realloc(ptr, len);
116         new_allocation(res, "realloc call", len);
117         return res;
118 }
119 void __wrap_reallocarray(void* ptr, size_t new_sz) {
120         // Rust doesn't seem to use reallocarray currently
121         DO_ASSERT(false);
122 }
123
124 void __attribute__((destructor)) check_leaks() {
125         unsigned long alloc_count = 0;
126         unsigned long alloc_size = 0;
127         DEBUG_PRINT("The following LDK-allocated blocks still remain.\n");
128         DEBUG_PRINT("Note that this is only accurate if System.gc(); System.runFinalization()\n");
129         DEBUG_PRINT("was called prior to exit after all LDK objects were out of scope.\n");
130         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
131                 DEBUG_PRINT("%s %p (%lu bytes) remains:\n", a->struct_name, a->ptr, a->alloc_len);
132                 backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
133                 DEBUG_PRINT("\n\n");
134                 alloc_count++;
135                 alloc_size += a->alloc_len;
136         }
137         DEBUG_PRINT("%lu allocations remained for %lu bytes.\n", alloc_count, alloc_size);
138         DEBUG_PRINT("Note that this is only accurate if System.gc(); System.runFinalization()\n");
139         DEBUG_PRINT("was called prior to exit after all LDK objects were out of scope.\n");
140 }
141
142 static jmethodID ordinal_meth = NULL;
143 static jmethodID slicedef_meth = NULL;
144 static jclass slicedef_cls = NULL;
145 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
146         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
147         CHECK(ordinal_meth != NULL);
148         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
149         CHECK(slicedef_meth != NULL);
150         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
151         CHECK(slicedef_cls != NULL);
152 }
153
154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
155         return *((bool*)ptr);
156 }
157 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
158         return *((long*)ptr);
159 }
160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
161         FREE((void*)ptr);
162 }
163 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
164         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
165         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
166         return ret_arr;
167 }
168 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
169         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
170         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
171         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
172         return ret_arr;
173 }
174 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
175         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
176         vec->datalen = (*env)->GetArrayLength(env, bytes);
177         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
178         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
179         return (uint64_t)vec;
180 }
181 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
182         LDKTransaction *txdata = (LDKTransaction*)ptr;
183         LDKu8slice slice;
184         slice.data = txdata->data;
185         slice.datalen = txdata->datalen;
186         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
187 }
188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
189         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
190         txdata->datalen = (*env)->GetArrayLength(env, bytes);
191         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
192         txdata->data_is_owned = false;
193         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
194         return (uint64_t)txdata;
195 }
196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
197         LDKTransaction *tx = (LDKTransaction*)ptr;
198         tx->data_is_owned = true;
199         Transaction_free(*tx);
200         FREE((void*)ptr);
201 }
202 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
203         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
204         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
205         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
206         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
207         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
208         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
209         return (uint64_t)vec->datalen;
210 }
211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
212         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
213         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
214         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
215         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
216         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
217         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
218         vec->data = NULL;
219         vec->datalen = 0;
220         return (uint64_t)vec;
221 }
222
223 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
224 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
225 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
226 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
227
228 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
229 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
230 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
231
232 typedef jlongArray int64_tArray;
233 typedef jbyteArray int8_tArray;
234
235 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
236         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
237         char* conv_buf = MALLOC(len + 1, "str conv buf");
238         memcpy(conv_buf, chars, len);
239         conv_buf[len] = 0;
240         jstring ret = (*env)->NewStringUTF(env, conv_buf);
241         FREE(conv_buf);
242         return ret;
243 }
244 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
245         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
246         char* newchars = MALLOC(str_len + 1, "String chars");
247         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
248         memcpy(newchars, jchars, str_len);
249         newchars[str_len] = 0;
250         (*env)->ReleaseStringUTFChars(env, str, jchars);
251         LDKStr res = {
252                 .chars = newchars,
253                 .len = str_len,
254                 .chars_is_owned = true
255         };
256         return res;
257 }
258
259 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
260         return str_ref_to_java(env, "v0.0.99.1-7-gf7a4eb8-dirty", strlen("v0.0.99.1-7-gf7a4eb8-dirty"));
261 }
262 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
263         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
264 }
265 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
266         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
267 }
268 static jclass arr_of_B_clz = NULL;
269 static jclass arr_of_J_clz = NULL;
270 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
271         arr_of_B_clz = (*env)->FindClass(env, "[B");
272         CHECK(arr_of_B_clz != NULL);
273         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
274         arr_of_J_clz = (*env)->FindClass(env, "[J");
275         CHECK(arr_of_J_clz != NULL);
276         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
277 }
278 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
279 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
280         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
281                 case 0: return LDKAccessError_UnknownChain;
282                 case 1: return LDKAccessError_UnknownTx;
283         }
284         abort();
285 }
286 static jclass AccessError_class = NULL;
287 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
288 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
289 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
290         AccessError_class = (*env)->NewGlobalRef(env, clz);
291         CHECK(AccessError_class != NULL);
292         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
293         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
294         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
295         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
296 }
297 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
298         switch (val) {
299                 case LDKAccessError_UnknownChain:
300                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
301                 case LDKAccessError_UnknownTx:
302                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
303                 default: abort();
304         }
305 }
306
307 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
308         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
309                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
310                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
311         }
312         abort();
313 }
314 static jclass ChannelMonitorUpdateErr_class = NULL;
315 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
316 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
317 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
318         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
319         CHECK(ChannelMonitorUpdateErr_class != NULL);
320         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
321         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
322         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
323         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
324 }
325 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
326         switch (val) {
327                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
328                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
329                 case LDKChannelMonitorUpdateErr_PermanentFailure:
330                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
331                 default: abort();
332         }
333 }
334
335 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
336         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
337                 case 0: return LDKConfirmationTarget_Background;
338                 case 1: return LDKConfirmationTarget_Normal;
339                 case 2: return LDKConfirmationTarget_HighPriority;
340         }
341         abort();
342 }
343 static jclass ConfirmationTarget_class = NULL;
344 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
345 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
346 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
347 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
348         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
349         CHECK(ConfirmationTarget_class != NULL);
350         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
351         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
352         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
353         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
354         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
355         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
356 }
357 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
358         switch (val) {
359                 case LDKConfirmationTarget_Background:
360                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
361                 case LDKConfirmationTarget_Normal:
362                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
363                 case LDKConfirmationTarget_HighPriority:
364                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
365                 default: abort();
366         }
367 }
368
369 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
370         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
371                 case 0: return LDKCreationError_DescriptionTooLong;
372                 case 1: return LDKCreationError_RouteTooLong;
373                 case 2: return LDKCreationError_TimestampOutOfBounds;
374                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
375         }
376         abort();
377 }
378 static jclass CreationError_class = NULL;
379 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
380 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
381 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
382 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
383 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
384         CreationError_class = (*env)->NewGlobalRef(env, clz);
385         CHECK(CreationError_class != NULL);
386         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
387         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
388         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
389         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
390         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
391         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
392         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
393         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
394 }
395 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
396         switch (val) {
397                 case LDKCreationError_DescriptionTooLong:
398                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
399                 case LDKCreationError_RouteTooLong:
400                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
401                 case LDKCreationError_TimestampOutOfBounds:
402                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
403                 case LDKCreationError_ExpiryTimeOutOfBounds:
404                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
405                 default: abort();
406         }
407 }
408
409 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
410         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
411                 case 0: return LDKCurrency_Bitcoin;
412                 case 1: return LDKCurrency_BitcoinTestnet;
413                 case 2: return LDKCurrency_Regtest;
414                 case 3: return LDKCurrency_Simnet;
415                 case 4: return LDKCurrency_Signet;
416         }
417         abort();
418 }
419 static jclass Currency_class = NULL;
420 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
421 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
422 static jfieldID Currency_LDKCurrency_Regtest = NULL;
423 static jfieldID Currency_LDKCurrency_Simnet = NULL;
424 static jfieldID Currency_LDKCurrency_Signet = NULL;
425 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
426         Currency_class = (*env)->NewGlobalRef(env, clz);
427         CHECK(Currency_class != NULL);
428         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
429         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
430         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
431         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
432         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
433         CHECK(Currency_LDKCurrency_Regtest != NULL);
434         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
435         CHECK(Currency_LDKCurrency_Simnet != NULL);
436         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
437         CHECK(Currency_LDKCurrency_Signet != NULL);
438 }
439 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
440         switch (val) {
441                 case LDKCurrency_Bitcoin:
442                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
443                 case LDKCurrency_BitcoinTestnet:
444                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
445                 case LDKCurrency_Regtest:
446                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
447                 case LDKCurrency_Simnet:
448                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
449                 case LDKCurrency_Signet:
450                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
451                 default: abort();
452         }
453 }
454
455 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
456         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
457                 case 0: return LDKIOError_NotFound;
458                 case 1: return LDKIOError_PermissionDenied;
459                 case 2: return LDKIOError_ConnectionRefused;
460                 case 3: return LDKIOError_ConnectionReset;
461                 case 4: return LDKIOError_ConnectionAborted;
462                 case 5: return LDKIOError_NotConnected;
463                 case 6: return LDKIOError_AddrInUse;
464                 case 7: return LDKIOError_AddrNotAvailable;
465                 case 8: return LDKIOError_BrokenPipe;
466                 case 9: return LDKIOError_AlreadyExists;
467                 case 10: return LDKIOError_WouldBlock;
468                 case 11: return LDKIOError_InvalidInput;
469                 case 12: return LDKIOError_InvalidData;
470                 case 13: return LDKIOError_TimedOut;
471                 case 14: return LDKIOError_WriteZero;
472                 case 15: return LDKIOError_Interrupted;
473                 case 16: return LDKIOError_Other;
474                 case 17: return LDKIOError_UnexpectedEof;
475         }
476         abort();
477 }
478 static jclass IOError_class = NULL;
479 static jfieldID IOError_LDKIOError_NotFound = NULL;
480 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
481 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
482 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
483 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
484 static jfieldID IOError_LDKIOError_NotConnected = NULL;
485 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
486 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
487 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
488 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
489 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
490 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
491 static jfieldID IOError_LDKIOError_InvalidData = NULL;
492 static jfieldID IOError_LDKIOError_TimedOut = NULL;
493 static jfieldID IOError_LDKIOError_WriteZero = NULL;
494 static jfieldID IOError_LDKIOError_Interrupted = NULL;
495 static jfieldID IOError_LDKIOError_Other = NULL;
496 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
497 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
498         IOError_class = (*env)->NewGlobalRef(env, clz);
499         CHECK(IOError_class != NULL);
500         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
501         CHECK(IOError_LDKIOError_NotFound != NULL);
502         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
503         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
504         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
505         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
506         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
507         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
508         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
509         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
510         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
511         CHECK(IOError_LDKIOError_NotConnected != NULL);
512         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
513         CHECK(IOError_LDKIOError_AddrInUse != NULL);
514         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
515         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
516         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
517         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
518         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
519         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
520         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
521         CHECK(IOError_LDKIOError_WouldBlock != NULL);
522         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
523         CHECK(IOError_LDKIOError_InvalidInput != NULL);
524         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
525         CHECK(IOError_LDKIOError_InvalidData != NULL);
526         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
527         CHECK(IOError_LDKIOError_TimedOut != NULL);
528         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
529         CHECK(IOError_LDKIOError_WriteZero != NULL);
530         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
531         CHECK(IOError_LDKIOError_Interrupted != NULL);
532         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
533         CHECK(IOError_LDKIOError_Other != NULL);
534         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
535         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
536 }
537 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
538         switch (val) {
539                 case LDKIOError_NotFound:
540                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
541                 case LDKIOError_PermissionDenied:
542                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
543                 case LDKIOError_ConnectionRefused:
544                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
545                 case LDKIOError_ConnectionReset:
546                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
547                 case LDKIOError_ConnectionAborted:
548                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
549                 case LDKIOError_NotConnected:
550                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
551                 case LDKIOError_AddrInUse:
552                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
553                 case LDKIOError_AddrNotAvailable:
554                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
555                 case LDKIOError_BrokenPipe:
556                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
557                 case LDKIOError_AlreadyExists:
558                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
559                 case LDKIOError_WouldBlock:
560                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
561                 case LDKIOError_InvalidInput:
562                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
563                 case LDKIOError_InvalidData:
564                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
565                 case LDKIOError_TimedOut:
566                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
567                 case LDKIOError_WriteZero:
568                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
569                 case LDKIOError_Interrupted:
570                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
571                 case LDKIOError_Other:
572                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
573                 case LDKIOError_UnexpectedEof:
574                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
575                 default: abort();
576         }
577 }
578
579 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
580         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
581                 case 0: return LDKLevel_Trace;
582                 case 1: return LDKLevel_Debug;
583                 case 2: return LDKLevel_Info;
584                 case 3: return LDKLevel_Warn;
585                 case 4: return LDKLevel_Error;
586         }
587         abort();
588 }
589 static jclass Level_class = NULL;
590 static jfieldID Level_LDKLevel_Trace = NULL;
591 static jfieldID Level_LDKLevel_Debug = NULL;
592 static jfieldID Level_LDKLevel_Info = NULL;
593 static jfieldID Level_LDKLevel_Warn = NULL;
594 static jfieldID Level_LDKLevel_Error = NULL;
595 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
596         Level_class = (*env)->NewGlobalRef(env, clz);
597         CHECK(Level_class != NULL);
598         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
599         CHECK(Level_LDKLevel_Trace != NULL);
600         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
601         CHECK(Level_LDKLevel_Debug != NULL);
602         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
603         CHECK(Level_LDKLevel_Info != NULL);
604         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
605         CHECK(Level_LDKLevel_Warn != NULL);
606         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
607         CHECK(Level_LDKLevel_Error != NULL);
608 }
609 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
610         switch (val) {
611                 case LDKLevel_Trace:
612                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
613                 case LDKLevel_Debug:
614                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
615                 case LDKLevel_Info:
616                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
617                 case LDKLevel_Warn:
618                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
619                 case LDKLevel_Error:
620                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
621                 default: abort();
622         }
623 }
624
625 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
626         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
627                 case 0: return LDKNetwork_Bitcoin;
628                 case 1: return LDKNetwork_Testnet;
629                 case 2: return LDKNetwork_Regtest;
630                 case 3: return LDKNetwork_Signet;
631         }
632         abort();
633 }
634 static jclass Network_class = NULL;
635 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
636 static jfieldID Network_LDKNetwork_Testnet = NULL;
637 static jfieldID Network_LDKNetwork_Regtest = NULL;
638 static jfieldID Network_LDKNetwork_Signet = NULL;
639 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
640         Network_class = (*env)->NewGlobalRef(env, clz);
641         CHECK(Network_class != NULL);
642         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
643         CHECK(Network_LDKNetwork_Bitcoin != NULL);
644         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
645         CHECK(Network_LDKNetwork_Testnet != NULL);
646         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
647         CHECK(Network_LDKNetwork_Regtest != NULL);
648         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
649         CHECK(Network_LDKNetwork_Signet != NULL);
650 }
651 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
652         switch (val) {
653                 case LDKNetwork_Bitcoin:
654                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
655                 case LDKNetwork_Testnet:
656                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
657                 case LDKNetwork_Regtest:
658                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
659                 case LDKNetwork_Signet:
660                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
661                 default: abort();
662         }
663 }
664
665 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
666         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
667                 case 0: return LDKSecp256k1Error_IncorrectSignature;
668                 case 1: return LDKSecp256k1Error_InvalidMessage;
669                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
670                 case 3: return LDKSecp256k1Error_InvalidSignature;
671                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
672                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
673                 case 6: return LDKSecp256k1Error_InvalidTweak;
674                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
675                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
676         }
677         abort();
678 }
679 static jclass Secp256k1Error_class = NULL;
680 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
681 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
682 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
683 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
684 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
685 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
686 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
687 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
688 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
689 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
690         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
691         CHECK(Secp256k1Error_class != NULL);
692         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
693         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
694         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
695         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
696         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
697         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
698         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
699         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
700         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
701         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
702         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
703         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
704         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
705         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
706         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
707         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
708         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
709         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
710 }
711 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
712         switch (val) {
713                 case LDKSecp256k1Error_IncorrectSignature:
714                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
715                 case LDKSecp256k1Error_InvalidMessage:
716                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
717                 case LDKSecp256k1Error_InvalidPublicKey:
718                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
719                 case LDKSecp256k1Error_InvalidSignature:
720                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
721                 case LDKSecp256k1Error_InvalidSecretKey:
722                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
723                 case LDKSecp256k1Error_InvalidRecoveryId:
724                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
725                 case LDKSecp256k1Error_InvalidTweak:
726                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
727                 case LDKSecp256k1Error_TweakCheckFailed:
728                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
729                 case LDKSecp256k1Error_NotEnoughMemory:
730                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
731                 default: abort();
732         }
733 }
734
735 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
736         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
737                 case 0: return LDKSemanticError_NoPaymentHash;
738                 case 1: return LDKSemanticError_MultiplePaymentHashes;
739                 case 2: return LDKSemanticError_NoDescription;
740                 case 3: return LDKSemanticError_MultipleDescriptions;
741                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
742                 case 5: return LDKSemanticError_InvalidFeatures;
743                 case 6: return LDKSemanticError_InvalidRecoveryId;
744                 case 7: return LDKSemanticError_InvalidSignature;
745         }
746         abort();
747 }
748 static jclass SemanticError_class = NULL;
749 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
750 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
751 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
752 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
753 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
754 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
755 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
756 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
757 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
758         SemanticError_class = (*env)->NewGlobalRef(env, clz);
759         CHECK(SemanticError_class != NULL);
760         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
761         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
762         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
763         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
764         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
765         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
766         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
767         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
768         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
769         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
770         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
771         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
772         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
773         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
774         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
775         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
776 }
777 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
778         switch (val) {
779                 case LDKSemanticError_NoPaymentHash:
780                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
781                 case LDKSemanticError_MultiplePaymentHashes:
782                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
783                 case LDKSemanticError_NoDescription:
784                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
785                 case LDKSemanticError_MultipleDescriptions:
786                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
787                 case LDKSemanticError_MultiplePaymentSecrets:
788                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
789                 case LDKSemanticError_InvalidFeatures:
790                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
791                 case LDKSemanticError_InvalidRecoveryId:
792                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
793                 case LDKSemanticError_InvalidSignature:
794                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
795                 default: abort();
796         }
797 }
798
799 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
800         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
801                 case 0: return LDKSiPrefix_Milli;
802                 case 1: return LDKSiPrefix_Micro;
803                 case 2: return LDKSiPrefix_Nano;
804                 case 3: return LDKSiPrefix_Pico;
805         }
806         abort();
807 }
808 static jclass SiPrefix_class = NULL;
809 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
810 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
811 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
812 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
813 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
814         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
815         CHECK(SiPrefix_class != NULL);
816         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
817         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
818         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
819         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
820         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
821         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
822         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
823         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
824 }
825 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
826         switch (val) {
827                 case LDKSiPrefix_Milli:
828                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
829                 case LDKSiPrefix_Micro:
830                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
831                 case LDKSiPrefix_Nano:
832                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
833                 case LDKSiPrefix_Pico:
834                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
835                 default: abort();
836         }
837 }
838
839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
840         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
841         ret->datalen = (*env)->GetArrayLength(env, elems);
842         if (ret->datalen == 0) {
843                 ret->data = NULL;
844         } else {
845                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
846                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
847                 for (size_t i = 0; i < ret->datalen; i++) {
848                         ret->data[i] = java_elems[i];
849                 }
850                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
851         }
852         return (uint64_t)ret;
853 }
854 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
855         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
856         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
857         return ret;
858 }
859 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
860         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
861 }
862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
863         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
864         CHECK(val->result_ok);
865         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
866         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
867         return res_arr;
868 }
869 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
870         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
871         CHECK(!val->result_ok);
872         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
873         return err_conv;
874 }
875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
876         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
877 }
878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
879         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
880         CHECK(val->result_ok);
881         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
882         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
883         return res_arr;
884 }
885 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
886         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
887         CHECK(!val->result_ok);
888         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
889         return err_conv;
890 }
891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
892         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
893 }
894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
895         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
896         CHECK(val->result_ok);
897         LDKTxCreationKeys res_var = (*val->contents.result);
898         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
899         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
900         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
901         return res_ref;
902 }
903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
904         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
905         CHECK(!val->result_ok);
906         LDKDecodeError err_var = (*val->contents.err);
907         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
908         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
909         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
910         return err_ref;
911 }
912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
913         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
914 }
915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
916         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
917         CHECK(val->result_ok);
918         LDKChannelPublicKeys res_var = (*val->contents.result);
919         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
920         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
921         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
922         return res_ref;
923 }
924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
925         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
926         CHECK(!val->result_ok);
927         LDKDecodeError err_var = (*val->contents.err);
928         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
929         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
930         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
931         return err_ref;
932 }
933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
934         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
935 }
936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
937         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
938         CHECK(val->result_ok);
939         LDKTxCreationKeys res_var = (*val->contents.result);
940         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
941         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
942         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
943         return res_ref;
944 }
945 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
946         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
947         CHECK(!val->result_ok);
948         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
949         return err_conv;
950 }
951 static jclass LDKCOption_u32Z_Some_class = NULL;
952 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
953 static jclass LDKCOption_u32Z_None_class = NULL;
954 static jmethodID LDKCOption_u32Z_None_meth = NULL;
955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
956         LDKCOption_u32Z_Some_class =
957                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
958         CHECK(LDKCOption_u32Z_Some_class != NULL);
959         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
960         CHECK(LDKCOption_u32Z_Some_meth != NULL);
961         LDKCOption_u32Z_None_class =
962                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
963         CHECK(LDKCOption_u32Z_None_class != NULL);
964         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
965         CHECK(LDKCOption_u32Z_None_meth != NULL);
966 }
967 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
968         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
969         switch(obj->tag) {
970                 case LDKCOption_u32Z_Some: {
971                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
972                 }
973                 case LDKCOption_u32Z_None: {
974                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
975                 }
976                 default: abort();
977         }
978 }
979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
980         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
981 }
982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
983         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
984         CHECK(val->result_ok);
985         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
986         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
987         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
988         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
989         return res_ref;
990 }
991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
992         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
993         CHECK(!val->result_ok);
994         LDKDecodeError err_var = (*val->contents.err);
995         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
996         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
997         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
998         return err_ref;
999 }
1000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1001         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
1002 }
1003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1004         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1005         CHECK(val->result_ok);
1006         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
1007         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1008         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1009         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1010         return res_ref;
1011 }
1012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1013         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1014         CHECK(!val->result_ok);
1015         LDKDecodeError err_var = (*val->contents.err);
1016         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1017         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1018         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1019         return err_ref;
1020 }
1021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1022         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
1023 }
1024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1025         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1026         CHECK(val->result_ok);
1027         LDKChannelTransactionParameters res_var = (*val->contents.result);
1028         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1029         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1030         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1031         return res_ref;
1032 }
1033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1034         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1035         CHECK(!val->result_ok);
1036         LDKDecodeError err_var = (*val->contents.err);
1037         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1038         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1039         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1040         return err_ref;
1041 }
1042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1043         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1044 }
1045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1046         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1047         CHECK(val->result_ok);
1048         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
1049         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1050         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1051         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1052         return res_ref;
1053 }
1054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1055         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1056         CHECK(!val->result_ok);
1057         LDKDecodeError err_var = (*val->contents.err);
1058         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1059         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1060         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1061         return err_ref;
1062 }
1063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1064         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1065 }
1066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1067         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1068         CHECK(val->result_ok);
1069         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
1070         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1071         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1072         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1073         return res_ref;
1074 }
1075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1076         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1077         CHECK(!val->result_ok);
1078         LDKDecodeError err_var = (*val->contents.err);
1079         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1080         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1081         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1082         return err_ref;
1083 }
1084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1085         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1086 }
1087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1088         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1089         CHECK(val->result_ok);
1090         LDKCommitmentTransaction res_var = (*val->contents.result);
1091         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1092         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1093         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1094         return res_ref;
1095 }
1096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1097         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1098         CHECK(!val->result_ok);
1099         LDKDecodeError err_var = (*val->contents.err);
1100         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1101         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1102         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1103         return err_ref;
1104 }
1105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1106         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
1107 }
1108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1109         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1110         CHECK(val->result_ok);
1111         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1112         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1113         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1114         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1115         return res_ref;
1116 }
1117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1118         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1119         CHECK(!val->result_ok);
1120         return *val->contents.err;
1121 }
1122 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1123         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1124 }
1125 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1126         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1127         CHECK(val->result_ok);
1128         LDKCVec_SignatureZ res_var = (*val->contents.result);
1129         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1130         ;
1131         for (size_t i = 0; i < res_var.datalen; i++) {
1132                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1133                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1134                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1135         }
1136         return res_arr;
1137 }
1138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1139         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1140         CHECK(!val->result_ok);
1141         return *val->contents.err;
1142 }
1143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1144         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1145 }
1146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1147         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1148         CHECK(val->result_ok);
1149         return *val->contents.result;
1150 }
1151 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1152         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1153         CHECK(!val->result_ok);
1154         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1155         return err_conv;
1156 }
1157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1158         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1159 }
1160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1161         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1162         CHECK(val->result_ok);
1163         LDKRouteHop res_var = (*val->contents.result);
1164         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1165         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1166         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1167         return res_ref;
1168 }
1169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1170         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1171         CHECK(!val->result_ok);
1172         LDKDecodeError err_var = (*val->contents.err);
1173         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1174         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1175         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1176         return err_ref;
1177 }
1178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1179         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1180         ret->datalen = (*env)->GetArrayLength(env, elems);
1181         if (ret->datalen == 0) {
1182                 ret->data = NULL;
1183         } else {
1184                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1185                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1186                 for (size_t i = 0; i < ret->datalen; i++) {
1187                         int64_t arr_elem = java_elems[i];
1188                         LDKRouteHop arr_elem_conv;
1189                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1190                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1191                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1192                         ret->data[i] = arr_elem_conv;
1193                 }
1194                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1195         }
1196         return (uint64_t)ret;
1197 }
1198 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1199         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1200         for (size_t i = 0; i < ret.datalen; i++) {
1201                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1202         }
1203         return ret;
1204 }
1205 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1206         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1207         for (size_t i = 0; i < ret.datalen; i++) {
1208                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1209         }
1210         return ret;
1211 }
1212 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1213         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1214 }
1215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1216         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1217         CHECK(val->result_ok);
1218         LDKRoute res_var = (*val->contents.result);
1219         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1220         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1221         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1222         return res_ref;
1223 }
1224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1225         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1226         CHECK(!val->result_ok);
1227         LDKDecodeError err_var = (*val->contents.err);
1228         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1229         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1230         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1231         return err_ref;
1232 }
1233 static jclass LDKCOption_u64Z_Some_class = NULL;
1234 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1235 static jclass LDKCOption_u64Z_None_class = NULL;
1236 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1238         LDKCOption_u64Z_Some_class =
1239                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1240         CHECK(LDKCOption_u64Z_Some_class != NULL);
1241         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1242         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1243         LDKCOption_u64Z_None_class =
1244                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1245         CHECK(LDKCOption_u64Z_None_class != NULL);
1246         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1247         CHECK(LDKCOption_u64Z_None_meth != NULL);
1248 }
1249 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1250         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1251         switch(obj->tag) {
1252                 case LDKCOption_u64Z_Some: {
1253                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1254                 }
1255                 case LDKCOption_u64Z_None: {
1256                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1257                 }
1258                 default: abort();
1259         }
1260 }
1261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1262         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1263         ret->datalen = (*env)->GetArrayLength(env, elems);
1264         if (ret->datalen == 0) {
1265                 ret->data = NULL;
1266         } else {
1267                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1268                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1269                 for (size_t i = 0; i < ret->datalen; i++) {
1270                         int64_t arr_elem = java_elems[i];
1271                         LDKChannelDetails arr_elem_conv;
1272                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1273                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1274                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1275                         ret->data[i] = arr_elem_conv;
1276                 }
1277                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1278         }
1279         return (uint64_t)ret;
1280 }
1281 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1282         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1283         for (size_t i = 0; i < ret.datalen; i++) {
1284                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1285         }
1286         return ret;
1287 }
1288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1289         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1290         ret->datalen = (*env)->GetArrayLength(env, elems);
1291         if (ret->datalen == 0) {
1292                 ret->data = NULL;
1293         } else {
1294                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1295                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1296                 for (size_t i = 0; i < ret->datalen; i++) {
1297                         int64_t arr_elem = java_elems[i];
1298                         LDKRouteHint arr_elem_conv;
1299                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1300                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1301                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1302                         ret->data[i] = arr_elem_conv;
1303                 }
1304                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1305         }
1306         return (uint64_t)ret;
1307 }
1308 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1309         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1310         for (size_t i = 0; i < ret.datalen; i++) {
1311                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1312         }
1313         return ret;
1314 }
1315 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1316         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1317 }
1318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1319         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1320         CHECK(val->result_ok);
1321         LDKRoute res_var = (*val->contents.result);
1322         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1323         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1324         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1325         return res_ref;
1326 }
1327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1328         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1329         CHECK(!val->result_ok);
1330         LDKLightningError err_var = (*val->contents.err);
1331         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1332         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1333         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1334         return err_ref;
1335 }
1336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1337         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1338 }
1339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1340         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1341         CHECK(val->result_ok);
1342         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1343         return (uint64_t)res_ref;
1344 }
1345 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1346         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1347         CHECK(!val->result_ok);
1348         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1349         return err_conv;
1350 }
1351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1352         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1353         ret->a = a;
1354         LDKTransaction b_ref;
1355         b_ref.datalen = (*env)->GetArrayLength(env, b);
1356         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1357         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1358         b_ref.data_is_owned = false;
1359         ret->b = b_ref;
1360         return (uint64_t)ret;
1361 }
1362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1363         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1364         return tuple->a;
1365 }
1366 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1367         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1368         LDKTransaction b_var = tuple->b;
1369         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1370         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1371         return b_arr;
1372 }
1373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1374         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1375         ret->datalen = (*env)->GetArrayLength(env, elems);
1376         if (ret->datalen == 0) {
1377                 ret->data = NULL;
1378         } else {
1379                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1380                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1381                 for (size_t i = 0; i < ret->datalen; i++) {
1382                         int64_t arr_elem = java_elems[i];
1383                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1384                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1385                         ret->data[i] = arr_elem_conv;
1386                 }
1387                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1388         }
1389         return (uint64_t)ret;
1390 }
1391 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1392         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1393         for (size_t i = 0; i < ret.datalen; i++) {
1394                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1395         }
1396         return ret;
1397 }
1398 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1399         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1400         for (size_t i = 0; i < ret.datalen; i++) {
1401                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1402         }
1403         return ret;
1404 }
1405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1406         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1407 }
1408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1409         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1410         CHECK(val->result_ok);
1411         return *val->contents.result;
1412 }
1413 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1414         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1415         CHECK(!val->result_ok);
1416         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1417         return err_conv;
1418 }
1419 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1420 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1421 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1422 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1424         LDKMonitorEvent_HTLCEvent_class =
1425                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1426         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1427         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1428         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1429         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1431         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1432         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1433         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1434 }
1435 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1436         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1437         switch(obj->tag) {
1438                 case LDKMonitorEvent_HTLCEvent: {
1439                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1440                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1441                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1442                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1443                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1444                 }
1445                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1446                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1447                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1448                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1449                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1450                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1451                 }
1452                 default: abort();
1453         }
1454 }
1455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1456         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1457         ret->datalen = (*env)->GetArrayLength(env, elems);
1458         if (ret->datalen == 0) {
1459                 ret->data = NULL;
1460         } else {
1461                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1462                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1463                 for (size_t i = 0; i < ret->datalen; i++) {
1464                         int64_t arr_elem = java_elems[i];
1465                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1466                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1467                         ret->data[i] = arr_elem_conv;
1468                 }
1469                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1470         }
1471         return (uint64_t)ret;
1472 }
1473 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1474         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1475         for (size_t i = 0; i < ret.datalen; i++) {
1476                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1477         }
1478         return ret;
1479 }
1480 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1481 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1482 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1483 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1485         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1486                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1487         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1488         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1489         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1490         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1491                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1492         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1493         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1494         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1495 }
1496 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1497         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1498         switch(obj->tag) {
1499                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1500                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1501                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1502                 }
1503                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1504                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1505                 }
1506                 default: abort();
1507         }
1508 }
1509 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1510 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1511 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1512 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1513 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1514 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1516         LDKSpendableOutputDescriptor_StaticOutput_class =
1517                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1518         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1519         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1520         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1521         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1522                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1523         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1524         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1525         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1526         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1527                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1528         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1529         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1530         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1531 }
1532 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1533         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1534         switch(obj->tag) {
1535                 case LDKSpendableOutputDescriptor_StaticOutput: {
1536                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1537                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1538                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1539                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1540                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1541                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1542                 }
1543                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1544                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1545                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1546                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1547                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1548                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1549                 }
1550                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1551                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1552                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1553                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1554                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1555                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1556                 }
1557                 default: abort();
1558         }
1559 }
1560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1561         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1562         ret->datalen = (*env)->GetArrayLength(env, elems);
1563         if (ret->datalen == 0) {
1564                 ret->data = NULL;
1565         } else {
1566                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1567                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1568                 for (size_t i = 0; i < ret->datalen; i++) {
1569                         int64_t arr_elem = java_elems[i];
1570                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1571                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1572                         ret->data[i] = arr_elem_conv;
1573                 }
1574                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1575         }
1576         return (uint64_t)ret;
1577 }
1578 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1579         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1580         for (size_t i = 0; i < ret.datalen; i++) {
1581                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1582         }
1583         return ret;
1584 }
1585 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1586 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1587 static jclass LDKErrorAction_IgnoreError_class = NULL;
1588 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1589 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1590 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1591 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1592 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1594         LDKErrorAction_DisconnectPeer_class =
1595                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1596         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1597         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1598         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1599         LDKErrorAction_IgnoreError_class =
1600                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1601         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1602         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1603         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1604         LDKErrorAction_IgnoreAndLog_class =
1605                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1606         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1607         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1608         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1609         LDKErrorAction_SendErrorMessage_class =
1610                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1611         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1612         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1613         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1614 }
1615 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1616         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1617         switch(obj->tag) {
1618                 case LDKErrorAction_DisconnectPeer: {
1619                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1620                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1621                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1622                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1623                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1624                 }
1625                 case LDKErrorAction_IgnoreError: {
1626                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1627                 }
1628                 case LDKErrorAction_IgnoreAndLog: {
1629                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1630                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1631                 }
1632                 case LDKErrorAction_SendErrorMessage: {
1633                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1634                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1635                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1636                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1637                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1638                 }
1639                 default: abort();
1640         }
1641 }
1642 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1643 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1644 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1645 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1646 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1647 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1649         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1650                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1651         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1652         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1653         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1654         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1655                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1656         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1657         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1658         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1659         LDKHTLCFailChannelUpdate_NodeFailure_class =
1660                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1661         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1662         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1663         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1664 }
1665 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1666         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1667         switch(obj->tag) {
1668                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1669                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1670                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1671                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1672                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1673                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1674                 }
1675                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1676                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1677                 }
1678                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1679                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1680                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1681                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1682                 }
1683                 default: abort();
1684         }
1685 }
1686 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1687 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1688 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1689 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1690 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1691 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1692 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1693 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1694 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1695 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1696 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1697 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1698 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1699 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1700 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1701 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1702 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1703 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1704 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1705 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1706 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1707 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1708 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1709 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1710 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1711 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1712 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1713 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1714 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1715 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1716 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1717 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1718 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1719 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1720 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1721 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1722 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1723 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1724 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1725 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1727         LDKMessageSendEvent_SendAcceptChannel_class =
1728                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1729         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1730         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1731         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1732         LDKMessageSendEvent_SendOpenChannel_class =
1733                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1734         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1735         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1736         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1737         LDKMessageSendEvent_SendFundingCreated_class =
1738                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1739         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1740         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1741         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1742         LDKMessageSendEvent_SendFundingSigned_class =
1743                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1744         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1745         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1746         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1747         LDKMessageSendEvent_SendFundingLocked_class =
1748                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1749         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1750         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1751         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1752         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1753                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1754         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1755         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1756         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1757         LDKMessageSendEvent_UpdateHTLCs_class =
1758                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1759         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1760         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1761         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1762         LDKMessageSendEvent_SendRevokeAndACK_class =
1763                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1764         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1765         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1766         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1767         LDKMessageSendEvent_SendClosingSigned_class =
1768                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1769         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1770         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1771         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1772         LDKMessageSendEvent_SendShutdown_class =
1773                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1774         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1775         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1776         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1777         LDKMessageSendEvent_SendChannelReestablish_class =
1778                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1779         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1780         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1781         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1782         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1783                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1784         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1785         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1786         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1787         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1788                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1789         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1790         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1791         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1792         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1793                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1794         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1795         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1796         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1797         LDKMessageSendEvent_SendChannelUpdate_class =
1798                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1799         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1800         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1801         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1802         LDKMessageSendEvent_HandleError_class =
1803                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1804         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1805         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1806         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1807         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1808                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1809         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1810         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1811         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1812         LDKMessageSendEvent_SendChannelRangeQuery_class =
1813                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1814         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1815         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1816         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1817         LDKMessageSendEvent_SendShortIdsQuery_class =
1818                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1819         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1820         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1821         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1822         LDKMessageSendEvent_SendReplyChannelRange_class =
1823                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1824         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1825         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1826         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1827 }
1828 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1829         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1830         switch(obj->tag) {
1831                 case LDKMessageSendEvent_SendAcceptChannel: {
1832                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1833                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1834                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1835                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1836                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1837                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1838                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1839                 }
1840                 case LDKMessageSendEvent_SendOpenChannel: {
1841                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1842                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1843                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1844                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1845                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1846                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1847                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1848                 }
1849                 case LDKMessageSendEvent_SendFundingCreated: {
1850                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1851                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1852                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1853                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1854                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1855                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1856                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1857                 }
1858                 case LDKMessageSendEvent_SendFundingSigned: {
1859                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1860                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1861                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1862                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1863                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1864                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1865                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1866                 }
1867                 case LDKMessageSendEvent_SendFundingLocked: {
1868                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1869                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1870                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1871                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1872                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1873                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1874                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1875                 }
1876                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1877                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1878                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1879                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1880                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1881                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1882                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1883                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1884                 }
1885                 case LDKMessageSendEvent_UpdateHTLCs: {
1886                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1887                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1888                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1889                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1890                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1891                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1892                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1893                 }
1894                 case LDKMessageSendEvent_SendRevokeAndACK: {
1895                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1896                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1897                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1898                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1899                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1900                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1901                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1902                 }
1903                 case LDKMessageSendEvent_SendClosingSigned: {
1904                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1905                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1906                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1907                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1908                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1909                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1910                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1911                 }
1912                 case LDKMessageSendEvent_SendShutdown: {
1913                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1914                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1915                         LDKShutdown msg_var = obj->send_shutdown.msg;
1916                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1917                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1918                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1919                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1920                 }
1921                 case LDKMessageSendEvent_SendChannelReestablish: {
1922                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1923                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1924                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1925                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1926                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1927                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1928                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1929                 }
1930                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1931                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1932                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1933                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1934                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1935                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1936                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1937                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1938                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1939                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1940                 }
1941                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1942                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1943                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1944                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1945                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1946                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1947                 }
1948                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1949                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1950                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1951                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1952                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1953                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1954                 }
1955                 case LDKMessageSendEvent_SendChannelUpdate: {
1956                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1957                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1958                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1959                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1960                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1961                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1962                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1963                 }
1964                 case LDKMessageSendEvent_HandleError: {
1965                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1966                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1967                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1968                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1969                 }
1970                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1971                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1972                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1973                 }
1974                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1975                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1976                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1977                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1978                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1979                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1980                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1981                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1982                 }
1983                 case LDKMessageSendEvent_SendShortIdsQuery: {
1984                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1985                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1986                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1987                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1988                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1989                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1990                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1991                 }
1992                 case LDKMessageSendEvent_SendReplyChannelRange: {
1993                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1994                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1995                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1996                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1997                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1998                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1999                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2000                 }
2001                 default: abort();
2002         }
2003 }
2004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2005         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
2006         ret->datalen = (*env)->GetArrayLength(env, elems);
2007         if (ret->datalen == 0) {
2008                 ret->data = NULL;
2009         } else {
2010                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
2011                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2012                 for (size_t i = 0; i < ret->datalen; i++) {
2013                         int64_t arr_elem = java_elems[i];
2014                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
2015                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
2016                         ret->data[i] = arr_elem_conv;
2017                 }
2018                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2019         }
2020         return (uint64_t)ret;
2021 }
2022 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2023         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2024         for (size_t i = 0; i < ret.datalen; i++) {
2025                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2026         }
2027         return ret;
2028 }
2029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2030         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
2031 }
2032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2033         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2034         CHECK(val->result_ok);
2035         LDKInitFeatures res_var = (*val->contents.result);
2036         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2037         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2038         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2039         return res_ref;
2040 }
2041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2042         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2043         CHECK(!val->result_ok);
2044         LDKDecodeError err_var = (*val->contents.err);
2045         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2046         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2047         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2048         return err_ref;
2049 }
2050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2051         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
2052 }
2053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2054         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2055         CHECK(val->result_ok);
2056         LDKNodeFeatures res_var = (*val->contents.result);
2057         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2058         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2059         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2060         return res_ref;
2061 }
2062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2063         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2064         CHECK(!val->result_ok);
2065         LDKDecodeError err_var = (*val->contents.err);
2066         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2067         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2068         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2069         return err_ref;
2070 }
2071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2072         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
2073 }
2074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2075         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2076         CHECK(val->result_ok);
2077         LDKChannelFeatures res_var = (*val->contents.result);
2078         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2079         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2080         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2081         return res_ref;
2082 }
2083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2084         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2085         CHECK(!val->result_ok);
2086         LDKDecodeError err_var = (*val->contents.err);
2087         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2088         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2089         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2090         return err_ref;
2091 }
2092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2093         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
2094 }
2095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2096         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2097         CHECK(val->result_ok);
2098         LDKInvoiceFeatures res_var = (*val->contents.result);
2099         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2100         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2101         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2102         return res_ref;
2103 }
2104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2105         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2106         CHECK(!val->result_ok);
2107         LDKDecodeError err_var = (*val->contents.err);
2108         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2109         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2110         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2111         return err_ref;
2112 }
2113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2114         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2115 }
2116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2117         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2118         CHECK(val->result_ok);
2119         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2120         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2121         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2122         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2123         return res_ref;
2124 }
2125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2126         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2127         CHECK(!val->result_ok);
2128         LDKDecodeError err_var = (*val->contents.err);
2129         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2130         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2131         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2132         return err_ref;
2133 }
2134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2135         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2136 }
2137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2138         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2139         CHECK(val->result_ok);
2140         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2141         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2142         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2143         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2144         return res_ref;
2145 }
2146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2147         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2148         CHECK(!val->result_ok);
2149         LDKDecodeError err_var = (*val->contents.err);
2150         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2151         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2152         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2153         return err_ref;
2154 }
2155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2156         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2157 }
2158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2159         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2160         CHECK(val->result_ok);
2161         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2162         return res_ref;
2163 }
2164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2165         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2166         CHECK(!val->result_ok);
2167         LDKDecodeError err_var = (*val->contents.err);
2168         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2169         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2170         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2171         return err_ref;
2172 }
2173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2174         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2175         LDKSignature a_ref;
2176         CHECK((*env)->GetArrayLength(env, a) == 64);
2177         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2178         ret->a = a_ref;
2179         LDKCVec_SignatureZ b_constr;
2180         b_constr.datalen = (*env)->GetArrayLength(env, b);
2181         if (b_constr.datalen > 0)
2182                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2183         else
2184                 b_constr.data = NULL;
2185         for (size_t i = 0; i < b_constr.datalen; i++) {
2186                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2187                 LDKSignature b_conv_8_ref;
2188                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2189                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2190                 b_constr.data[i] = b_conv_8_ref;
2191         }
2192         ret->b = b_constr;
2193         return (uint64_t)ret;
2194 }
2195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2196         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2197         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2198         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2199         return a_arr;
2200 }
2201 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2202         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2203         LDKCVec_SignatureZ b_var = tuple->b;
2204         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2205         ;
2206         for (size_t i = 0; i < b_var.datalen; i++) {
2207                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2208                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2209                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2210         }
2211         return b_arr;
2212 }
2213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2214         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2215 }
2216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2217         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2218         CHECK(val->result_ok);
2219         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2220         return res_ref;
2221 }
2222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2223         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2224         CHECK(!val->result_ok);
2225         return *val->contents.err;
2226 }
2227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2228         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2229 }
2230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2231         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2232         CHECK(val->result_ok);
2233         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2234         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2235         return res_arr;
2236 }
2237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2238         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2239         CHECK(!val->result_ok);
2240         return *val->contents.err;
2241 }
2242 typedef struct LDKBaseSign_JCalls {
2243         atomic_size_t refcnt;
2244         JavaVM *vm;
2245         jweak o;
2246         jmethodID get_per_commitment_point_meth;
2247         jmethodID release_commitment_secret_meth;
2248         jmethodID channel_keys_id_meth;
2249         jmethodID sign_counterparty_commitment_meth;
2250         jmethodID sign_holder_commitment_and_htlcs_meth;
2251         jmethodID sign_justice_revoked_output_meth;
2252         jmethodID sign_justice_revoked_htlc_meth;
2253         jmethodID sign_counterparty_htlc_transaction_meth;
2254         jmethodID sign_closing_transaction_meth;
2255         jmethodID sign_channel_announcement_meth;
2256         jmethodID ready_channel_meth;
2257 } LDKBaseSign_JCalls;
2258 static void LDKBaseSign_JCalls_free(void* this_arg) {
2259         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2260         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2261                 JNIEnv *env;
2262                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2263                 if (get_jenv_res == JNI_EDETACHED) {
2264                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2265                 } else {
2266                         DO_ASSERT(get_jenv_res == JNI_OK);
2267                 }
2268                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2269                 if (get_jenv_res == JNI_EDETACHED) {
2270                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2271                 }
2272                 FREE(j_calls);
2273         }
2274 }
2275 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2276         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2277         JNIEnv *env;
2278         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2279         if (get_jenv_res == JNI_EDETACHED) {
2280                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2281         } else {
2282                 DO_ASSERT(get_jenv_res == JNI_OK);
2283         }
2284         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2285         CHECK(obj != NULL);
2286         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2287         if ((*env)->ExceptionCheck(env)) {
2288                 (*env)->ExceptionDescribe(env);
2289                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2290         }
2291         LDKPublicKey ret_ref;
2292         CHECK((*env)->GetArrayLength(env, ret) == 33);
2293         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2294         if (get_jenv_res == JNI_EDETACHED) {
2295                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2296         }
2297         return ret_ref;
2298 }
2299 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2300         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2301         JNIEnv *env;
2302         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2303         if (get_jenv_res == JNI_EDETACHED) {
2304                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2305         } else {
2306                 DO_ASSERT(get_jenv_res == JNI_OK);
2307         }
2308         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2309         CHECK(obj != NULL);
2310         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2311         if ((*env)->ExceptionCheck(env)) {
2312                 (*env)->ExceptionDescribe(env);
2313                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2314         }
2315         LDKThirtyTwoBytes ret_ref;
2316         CHECK((*env)->GetArrayLength(env, ret) == 32);
2317         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2318         if (get_jenv_res == JNI_EDETACHED) {
2319                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2320         }
2321         return ret_ref;
2322 }
2323 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2324         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2325         JNIEnv *env;
2326         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2327         if (get_jenv_res == JNI_EDETACHED) {
2328                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2329         } else {
2330                 DO_ASSERT(get_jenv_res == JNI_OK);
2331         }
2332         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2333         CHECK(obj != NULL);
2334         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2335         if ((*env)->ExceptionCheck(env)) {
2336                 (*env)->ExceptionDescribe(env);
2337                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2338         }
2339         LDKThirtyTwoBytes ret_ref;
2340         CHECK((*env)->GetArrayLength(env, ret) == 32);
2341         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2342         if (get_jenv_res == JNI_EDETACHED) {
2343                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2344         }
2345         return ret_ref;
2346 }
2347 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2348         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2349         JNIEnv *env;
2350         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2351         if (get_jenv_res == JNI_EDETACHED) {
2352                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2353         } else {
2354                 DO_ASSERT(get_jenv_res == JNI_OK);
2355         }
2356         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2357         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2358         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2359         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2360         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2361         if (commitment_tx_var.is_owned) {
2362                 commitment_tx_ref |= 1;
2363         }
2364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2365         CHECK(obj != NULL);
2366         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2367         if ((*env)->ExceptionCheck(env)) {
2368                 (*env)->ExceptionDescribe(env);
2369                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2370         }
2371         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2372         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2373         if (get_jenv_res == JNI_EDETACHED) {
2374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2375         }
2376         return ret_conv;
2377 }
2378 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2379         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2380         JNIEnv *env;
2381         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2382         if (get_jenv_res == JNI_EDETACHED) {
2383                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2384         } else {
2385                 DO_ASSERT(get_jenv_res == JNI_OK);
2386         }
2387         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2388         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2389         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2390         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2391         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2392         if (commitment_tx_var.is_owned) {
2393                 commitment_tx_ref |= 1;
2394         }
2395         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2396         CHECK(obj != NULL);
2397         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2398         if ((*env)->ExceptionCheck(env)) {
2399                 (*env)->ExceptionDescribe(env);
2400                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2401         }
2402         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2403         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2404         if (get_jenv_res == JNI_EDETACHED) {
2405                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2406         }
2407         return ret_conv;
2408 }
2409 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]) {
2410         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2411         JNIEnv *env;
2412         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2413         if (get_jenv_res == JNI_EDETACHED) {
2414                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2415         } else {
2416                 DO_ASSERT(get_jenv_res == JNI_OK);
2417         }
2418         LDKTransaction justice_tx_var = justice_tx;
2419         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2420         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2421         Transaction_free(justice_tx_var);
2422         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2423         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2424         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2425         CHECK(obj != NULL);
2426         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2427         if ((*env)->ExceptionCheck(env)) {
2428                 (*env)->ExceptionDescribe(env);
2429                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2430         }
2431         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2432         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2433         if (get_jenv_res == JNI_EDETACHED) {
2434                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2435         }
2436         return ret_conv;
2437 }
2438 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) {
2439         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2440         JNIEnv *env;
2441         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2442         if (get_jenv_res == JNI_EDETACHED) {
2443                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2444         } else {
2445                 DO_ASSERT(get_jenv_res == JNI_OK);
2446         }
2447         LDKTransaction justice_tx_var = justice_tx;
2448         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2449         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2450         Transaction_free(justice_tx_var);
2451         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2452         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2453         LDKHTLCOutputInCommitment htlc_var = *htlc;
2454         htlc_var = HTLCOutputInCommitment_clone(htlc);
2455         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2456         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2457         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2458         if (htlc_var.is_owned) {
2459                 htlc_ref |= 1;
2460         }
2461         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2462         CHECK(obj != NULL);
2463         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2464         if ((*env)->ExceptionCheck(env)) {
2465                 (*env)->ExceptionDescribe(env);
2466                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2467         }
2468         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2469         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2470         if (get_jenv_res == JNI_EDETACHED) {
2471                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2472         }
2473         return ret_conv;
2474 }
2475 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) {
2476         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2477         JNIEnv *env;
2478         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2479         if (get_jenv_res == JNI_EDETACHED) {
2480                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2481         } else {
2482                 DO_ASSERT(get_jenv_res == JNI_OK);
2483         }
2484         LDKTransaction htlc_tx_var = htlc_tx;
2485         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2486         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2487         Transaction_free(htlc_tx_var);
2488         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2489         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2490         LDKHTLCOutputInCommitment htlc_var = *htlc;
2491         htlc_var = HTLCOutputInCommitment_clone(htlc);
2492         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2493         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2494         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2495         if (htlc_var.is_owned) {
2496                 htlc_ref |= 1;
2497         }
2498         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2499         CHECK(obj != NULL);
2500         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2501         if ((*env)->ExceptionCheck(env)) {
2502                 (*env)->ExceptionDescribe(env);
2503                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2504         }
2505         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2506         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2507         if (get_jenv_res == JNI_EDETACHED) {
2508                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2509         }
2510         return ret_conv;
2511 }
2512 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2513         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2514         JNIEnv *env;
2515         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2516         if (get_jenv_res == JNI_EDETACHED) {
2517                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2518         } else {
2519                 DO_ASSERT(get_jenv_res == JNI_OK);
2520         }
2521         LDKTransaction closing_tx_var = closing_tx;
2522         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2523         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2524         Transaction_free(closing_tx_var);
2525         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2526         CHECK(obj != NULL);
2527         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2528         if ((*env)->ExceptionCheck(env)) {
2529                 (*env)->ExceptionDescribe(env);
2530                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2531         }
2532         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2533         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2534         if (get_jenv_res == JNI_EDETACHED) {
2535                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2536         }
2537         return ret_conv;
2538 }
2539 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2540         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2541         JNIEnv *env;
2542         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2543         if (get_jenv_res == JNI_EDETACHED) {
2544                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2545         } else {
2546                 DO_ASSERT(get_jenv_res == JNI_OK);
2547         }
2548         LDKUnsignedChannelAnnouncement msg_var = *msg;
2549         msg_var = UnsignedChannelAnnouncement_clone(msg);
2550         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2551         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2552         uint64_t msg_ref = (uint64_t)msg_var.inner;
2553         if (msg_var.is_owned) {
2554                 msg_ref |= 1;
2555         }
2556         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2557         CHECK(obj != NULL);
2558         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2559         if ((*env)->ExceptionCheck(env)) {
2560                 (*env)->ExceptionDescribe(env);
2561                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2562         }
2563         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2564         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2565         if (get_jenv_res == JNI_EDETACHED) {
2566                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2567         }
2568         return ret_conv;
2569 }
2570 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2571         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2572         JNIEnv *env;
2573         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2574         if (get_jenv_res == JNI_EDETACHED) {
2575                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2576         } else {
2577                 DO_ASSERT(get_jenv_res == JNI_OK);
2578         }
2579         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2580         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2581         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2582         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2583         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2584         if (channel_parameters_var.is_owned) {
2585                 channel_parameters_ref |= 1;
2586         }
2587         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2588         CHECK(obj != NULL);
2589         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2590         if ((*env)->ExceptionCheck(env)) {
2591                 (*env)->ExceptionDescribe(env);
2592                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2593         }
2594         if (get_jenv_res == JNI_EDETACHED) {
2595                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2596         }
2597 }
2598 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2599         jclass c = (*env)->GetObjectClass(env, o);
2600         CHECK(c != NULL);
2601         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2602         atomic_init(&calls->refcnt, 1);
2603         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2604         calls->o = (*env)->NewWeakGlobalRef(env, o);
2605         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2606         CHECK(calls->get_per_commitment_point_meth != NULL);
2607         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2608         CHECK(calls->release_commitment_secret_meth != NULL);
2609         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2610         CHECK(calls->channel_keys_id_meth != NULL);
2611         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2612         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2613         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2614         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2615         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2616         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2617         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2618         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2619         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2620         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2621         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2622         CHECK(calls->sign_closing_transaction_meth != NULL);
2623         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2624         CHECK(calls->sign_channel_announcement_meth != NULL);
2625         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2626         CHECK(calls->ready_channel_meth != NULL);
2627
2628         LDKChannelPublicKeys pubkeys_conv;
2629         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2630         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2631         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2632
2633         LDKBaseSign ret = {
2634                 .this_arg = (void*) calls,
2635                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2636                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2637                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2638                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2639                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2640                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2641                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2642                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2643                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2644                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2645                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2646                 .free = LDKBaseSign_JCalls_free,
2647                 .pubkeys = pubkeys_conv,
2648                 .set_pubkeys = NULL,
2649         };
2650         return ret;
2651 }
2652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2653         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2654         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2655         return (uint64_t)res_ptr;
2656 }
2657 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) {
2658         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2659         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2660         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2661         return ret_arr;
2662 }
2663
2664 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2665         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2666         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2668         return ret_arr;
2669 }
2670
2671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2672         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2673         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2675         return ret_arr;
2676 }
2677
2678 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) {
2679         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2680         LDKCommitmentTransaction commitment_tx_conv;
2681         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2682         commitment_tx_conv.is_owned = false;
2683         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2684         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2685         return (uint64_t)ret_conv;
2686 }
2687
2688 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) {
2689         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2690         LDKHolderCommitmentTransaction commitment_tx_conv;
2691         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2692         commitment_tx_conv.is_owned = false;
2693         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2694         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2695         return (uint64_t)ret_conv;
2696 }
2697
2698 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) {
2699         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2700         LDKTransaction justice_tx_ref;
2701         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2702         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2703         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2704         justice_tx_ref.data_is_owned = true;
2705         unsigned char per_commitment_key_arr[32];
2706         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2707         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2708         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2709         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2710         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2711         return (uint64_t)ret_conv;
2712 }
2713
2714 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) {
2715         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2716         LDKTransaction justice_tx_ref;
2717         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2718         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2719         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2720         justice_tx_ref.data_is_owned = true;
2721         unsigned char per_commitment_key_arr[32];
2722         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2723         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2724         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2725         LDKHTLCOutputInCommitment htlc_conv;
2726         htlc_conv.inner = (void*)(htlc & (~1));
2727         htlc_conv.is_owned = false;
2728         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2729         *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);
2730         return (uint64_t)ret_conv;
2731 }
2732
2733 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) {
2734         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2735         LDKTransaction htlc_tx_ref;
2736         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2737         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2738         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2739         htlc_tx_ref.data_is_owned = true;
2740         LDKPublicKey per_commitment_point_ref;
2741         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2742         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2743         LDKHTLCOutputInCommitment htlc_conv;
2744         htlc_conv.inner = (void*)(htlc & (~1));
2745         htlc_conv.is_owned = false;
2746         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2747         *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);
2748         return (uint64_t)ret_conv;
2749 }
2750
2751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
2752         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2753         LDKTransaction closing_tx_ref;
2754         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2755         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2756         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2757         closing_tx_ref.data_is_owned = true;
2758         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2759         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2760         return (uint64_t)ret_conv;
2761 }
2762
2763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2764         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2765         LDKUnsignedChannelAnnouncement msg_conv;
2766         msg_conv.inner = (void*)(msg & (~1));
2767         msg_conv.is_owned = false;
2768         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2769         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2770         return (uint64_t)ret_conv;
2771 }
2772
2773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2774         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2775         LDKChannelTransactionParameters channel_parameters_conv;
2776         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2777         channel_parameters_conv.is_owned = false;
2778         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2779 }
2780
2781 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2782         if (this_arg->set_pubkeys != NULL)
2783                 this_arg->set_pubkeys(this_arg);
2784         return this_arg->pubkeys;
2785 }
2786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2787         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2788         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2789         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2790         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2791         uint64_t ret_ref = (uint64_t)ret_var.inner;
2792         if (ret_var.is_owned) {
2793                 ret_ref |= 1;
2794         }
2795         return ret_ref;
2796 }
2797
2798 typedef struct LDKSign_JCalls {
2799         atomic_size_t refcnt;
2800         JavaVM *vm;
2801         jweak o;
2802         LDKBaseSign_JCalls* BaseSign;
2803         jmethodID write_meth;
2804 } LDKSign_JCalls;
2805 static void LDKSign_JCalls_free(void* this_arg) {
2806         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2807         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2808                 JNIEnv *env;
2809                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2810                 if (get_jenv_res == JNI_EDETACHED) {
2811                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2812                 } else {
2813                         DO_ASSERT(get_jenv_res == JNI_OK);
2814                 }
2815                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2816                 if (get_jenv_res == JNI_EDETACHED) {
2817                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2818                 }
2819                 FREE(j_calls);
2820         }
2821 }
2822 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2823         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2824         JNIEnv *env;
2825         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2826         if (get_jenv_res == JNI_EDETACHED) {
2827                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2828         } else {
2829                 DO_ASSERT(get_jenv_res == JNI_OK);
2830         }
2831         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2832         CHECK(obj != NULL);
2833         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2834         if ((*env)->ExceptionCheck(env)) {
2835                 (*env)->ExceptionDescribe(env);
2836                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2837         }
2838         LDKCVec_u8Z ret_ref;
2839         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2840         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2841         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2842         if (get_jenv_res == JNI_EDETACHED) {
2843                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2844         }
2845         return ret_ref;
2846 }
2847 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2848         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2849         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2850         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2851 }
2852 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2853         jclass c = (*env)->GetObjectClass(env, o);
2854         CHECK(c != NULL);
2855         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2856         atomic_init(&calls->refcnt, 1);
2857         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2858         calls->o = (*env)->NewWeakGlobalRef(env, o);
2859         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2860         CHECK(calls->write_meth != NULL);
2861
2862         LDKChannelPublicKeys pubkeys_conv;
2863         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2864         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2865         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2866
2867         LDKSign ret = {
2868                 .this_arg = (void*) calls,
2869                 .write = write_LDKSign_jcall,
2870                 .cloned = LDKSign_JCalls_cloned,
2871                 .free = LDKSign_JCalls_free,
2872                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2873         };
2874         calls->BaseSign = ret.BaseSign.this_arg;
2875         return ret;
2876 }
2877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2878         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2879         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2880         return (uint64_t)res_ptr;
2881 }
2882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
2883         LDKSign *inp = (LDKSign *)(arg & ~1);
2884         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
2885         DO_ASSERT((res_ptr & 1) == 0);
2886         return (int64_t)(res_ptr | 1);
2887 }
2888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2889         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2890         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2893         CVec_u8Z_free(ret_var);
2894         return ret_arr;
2895 }
2896
2897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2898         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2899 }
2900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2901         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2902         CHECK(val->result_ok);
2903         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2904         *ret = Sign_clone(&(*val->contents.result));
2905         return (uint64_t)ret;
2906 }
2907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2908         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2909         CHECK(!val->result_ok);
2910         LDKDecodeError err_var = (*val->contents.err);
2911         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2912         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2913         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2914         return err_ref;
2915 }
2916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2917         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2918 }
2919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2920         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2921         CHECK(val->result_ok);
2922         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2923         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2924         return es_arr;
2925 }
2926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2927         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2928         CHECK(!val->result_ok);
2929         return *val->contents.err;
2930 }
2931 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2932         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2933         for (size_t i = 0; i < ret.datalen; i++) {
2934                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2935         }
2936         return ret;
2937 }
2938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2939         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2940 }
2941 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2942         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2943         CHECK(val->result_ok);
2944         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2945         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2946         ;
2947         for (size_t i = 0; i < res_var.datalen; i++) {
2948                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2949                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2950                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2951                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2952         }
2953         return res_arr;
2954 }
2955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2956         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2957         CHECK(!val->result_ok);
2958         return *val->contents.err;
2959 }
2960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2961         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2962 }
2963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2964         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2965         CHECK(val->result_ok);
2966         LDKInMemorySigner res_var = (*val->contents.result);
2967         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2968         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2969         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2970         return res_ref;
2971 }
2972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2973         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2974         CHECK(!val->result_ok);
2975         LDKDecodeError err_var = (*val->contents.err);
2976         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2977         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2978         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2979         return err_ref;
2980 }
2981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2982         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2983         ret->datalen = (*env)->GetArrayLength(env, elems);
2984         if (ret->datalen == 0) {
2985                 ret->data = NULL;
2986         } else {
2987                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2988                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2989                 for (size_t i = 0; i < ret->datalen; i++) {
2990                         int64_t arr_elem = java_elems[i];
2991                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2992                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2993                         ret->data[i] = arr_elem_conv;
2994                 }
2995                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2996         }
2997         return (uint64_t)ret;
2998 }
2999 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3000         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3001         for (size_t i = 0; i < ret.datalen; i++) {
3002                 ret.data[i] = TxOut_clone(&orig->data[i]);
3003         }
3004         return ret;
3005 }
3006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3007         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3008 }
3009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3010         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3011         CHECK(val->result_ok);
3012         LDKTransaction res_var = (*val->contents.result);
3013         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3014         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3015         return res_arr;
3016 }
3017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3018         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3019         CHECK(!val->result_ok);
3020         return *val->contents.err;
3021 }
3022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3023         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3024         LDKThirtyTwoBytes a_ref;
3025         CHECK((*env)->GetArrayLength(env, a) == 32);
3026         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3027         ret->a = a_ref;
3028         LDKChannelMonitor b_conv;
3029         b_conv.inner = (void*)(b & (~1));
3030         b_conv.is_owned = (b & 1) || (b == 0);
3031         b_conv = ChannelMonitor_clone(&b_conv);
3032         ret->b = b_conv;
3033         return (uint64_t)ret;
3034 }
3035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3036         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
3037         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3038         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3039         return a_arr;
3040 }
3041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3042         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
3043         LDKChannelMonitor b_var = tuple->b;
3044         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3045         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3046         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3047         return b_ref;
3048 }
3049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3050         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
3051         ret->datalen = (*env)->GetArrayLength(env, elems);
3052         if (ret->datalen == 0) {
3053                 ret->data = NULL;
3054         } else {
3055                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
3056                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3057                 for (size_t i = 0; i < ret->datalen; i++) {
3058                         int64_t arr_elem = java_elems[i];
3059                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
3060                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
3061                         ret->data[i] = arr_elem_conv;
3062                 }
3063                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3064         }
3065         return (uint64_t)ret;
3066 }
3067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3068         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
3069 }
3070 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3071         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3072         CHECK(val->result_ok);
3073         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3074         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
3075         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3076         for (size_t i = 0; i < res_var.datalen; i++) {
3077                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
3078                 res_arr_ptr[i] = res_conv_34_ref;
3079         }
3080         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3081         return res_arr;
3082 }
3083 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3084         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3085         CHECK(!val->result_ok);
3086         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3087         return err_conv;
3088 }
3089 static jclass LDKCOption_u16Z_Some_class = NULL;
3090 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3091 static jclass LDKCOption_u16Z_None_class = NULL;
3092 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3094         LDKCOption_u16Z_Some_class =
3095                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3096         CHECK(LDKCOption_u16Z_Some_class != NULL);
3097         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3098         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3099         LDKCOption_u16Z_None_class =
3100                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3101         CHECK(LDKCOption_u16Z_None_class != NULL);
3102         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3103         CHECK(LDKCOption_u16Z_None_meth != NULL);
3104 }
3105 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3106         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3107         switch(obj->tag) {
3108                 case LDKCOption_u16Z_Some: {
3109                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3110                 }
3111                 case LDKCOption_u16Z_None: {
3112                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3113                 }
3114                 default: abort();
3115         }
3116 }
3117 static jclass LDKAPIError_APIMisuseError_class = NULL;
3118 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3119 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3120 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3121 static jclass LDKAPIError_RouteError_class = NULL;
3122 static jmethodID LDKAPIError_RouteError_meth = NULL;
3123 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3124 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3125 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3126 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3128         LDKAPIError_APIMisuseError_class =
3129                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3130         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3131         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3132         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3133         LDKAPIError_FeeRateTooHigh_class =
3134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3135         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3136         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3137         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3138         LDKAPIError_RouteError_class =
3139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3140         CHECK(LDKAPIError_RouteError_class != NULL);
3141         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3142         CHECK(LDKAPIError_RouteError_meth != NULL);
3143         LDKAPIError_ChannelUnavailable_class =
3144                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3145         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3146         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3147         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3148         LDKAPIError_MonitorUpdateFailed_class =
3149                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3150         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3151         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3152         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3153 }
3154 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3155         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3156         switch(obj->tag) {
3157                 case LDKAPIError_APIMisuseError: {
3158                         LDKStr err_str = obj->api_misuse_error.err;
3159                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3160                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3161                 }
3162                 case LDKAPIError_FeeRateTooHigh: {
3163                         LDKStr err_str = obj->fee_rate_too_high.err;
3164                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3165                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3166                 }
3167                 case LDKAPIError_RouteError: {
3168                         LDKStr err_str = obj->route_error.err;
3169                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3170                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3171                 }
3172                 case LDKAPIError_ChannelUnavailable: {
3173                         LDKStr err_str = obj->channel_unavailable.err;
3174                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3175                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3176                 }
3177                 case LDKAPIError_MonitorUpdateFailed: {
3178                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3179                 }
3180                 default: abort();
3181         }
3182 }
3183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3184         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3185 }
3186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3187         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3188         CHECK(val->result_ok);
3189         return *val->contents.result;
3190 }
3191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3192         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3193         CHECK(!val->result_ok);
3194         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3195         return err_ref;
3196 }
3197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3198         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3199         ret->datalen = (*env)->GetArrayLength(env, elems);
3200         if (ret->datalen == 0) {
3201                 ret->data = NULL;
3202         } else {
3203                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3204                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3205                 for (size_t i = 0; i < ret->datalen; i++) {
3206                         int64_t arr_elem = java_elems[i];
3207                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3208                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3209                         ret->data[i] = arr_elem_conv;
3210                 }
3211                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3212         }
3213         return (uint64_t)ret;
3214 }
3215 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3216         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3217         for (size_t i = 0; i < ret.datalen; i++) {
3218                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3219         }
3220         return ret;
3221 }
3222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3223         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3224         ret->datalen = (*env)->GetArrayLength(env, elems);
3225         if (ret->datalen == 0) {
3226                 ret->data = NULL;
3227         } else {
3228                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3229                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3230                 for (size_t i = 0; i < ret->datalen; i++) {
3231                         int64_t arr_elem = java_elems[i];
3232                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3233                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3234                         ret->data[i] = arr_elem_conv;
3235                 }
3236                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3237         }
3238         return (uint64_t)ret;
3239 }
3240 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3241         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3242         for (size_t i = 0; i < ret.datalen; i++) {
3243                 ret.data[i] = APIError_clone(&orig->data[i]);
3244         }
3245         return ret;
3246 }
3247 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3248 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3249 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3250 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3251 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3252 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3253 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3254 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3256         LDKPaymentSendFailure_ParameterError_class =
3257                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3258         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3259         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3260         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3261         LDKPaymentSendFailure_PathParameterError_class =
3262                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3263         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3264         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3265         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3266         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3267                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3268         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3269         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3270         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3271         LDKPaymentSendFailure_PartialFailure_class =
3272                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3273         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3274         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3275         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3276 }
3277 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3278         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3279         switch(obj->tag) {
3280                 case LDKPaymentSendFailure_ParameterError: {
3281                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3282                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3283                 }
3284                 case LDKPaymentSendFailure_PathParameterError: {
3285                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3286                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3287                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3288                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3289                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3290                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3291                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3292                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3293                         }
3294                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3295                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3296                 }
3297                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3298                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3299                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3300                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3301                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3302                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3303                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3304                         }
3305                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3306                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3307                 }
3308                 case LDKPaymentSendFailure_PartialFailure: {
3309                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3310                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3311                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3312                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3313                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3314                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3315                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3316                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3317                         }
3318                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3319                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3320                 }
3321                 default: abort();
3322         }
3323 }
3324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3325         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3326 }
3327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3328         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3329         CHECK(val->result_ok);
3330         return *val->contents.result;
3331 }
3332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3333         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3334         CHECK(!val->result_ok);
3335         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3336         return err_ref;
3337 }
3338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3339         return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok;
3340 }
3341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3342         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3343         CHECK(val->result_ok);
3344         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3345         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3346         return res_arr;
3347 }
3348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3349         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3350         CHECK(!val->result_ok);
3351         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3352         return err_ref;
3353 }
3354 static jclass LDKNetAddress_IPv4_class = NULL;
3355 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3356 static jclass LDKNetAddress_IPv6_class = NULL;
3357 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3358 static jclass LDKNetAddress_OnionV2_class = NULL;
3359 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3360 static jclass LDKNetAddress_OnionV3_class = NULL;
3361 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3363         LDKNetAddress_IPv4_class =
3364                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3365         CHECK(LDKNetAddress_IPv4_class != NULL);
3366         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3367         CHECK(LDKNetAddress_IPv4_meth != NULL);
3368         LDKNetAddress_IPv6_class =
3369                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3370         CHECK(LDKNetAddress_IPv6_class != NULL);
3371         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3372         CHECK(LDKNetAddress_IPv6_meth != NULL);
3373         LDKNetAddress_OnionV2_class =
3374                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3375         CHECK(LDKNetAddress_OnionV2_class != NULL);
3376         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3377         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3378         LDKNetAddress_OnionV3_class =
3379                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3380         CHECK(LDKNetAddress_OnionV3_class != NULL);
3381         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3382         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3383 }
3384 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3385         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3386         switch(obj->tag) {
3387                 case LDKNetAddress_IPv4: {
3388                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3389                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3390                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3391                 }
3392                 case LDKNetAddress_IPv6: {
3393                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3394                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3395                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3396                 }
3397                 case LDKNetAddress_OnionV2: {
3398                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3399                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3400                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3401                 }
3402                 case LDKNetAddress_OnionV3: {
3403                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3404                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3405                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, obj->onion_v3.checksum, obj->onion_v3.version, obj->onion_v3.port);
3406                 }
3407                 default: abort();
3408         }
3409 }
3410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3411         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3412         ret->datalen = (*env)->GetArrayLength(env, elems);
3413         if (ret->datalen == 0) {
3414                 ret->data = NULL;
3415         } else {
3416                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3417                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3418                 for (size_t i = 0; i < ret->datalen; i++) {
3419                         int64_t arr_elem = java_elems[i];
3420                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3421                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3422                         ret->data[i] = arr_elem_conv;
3423                 }
3424                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3425         }
3426         return (uint64_t)ret;
3427 }
3428 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3429         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3430         for (size_t i = 0; i < ret.datalen; i++) {
3431                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3432         }
3433         return ret;
3434 }
3435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3436         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3437         LDKThirtyTwoBytes a_ref;
3438         CHECK((*env)->GetArrayLength(env, a) == 32);
3439         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3440         ret->a = a_ref;
3441         LDKThirtyTwoBytes b_ref;
3442         CHECK((*env)->GetArrayLength(env, b) == 32);
3443         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3444         ret->b = b_ref;
3445         return (uint64_t)ret;
3446 }
3447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3448         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3449         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3450         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3451         return a_arr;
3452 }
3453 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3454         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3455         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3456         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3457         return b_arr;
3458 }
3459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3460         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3461 }
3462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3463         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3464         CHECK(val->result_ok);
3465         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3466         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3467         return res_arr;
3468 }
3469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3470         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3471         CHECK(!val->result_ok);
3472         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3473         return err_ref;
3474 }
3475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3476         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3477         ret->datalen = (*env)->GetArrayLength(env, elems);
3478         if (ret->datalen == 0) {
3479                 ret->data = NULL;
3480         } else {
3481                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3482                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3483                 for (size_t i = 0; i < ret->datalen; i++) {
3484                         int64_t arr_elem = java_elems[i];
3485                         LDKChannelMonitor arr_elem_conv;
3486                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3487                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3488                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3489                         ret->data[i] = arr_elem_conv;
3490                 }
3491                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3492         }
3493         return (uint64_t)ret;
3494 }
3495 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3496         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3497         for (size_t i = 0; i < ret.datalen; i++) {
3498                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3499         }
3500         return ret;
3501 }
3502 typedef struct LDKWatch_JCalls {
3503         atomic_size_t refcnt;
3504         JavaVM *vm;
3505         jweak o;
3506         jmethodID watch_channel_meth;
3507         jmethodID update_channel_meth;
3508         jmethodID release_pending_monitor_events_meth;
3509 } LDKWatch_JCalls;
3510 static void LDKWatch_JCalls_free(void* this_arg) {
3511         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3512         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3513                 JNIEnv *env;
3514                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3515                 if (get_jenv_res == JNI_EDETACHED) {
3516                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3517                 } else {
3518                         DO_ASSERT(get_jenv_res == JNI_OK);
3519                 }
3520                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3521                 if (get_jenv_res == JNI_EDETACHED) {
3522                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3523                 }
3524                 FREE(j_calls);
3525         }
3526 }
3527 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3528         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3529         JNIEnv *env;
3530         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3531         if (get_jenv_res == JNI_EDETACHED) {
3532                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3533         } else {
3534                 DO_ASSERT(get_jenv_res == JNI_OK);
3535         }
3536         LDKOutPoint funding_txo_var = funding_txo;
3537         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3538         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3539         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3540         if (funding_txo_var.is_owned) {
3541                 funding_txo_ref |= 1;
3542         }
3543         LDKChannelMonitor monitor_var = monitor;
3544         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3545         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3546         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3547         if (monitor_var.is_owned) {
3548                 monitor_ref |= 1;
3549         }
3550         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3551         CHECK(obj != NULL);
3552         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3553         if ((*env)->ExceptionCheck(env)) {
3554                 (*env)->ExceptionDescribe(env);
3555                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3556         }
3557         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3558         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3559         if (get_jenv_res == JNI_EDETACHED) {
3560                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3561         }
3562         return ret_conv;
3563 }
3564 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3565         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3566         JNIEnv *env;
3567         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3568         if (get_jenv_res == JNI_EDETACHED) {
3569                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3570         } else {
3571                 DO_ASSERT(get_jenv_res == JNI_OK);
3572         }
3573         LDKOutPoint funding_txo_var = funding_txo;
3574         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3575         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3576         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3577         if (funding_txo_var.is_owned) {
3578                 funding_txo_ref |= 1;
3579         }
3580         LDKChannelMonitorUpdate update_var = update;
3581         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3582         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3583         uint64_t update_ref = (uint64_t)update_var.inner;
3584         if (update_var.is_owned) {
3585                 update_ref |= 1;
3586         }
3587         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3588         CHECK(obj != NULL);
3589         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3590         if ((*env)->ExceptionCheck(env)) {
3591                 (*env)->ExceptionDescribe(env);
3592                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3593         }
3594         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3595         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3596         if (get_jenv_res == JNI_EDETACHED) {
3597                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3598         }
3599         return ret_conv;
3600 }
3601 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3602         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3603         JNIEnv *env;
3604         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3605         if (get_jenv_res == JNI_EDETACHED) {
3606                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3607         } else {
3608                 DO_ASSERT(get_jenv_res == JNI_OK);
3609         }
3610         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3611         CHECK(obj != NULL);
3612         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3613         if ((*env)->ExceptionCheck(env)) {
3614                 (*env)->ExceptionDescribe(env);
3615                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3616         }
3617         LDKCVec_MonitorEventZ ret_constr;
3618         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3619         if (ret_constr.datalen > 0)
3620                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3621         else
3622                 ret_constr.data = NULL;
3623         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3624         for (size_t o = 0; o < ret_constr.datalen; o++) {
3625                 int64_t ret_conv_14 = ret_vals[o];
3626                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3627                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3628                 ret_constr.data[o] = ret_conv_14_conv;
3629         }
3630         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3631         if (get_jenv_res == JNI_EDETACHED) {
3632                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3633         }
3634         return ret_constr;
3635 }
3636 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3637         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3638         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3639 }
3640 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3641         jclass c = (*env)->GetObjectClass(env, o);
3642         CHECK(c != NULL);
3643         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3644         atomic_init(&calls->refcnt, 1);
3645         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3646         calls->o = (*env)->NewWeakGlobalRef(env, o);
3647         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3648         CHECK(calls->watch_channel_meth != NULL);
3649         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3650         CHECK(calls->update_channel_meth != NULL);
3651         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3652         CHECK(calls->release_pending_monitor_events_meth != NULL);
3653
3654         LDKWatch ret = {
3655                 .this_arg = (void*) calls,
3656                 .watch_channel = watch_channel_LDKWatch_jcall,
3657                 .update_channel = update_channel_LDKWatch_jcall,
3658                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3659                 .free = LDKWatch_JCalls_free,
3660         };
3661         return ret;
3662 }
3663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3664         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3665         *res_ptr = LDKWatch_init(env, clz, o);
3666         return (uint64_t)res_ptr;
3667 }
3668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t monitor) {
3669         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3670         LDKOutPoint funding_txo_conv;
3671         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3672         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3673         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3674         LDKChannelMonitor monitor_conv;
3675         monitor_conv.inner = (void*)(monitor & (~1));
3676         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3677         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3678         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3679         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3680         return (uint64_t)ret_conv;
3681 }
3682
3683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t update) {
3684         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3685         LDKOutPoint funding_txo_conv;
3686         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3687         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3688         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3689         LDKChannelMonitorUpdate update_conv;
3690         update_conv.inner = (void*)(update & (~1));
3691         update_conv.is_owned = (update & 1) || (update == 0);
3692         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3693         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3694         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3695         return (uint64_t)ret_conv;
3696 }
3697
3698 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3699         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3700         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3701         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3702         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3703         for (size_t o = 0; o < ret_var.datalen; o++) {
3704                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3705                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3706                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3707                 ret_arr_ptr[o] = ret_conv_14_ref;
3708         }
3709         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3710         FREE(ret_var.data);
3711         return ret_arr;
3712 }
3713
3714 typedef struct LDKBroadcasterInterface_JCalls {
3715         atomic_size_t refcnt;
3716         JavaVM *vm;
3717         jweak o;
3718         jmethodID broadcast_transaction_meth;
3719 } LDKBroadcasterInterface_JCalls;
3720 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3721         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3722         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3723                 JNIEnv *env;
3724                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3725                 if (get_jenv_res == JNI_EDETACHED) {
3726                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3727                 } else {
3728                         DO_ASSERT(get_jenv_res == JNI_OK);
3729                 }
3730                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3731                 if (get_jenv_res == JNI_EDETACHED) {
3732                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3733                 }
3734                 FREE(j_calls);
3735         }
3736 }
3737 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3738         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3739         JNIEnv *env;
3740         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3741         if (get_jenv_res == JNI_EDETACHED) {
3742                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3743         } else {
3744                 DO_ASSERT(get_jenv_res == JNI_OK);
3745         }
3746         LDKTransaction tx_var = tx;
3747         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3748         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3749         Transaction_free(tx_var);
3750         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3751         CHECK(obj != NULL);
3752         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3753         if ((*env)->ExceptionCheck(env)) {
3754                 (*env)->ExceptionDescribe(env);
3755                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3756         }
3757         if (get_jenv_res == JNI_EDETACHED) {
3758                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3759         }
3760 }
3761 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3762         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3763         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3764 }
3765 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3766         jclass c = (*env)->GetObjectClass(env, o);
3767         CHECK(c != NULL);
3768         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3769         atomic_init(&calls->refcnt, 1);
3770         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3771         calls->o = (*env)->NewWeakGlobalRef(env, o);
3772         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3773         CHECK(calls->broadcast_transaction_meth != NULL);
3774
3775         LDKBroadcasterInterface ret = {
3776                 .this_arg = (void*) calls,
3777                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3778                 .free = LDKBroadcasterInterface_JCalls_free,
3779         };
3780         return ret;
3781 }
3782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3783         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3784         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3785         return (uint64_t)res_ptr;
3786 }
3787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3788         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3789         LDKTransaction tx_ref;
3790         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3791         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3792         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3793         tx_ref.data_is_owned = true;
3794         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3795 }
3796
3797 typedef struct LDKKeysInterface_JCalls {
3798         atomic_size_t refcnt;
3799         JavaVM *vm;
3800         jweak o;
3801         jmethodID get_node_secret_meth;
3802         jmethodID get_destination_script_meth;
3803         jmethodID get_shutdown_pubkey_meth;
3804         jmethodID get_channel_signer_meth;
3805         jmethodID get_secure_random_bytes_meth;
3806         jmethodID read_chan_signer_meth;
3807         jmethodID sign_invoice_meth;
3808 } LDKKeysInterface_JCalls;
3809 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3810         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3811         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3812                 JNIEnv *env;
3813                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3814                 if (get_jenv_res == JNI_EDETACHED) {
3815                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3816                 } else {
3817                         DO_ASSERT(get_jenv_res == JNI_OK);
3818                 }
3819                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3820                 if (get_jenv_res == JNI_EDETACHED) {
3821                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3822                 }
3823                 FREE(j_calls);
3824         }
3825 }
3826 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3827         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3828         JNIEnv *env;
3829         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3830         if (get_jenv_res == JNI_EDETACHED) {
3831                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3832         } else {
3833                 DO_ASSERT(get_jenv_res == JNI_OK);
3834         }
3835         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3836         CHECK(obj != NULL);
3837         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3838         if ((*env)->ExceptionCheck(env)) {
3839                 (*env)->ExceptionDescribe(env);
3840                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3841         }
3842         LDKSecretKey ret_ref;
3843         CHECK((*env)->GetArrayLength(env, ret) == 32);
3844         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3845         if (get_jenv_res == JNI_EDETACHED) {
3846                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3847         }
3848         return ret_ref;
3849 }
3850 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3851         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3852         JNIEnv *env;
3853         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3854         if (get_jenv_res == JNI_EDETACHED) {
3855                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3856         } else {
3857                 DO_ASSERT(get_jenv_res == JNI_OK);
3858         }
3859         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3860         CHECK(obj != NULL);
3861         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3862         if ((*env)->ExceptionCheck(env)) {
3863                 (*env)->ExceptionDescribe(env);
3864                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
3865         }
3866         LDKCVec_u8Z ret_ref;
3867         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3868         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3869         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3870         if (get_jenv_res == JNI_EDETACHED) {
3871                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3872         }
3873         return ret_ref;
3874 }
3875 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3876         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3877         JNIEnv *env;
3878         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3879         if (get_jenv_res == JNI_EDETACHED) {
3880                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3881         } else {
3882                 DO_ASSERT(get_jenv_res == JNI_OK);
3883         }
3884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3885         CHECK(obj != NULL);
3886         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3887         if ((*env)->ExceptionCheck(env)) {
3888                 (*env)->ExceptionDescribe(env);
3889                 (*env)->FatalError(env, "A call to get_shutdown_pubkey in LDKKeysInterface from rust threw an exception.");
3890         }
3891         LDKPublicKey ret_ref;
3892         CHECK((*env)->GetArrayLength(env, ret) == 33);
3893         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3894         if (get_jenv_res == JNI_EDETACHED) {
3895                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3896         }
3897         return ret_ref;
3898 }
3899 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3900         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3901         JNIEnv *env;
3902         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3903         if (get_jenv_res == JNI_EDETACHED) {
3904                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3905         } else {
3906                 DO_ASSERT(get_jenv_res == JNI_OK);
3907         }
3908         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3909         CHECK(obj != NULL);
3910         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3911         if ((*env)->ExceptionCheck(env)) {
3912                 (*env)->ExceptionDescribe(env);
3913                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
3914         }
3915         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3916         ret_conv = Sign_clone(ret);
3917         if (get_jenv_res == JNI_EDETACHED) {
3918                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3919         }
3920         return ret_conv;
3921 }
3922 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3923         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3924         JNIEnv *env;
3925         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3926         if (get_jenv_res == JNI_EDETACHED) {
3927                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3928         } else {
3929                 DO_ASSERT(get_jenv_res == JNI_OK);
3930         }
3931         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3932         CHECK(obj != NULL);
3933         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3934         if ((*env)->ExceptionCheck(env)) {
3935                 (*env)->ExceptionDescribe(env);
3936                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
3937         }
3938         LDKThirtyTwoBytes ret_ref;
3939         CHECK((*env)->GetArrayLength(env, ret) == 32);
3940         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3941         if (get_jenv_res == JNI_EDETACHED) {
3942                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3943         }
3944         return ret_ref;
3945 }
3946 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3947         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3948         JNIEnv *env;
3949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3950         if (get_jenv_res == JNI_EDETACHED) {
3951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3952         } else {
3953                 DO_ASSERT(get_jenv_res == JNI_OK);
3954         }
3955         LDKu8slice reader_var = reader;
3956         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3957         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3958         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3959         CHECK(obj != NULL);
3960         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3961         if ((*env)->ExceptionCheck(env)) {
3962                 (*env)->ExceptionDescribe(env);
3963                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
3964         }
3965         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3966         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3967         if (get_jenv_res == JNI_EDETACHED) {
3968                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3969         }
3970         return ret_conv;
3971 }
3972 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3973         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3974         JNIEnv *env;
3975         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3976         if (get_jenv_res == JNI_EDETACHED) {
3977                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3978         } else {
3979                 DO_ASSERT(get_jenv_res == JNI_OK);
3980         }
3981         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3982         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3983         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3984         CVec_u8Z_free(invoice_preimage_var);
3985         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3986         CHECK(obj != NULL);
3987         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3988         if ((*env)->ExceptionCheck(env)) {
3989                 (*env)->ExceptionDescribe(env);
3990                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
3991         }
3992         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3993         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3994         if (get_jenv_res == JNI_EDETACHED) {
3995                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3996         }
3997         return ret_conv;
3998 }
3999 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4000         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4001         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4002 }
4003 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4004         jclass c = (*env)->GetObjectClass(env, o);
4005         CHECK(c != NULL);
4006         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4007         atomic_init(&calls->refcnt, 1);
4008         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4009         calls->o = (*env)->NewWeakGlobalRef(env, o);
4010         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4011         CHECK(calls->get_node_secret_meth != NULL);
4012         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4013         CHECK(calls->get_destination_script_meth != NULL);
4014         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
4015         CHECK(calls->get_shutdown_pubkey_meth != NULL);
4016         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4017         CHECK(calls->get_channel_signer_meth != NULL);
4018         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4019         CHECK(calls->get_secure_random_bytes_meth != NULL);
4020         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4021         CHECK(calls->read_chan_signer_meth != NULL);
4022         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4023         CHECK(calls->sign_invoice_meth != NULL);
4024
4025         LDKKeysInterface ret = {
4026                 .this_arg = (void*) calls,
4027                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4028                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4029                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
4030                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4031                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4032                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4033                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4034                 .free = LDKKeysInterface_JCalls_free,
4035         };
4036         return ret;
4037 }
4038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4039         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4040         *res_ptr = LDKKeysInterface_init(env, clz, o);
4041         return (uint64_t)res_ptr;
4042 }
4043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4044         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4045         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4046         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4047         return ret_arr;
4048 }
4049
4050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4051         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4052         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4055         CVec_u8Z_free(ret_var);
4056         return ret_arr;
4057 }
4058
4059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4060         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4061         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4062         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
4063         return ret_arr;
4064 }
4065
4066 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) {
4067         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4068         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
4069         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4070         return (uint64_t)ret;
4071 }
4072
4073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4074         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4075         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4076         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4077         return ret_arr;
4078 }
4079
4080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4081         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4082         LDKu8slice reader_ref;
4083         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4084         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4085         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4086         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4087         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4088         return (uint64_t)ret_conv;
4089 }
4090
4091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4092         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4093         LDKCVec_u8Z invoice_preimage_ref;
4094         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4095         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4096         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4097         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4098         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4099         return (uint64_t)ret_conv;
4100 }
4101
4102 typedef struct LDKFeeEstimator_JCalls {
4103         atomic_size_t refcnt;
4104         JavaVM *vm;
4105         jweak o;
4106         jmethodID get_est_sat_per_1000_weight_meth;
4107 } LDKFeeEstimator_JCalls;
4108 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4109         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4110         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4111                 JNIEnv *env;
4112                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4113                 if (get_jenv_res == JNI_EDETACHED) {
4114                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4115                 } else {
4116                         DO_ASSERT(get_jenv_res == JNI_OK);
4117                 }
4118                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4119                 if (get_jenv_res == JNI_EDETACHED) {
4120                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4121                 }
4122                 FREE(j_calls);
4123         }
4124 }
4125 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4126         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4127         JNIEnv *env;
4128         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4129         if (get_jenv_res == JNI_EDETACHED) {
4130                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4131         } else {
4132                 DO_ASSERT(get_jenv_res == JNI_OK);
4133         }
4134         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4135         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4136         CHECK(obj != NULL);
4137         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4138         if ((*env)->ExceptionCheck(env)) {
4139                 (*env)->ExceptionDescribe(env);
4140                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4141         }
4142         if (get_jenv_res == JNI_EDETACHED) {
4143                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4144         }
4145         return ret;
4146 }
4147 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4148         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4149         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4150 }
4151 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4152         jclass c = (*env)->GetObjectClass(env, o);
4153         CHECK(c != NULL);
4154         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4155         atomic_init(&calls->refcnt, 1);
4156         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4157         calls->o = (*env)->NewWeakGlobalRef(env, o);
4158         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4159         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4160
4161         LDKFeeEstimator ret = {
4162                 .this_arg = (void*) calls,
4163                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4164                 .free = LDKFeeEstimator_JCalls_free,
4165         };
4166         return ret;
4167 }
4168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4169         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4170         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4171         return (uint64_t)res_ptr;
4172 }
4173 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) {
4174         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4175         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4176         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4177         return ret_val;
4178 }
4179
4180 typedef struct LDKLogger_JCalls {
4181         atomic_size_t refcnt;
4182         JavaVM *vm;
4183         jweak o;
4184         jmethodID log_meth;
4185 } LDKLogger_JCalls;
4186 static void LDKLogger_JCalls_free(void* this_arg) {
4187         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4188         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4189                 JNIEnv *env;
4190                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4191                 if (get_jenv_res == JNI_EDETACHED) {
4192                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4193                 } else {
4194                         DO_ASSERT(get_jenv_res == JNI_OK);
4195                 }
4196                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4197                 if (get_jenv_res == JNI_EDETACHED) {
4198                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4199                 }
4200                 FREE(j_calls);
4201         }
4202 }
4203 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4204         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4205         JNIEnv *env;
4206         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4207         if (get_jenv_res == JNI_EDETACHED) {
4208                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4209         } else {
4210                 DO_ASSERT(get_jenv_res == JNI_OK);
4211         }
4212         const char* record_str = record;
4213         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4214         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4215         CHECK(obj != NULL);
4216         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4217         if ((*env)->ExceptionCheck(env)) {
4218                 (*env)->ExceptionDescribe(env);
4219                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4220         }
4221         if (get_jenv_res == JNI_EDETACHED) {
4222                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4223         }
4224 }
4225 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4226         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4227         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4228 }
4229 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4230         jclass c = (*env)->GetObjectClass(env, o);
4231         CHECK(c != NULL);
4232         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4233         atomic_init(&calls->refcnt, 1);
4234         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4235         calls->o = (*env)->NewWeakGlobalRef(env, o);
4236         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4237         CHECK(calls->log_meth != NULL);
4238
4239         LDKLogger ret = {
4240                 .this_arg = (void*) calls,
4241                 .log = log_LDKLogger_jcall,
4242                 .free = LDKLogger_JCalls_free,
4243         };
4244         return ret;
4245 }
4246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4247         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4248         *res_ptr = LDKLogger_init(env, clz, o);
4249         return (uint64_t)res_ptr;
4250 }
4251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4252         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4253         LDKThirtyTwoBytes a_ref;
4254         CHECK((*env)->GetArrayLength(env, a) == 32);
4255         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4256         ret->a = a_ref;
4257         LDKChannelManager b_conv;
4258         b_conv.inner = (void*)(b & (~1));
4259         b_conv.is_owned = (b & 1) || (b == 0);
4260         // Warning: we need a move here but no clone is available for LDKChannelManager
4261         ret->b = b_conv;
4262         return (uint64_t)ret;
4263 }
4264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4265         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4266         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4267         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4268         return a_arr;
4269 }
4270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4271         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4272         LDKChannelManager b_var = tuple->b;
4273         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4274         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4275         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4276         return b_ref;
4277 }
4278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4279         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4280 }
4281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4282         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4283         CHECK(val->result_ok);
4284         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4285         return res_ref;
4286 }
4287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4288         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4289         CHECK(!val->result_ok);
4290         LDKDecodeError err_var = (*val->contents.err);
4291         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4292         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4293         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4294         return err_ref;
4295 }
4296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4297         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4298 }
4299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4300         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4301         CHECK(val->result_ok);
4302         LDKChannelConfig res_var = (*val->contents.result);
4303         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4304         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4305         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4306         return res_ref;
4307 }
4308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4309         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4310         CHECK(!val->result_ok);
4311         LDKDecodeError err_var = (*val->contents.err);
4312         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4313         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4314         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4315         return err_ref;
4316 }
4317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4318         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4319 }
4320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4321         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4322         CHECK(val->result_ok);
4323         LDKOutPoint res_var = (*val->contents.result);
4324         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4325         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4326         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4327         return res_ref;
4328 }
4329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4330         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4331         CHECK(!val->result_ok);
4332         LDKDecodeError err_var = (*val->contents.err);
4333         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4334         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4335         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4336         return err_ref;
4337 }
4338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4339         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4340 }
4341 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4342         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4343         CHECK(val->result_ok);
4344         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4345         return res_conv;
4346 }
4347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4348         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4349         CHECK(!val->result_ok);
4350         return *val->contents.err;
4351 }
4352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4353         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4354 }
4355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4356         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4357         CHECK(val->result_ok);
4358         LDKInvoice res_var = (*val->contents.result);
4359         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4360         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4361         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4362         return res_ref;
4363 }
4364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4365         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4366         CHECK(!val->result_ok);
4367         return *val->contents.err;
4368 }
4369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4370         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4371 }
4372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4373         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4374         CHECK(val->result_ok);
4375         LDKSignedRawInvoice res_var = (*val->contents.result);
4376         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4377         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4378         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4379         return res_ref;
4380 }
4381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4382         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4383         CHECK(!val->result_ok);
4384         return *val->contents.err;
4385 }
4386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b, int64_t c) {
4387         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4388         LDKRawInvoice a_conv;
4389         a_conv.inner = (void*)(a & (~1));
4390         a_conv.is_owned = (a & 1) || (a == 0);
4391         a_conv = RawInvoice_clone(&a_conv);
4392         ret->a = a_conv;
4393         LDKThirtyTwoBytes b_ref;
4394         CHECK((*env)->GetArrayLength(env, b) == 32);
4395         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4396         ret->b = b_ref;
4397         LDKInvoiceSignature c_conv;
4398         c_conv.inner = (void*)(c & (~1));
4399         c_conv.is_owned = (c & 1) || (c == 0);
4400         c_conv = InvoiceSignature_clone(&c_conv);
4401         ret->c = c_conv;
4402         return (uint64_t)ret;
4403 }
4404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4405         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4406         LDKRawInvoice a_var = tuple->a;
4407         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4408         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4409         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4410         return a_ref;
4411 }
4412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4413         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4414         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4415         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4416         return b_arr;
4417 }
4418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4419         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4420         LDKInvoiceSignature c_var = tuple->c;
4421         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4422         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4423         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4424         return c_ref;
4425 }
4426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4427         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4428 }
4429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4430         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4431         CHECK(val->result_ok);
4432         LDKPayeePubKey res_var = (*val->contents.result);
4433         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4434         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4435         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4436         return res_ref;
4437 }
4438 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4439         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4440         CHECK(!val->result_ok);
4441         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4442         return err_conv;
4443 }
4444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4445         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4446         ret->datalen = (*env)->GetArrayLength(env, elems);
4447         if (ret->datalen == 0) {
4448                 ret->data = NULL;
4449         } else {
4450                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4451                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4452                 for (size_t i = 0; i < ret->datalen; i++) {
4453                         int64_t arr_elem = java_elems[i];
4454                         LDKPrivateRoute arr_elem_conv;
4455                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4456                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4457                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4458                         ret->data[i] = arr_elem_conv;
4459                 }
4460                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4461         }
4462         return (uint64_t)ret;
4463 }
4464 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4465         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4466         for (size_t i = 0; i < ret.datalen; i++) {
4467                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4468         }
4469         return ret;
4470 }
4471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4472         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4473 }
4474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4475         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4476         CHECK(val->result_ok);
4477         LDKPositiveTimestamp res_var = (*val->contents.result);
4478         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4479         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4480         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4481         return res_ref;
4482 }
4483 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4484         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4485         CHECK(!val->result_ok);
4486         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4487         return err_conv;
4488 }
4489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4490         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4491 }
4492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4493         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4494         CHECK(val->result_ok);
4495         return *val->contents.result;
4496 }
4497 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4498         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4499         CHECK(!val->result_ok);
4500         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4501         return err_conv;
4502 }
4503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4504         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4505 }
4506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4507         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4508         CHECK(val->result_ok);
4509         LDKInvoice res_var = (*val->contents.result);
4510         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4511         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4512         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4513         return res_ref;
4514 }
4515 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4516         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4517         CHECK(!val->result_ok);
4518         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4519         return err_conv;
4520 }
4521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4522         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4523 }
4524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4525         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4526         CHECK(val->result_ok);
4527         LDKDescription res_var = (*val->contents.result);
4528         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4529         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4530         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4531         return res_ref;
4532 }
4533 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4534         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4535         CHECK(!val->result_ok);
4536         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4537         return err_conv;
4538 }
4539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4540         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4541 }
4542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4543         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4544         CHECK(val->result_ok);
4545         LDKExpiryTime res_var = (*val->contents.result);
4546         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4547         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4548         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4549         return res_ref;
4550 }
4551 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4552         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4553         CHECK(!val->result_ok);
4554         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4555         return err_conv;
4556 }
4557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4558         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4559 }
4560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4561         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4562         CHECK(val->result_ok);
4563         LDKPrivateRoute res_var = (*val->contents.result);
4564         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4565         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4566         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4567         return res_ref;
4568 }
4569 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4570         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4571         CHECK(!val->result_ok);
4572         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4573         return err_conv;
4574 }
4575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4576         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4577 }
4578 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4579         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4580         CHECK(val->result_ok);
4581         LDKStr res_str = (*val->contents.result);
4582         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4583         return res_conv;
4584 }
4585 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4586         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4587         CHECK(!val->result_ok);
4588         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4589         return err_conv;
4590 }
4591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4592         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4593 }
4594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4595         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4596         CHECK(val->result_ok);
4597         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4598         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4599         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4600         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4601         return res_ref;
4602 }
4603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4604         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4605         CHECK(!val->result_ok);
4606         LDKDecodeError err_var = (*val->contents.err);
4607         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4608         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4609         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4610         return err_ref;
4611 }
4612 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4613         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4614 }
4615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4616         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4617         CHECK(val->result_ok);
4618         LDKHTLCUpdate res_var = (*val->contents.result);
4619         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4620         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4621         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4622         return res_ref;
4623 }
4624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4625         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4626         CHECK(!val->result_ok);
4627         LDKDecodeError err_var = (*val->contents.err);
4628         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4629         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4630         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4631         return err_ref;
4632 }
4633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4634         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4635 }
4636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4637         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4638         CHECK(val->result_ok);
4639         return *val->contents.result;
4640 }
4641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4642         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4643         CHECK(!val->result_ok);
4644         LDKMonitorUpdateError err_var = (*val->contents.err);
4645         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4646         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4647         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4648         return err_ref;
4649 }
4650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4651         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4652         LDKOutPoint a_conv;
4653         a_conv.inner = (void*)(a & (~1));
4654         a_conv.is_owned = (a & 1) || (a == 0);
4655         a_conv = OutPoint_clone(&a_conv);
4656         ret->a = a_conv;
4657         LDKCVec_u8Z b_ref;
4658         b_ref.datalen = (*env)->GetArrayLength(env, b);
4659         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4660         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4661         ret->b = b_ref;
4662         return (uint64_t)ret;
4663 }
4664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4665         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4666         LDKOutPoint a_var = tuple->a;
4667         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4668         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4669         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4670         return a_ref;
4671 }
4672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4673         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4674         LDKCVec_u8Z b_var = tuple->b;
4675         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4676         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4677         return b_arr;
4678 }
4679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4680         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4681         ret->a = a;
4682         LDKCVec_u8Z b_ref;
4683         b_ref.datalen = (*env)->GetArrayLength(env, b);
4684         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4685         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4686         ret->b = b_ref;
4687         return (uint64_t)ret;
4688 }
4689 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4690         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4691         return tuple->a;
4692 }
4693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4694         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4695         LDKCVec_u8Z b_var = tuple->b;
4696         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4697         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4698         return b_arr;
4699 }
4700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4701         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4702         ret->datalen = (*env)->GetArrayLength(env, elems);
4703         if (ret->datalen == 0) {
4704                 ret->data = NULL;
4705         } else {
4706                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4707                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4708                 for (size_t i = 0; i < ret->datalen; i++) {
4709                         int64_t arr_elem = java_elems[i];
4710                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4711                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4712                         ret->data[i] = arr_elem_conv;
4713                 }
4714                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4715         }
4716         return (uint64_t)ret;
4717 }
4718 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4719         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4720         for (size_t i = 0; i < ret.datalen; i++) {
4721                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4722         }
4723         return ret;
4724 }
4725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4726         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4727         LDKThirtyTwoBytes a_ref;
4728         CHECK((*env)->GetArrayLength(env, a) == 32);
4729         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4730         ret->a = a_ref;
4731         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4732         b_constr.datalen = (*env)->GetArrayLength(env, b);
4733         if (b_constr.datalen > 0)
4734                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4735         else
4736                 b_constr.data = NULL;
4737         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4738         for (size_t b = 0; b < b_constr.datalen; b++) {
4739                 int64_t b_conv_27 = b_vals[b];
4740                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4741                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4742                 b_constr.data[b] = b_conv_27_conv;
4743         }
4744         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4745         ret->b = b_constr;
4746         return (uint64_t)ret;
4747 }
4748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4749         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4750         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4751         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4752         return a_arr;
4753 }
4754 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4755         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4756         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4757         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4758         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4759         for (size_t b = 0; b < b_var.datalen; b++) {
4760                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4761                 b_arr_ptr[b] = b_conv_27_ref;
4762         }
4763         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4764         return b_arr;
4765 }
4766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4767         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4768         ret->datalen = (*env)->GetArrayLength(env, elems);
4769         if (ret->datalen == 0) {
4770                 ret->data = NULL;
4771         } else {
4772                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4773                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4774                 for (size_t i = 0; i < ret->datalen; i++) {
4775                         int64_t arr_elem = java_elems[i];
4776                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4777                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4778                         ret->data[i] = arr_elem_conv;
4779                 }
4780                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4781         }
4782         return (uint64_t)ret;
4783 }
4784 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4785         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 };
4786         for (size_t i = 0; i < ret.datalen; i++) {
4787                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4788         }
4789         return ret;
4790 }
4791 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
4792 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
4793 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
4794 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
4795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
4796         LDKPaymentPurpose_InvoicePayment_class =
4797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
4798         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
4799         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
4800         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
4801         LDKPaymentPurpose_SpontaneousPayment_class =
4802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
4803         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
4804         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
4805         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
4806 }
4807 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4808         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
4809         switch(obj->tag) {
4810                 case LDKPaymentPurpose_InvoicePayment: {
4811                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4812                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
4813                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4814                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
4815                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
4816                 }
4817                 case LDKPaymentPurpose_SpontaneousPayment: {
4818                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
4819                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
4820                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
4821                 }
4822                 default: abort();
4823         }
4824 }
4825 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4826 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4827 static jclass LDKEvent_PaymentReceived_class = NULL;
4828 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4829 static jclass LDKEvent_PaymentSent_class = NULL;
4830 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4831 static jclass LDKEvent_PaymentFailed_class = NULL;
4832 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4833 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4834 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4835 static jclass LDKEvent_SpendableOutputs_class = NULL;
4836 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4838         LDKEvent_FundingGenerationReady_class =
4839                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4840         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4841         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4842         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4843         LDKEvent_PaymentReceived_class =
4844                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4845         CHECK(LDKEvent_PaymentReceived_class != NULL);
4846         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
4847         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4848         LDKEvent_PaymentSent_class =
4849                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4850         CHECK(LDKEvent_PaymentSent_class != NULL);
4851         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4852         CHECK(LDKEvent_PaymentSent_meth != NULL);
4853         LDKEvent_PaymentFailed_class =
4854                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4855         CHECK(LDKEvent_PaymentFailed_class != NULL);
4856         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4857         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4858         LDKEvent_PendingHTLCsForwardable_class =
4859                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4860         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4861         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4862         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4863         LDKEvent_SpendableOutputs_class =
4864                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4865         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4866         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4867         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4868 }
4869 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4870         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4871         switch(obj->tag) {
4872                 case LDKEvent_FundingGenerationReady: {
4873                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4874                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4875                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4876                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4877                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4878                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_arr, obj->funding_generation_ready.user_channel_id);
4879                 }
4880                 case LDKEvent_PaymentReceived: {
4881                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4882                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4883                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
4884                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
4885                 }
4886                 case LDKEvent_PaymentSent: {
4887                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4888                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4889                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4890                 }
4891                 case LDKEvent_PaymentFailed: {
4892                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4893                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4894                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4895                 }
4896                 case LDKEvent_PendingHTLCsForwardable: {
4897                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4898                 }
4899                 case LDKEvent_SpendableOutputs: {
4900                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4901                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4902                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4903                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4904                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4905                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4906                         }
4907                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4908                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4909                 }
4910                 default: abort();
4911         }
4912 }
4913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4914         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4915         ret->datalen = (*env)->GetArrayLength(env, elems);
4916         if (ret->datalen == 0) {
4917                 ret->data = NULL;
4918         } else {
4919                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4920                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4921                 for (size_t i = 0; i < ret->datalen; i++) {
4922                         int64_t arr_elem = java_elems[i];
4923                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4924                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4925                         ret->data[i] = arr_elem_conv;
4926                 }
4927                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4928         }
4929         return (uint64_t)ret;
4930 }
4931 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4932         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4933         for (size_t i = 0; i < ret.datalen; i++) {
4934                 ret.data[i] = Event_clone(&orig->data[i]);
4935         }
4936         return ret;
4937 }
4938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4939         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4940         ret->a = a;
4941         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4942         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4943         ret->b = b_conv;
4944         return (uint64_t)ret;
4945 }
4946 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4947         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4948         return tuple->a;
4949 }
4950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4951         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4952         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4953         return (uint64_t)b_ref;
4954 }
4955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4956         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4957         ret->datalen = (*env)->GetArrayLength(env, elems);
4958         if (ret->datalen == 0) {
4959                 ret->data = NULL;
4960         } else {
4961                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4962                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4963                 for (size_t i = 0; i < ret->datalen; i++) {
4964                         int64_t arr_elem = java_elems[i];
4965                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4966                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4967                         ret->data[i] = arr_elem_conv;
4968                 }
4969                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4970         }
4971         return (uint64_t)ret;
4972 }
4973 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4974         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4975         for (size_t i = 0; i < ret.datalen; i++) {
4976                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4977         }
4978         return ret;
4979 }
4980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4981         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4982         LDKThirtyTwoBytes a_ref;
4983         CHECK((*env)->GetArrayLength(env, a) == 32);
4984         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4985         ret->a = a_ref;
4986         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4987         b_constr.datalen = (*env)->GetArrayLength(env, b);
4988         if (b_constr.datalen > 0)
4989                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4990         else
4991                 b_constr.data = NULL;
4992         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4993         for (size_t a = 0; a < b_constr.datalen; a++) {
4994                 int64_t b_conv_26 = b_vals[a];
4995                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4996                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4997                 b_constr.data[a] = b_conv_26_conv;
4998         }
4999         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
5000         ret->b = b_constr;
5001         return (uint64_t)ret;
5002 }
5003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
5004         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
5005         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
5006         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
5007         return a_arr;
5008 }
5009 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
5010         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
5011         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
5012         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
5013         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
5014         for (size_t a = 0; a < b_var.datalen; a++) {
5015                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
5016                 b_arr_ptr[a] = b_conv_26_ref;
5017         }
5018         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
5019         return b_arr;
5020 }
5021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5022         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
5023         ret->datalen = (*env)->GetArrayLength(env, elems);
5024         if (ret->datalen == 0) {
5025                 ret->data = NULL;
5026         } else {
5027                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
5028                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5029                 for (size_t i = 0; i < ret->datalen; i++) {
5030                         int64_t arr_elem = java_elems[i];
5031                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
5032                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
5033                         ret->data[i] = arr_elem_conv;
5034                 }
5035                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5036         }
5037         return (uint64_t)ret;
5038 }
5039 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5040         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 };
5041         for (size_t i = 0; i < ret.datalen; i++) {
5042                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5043         }
5044         return ret;
5045 }
5046 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5047         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
5048 }
5049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5050         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5051         CHECK(val->result_ok);
5052         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
5053         return res_ref;
5054 }
5055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5056         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5057         CHECK(!val->result_ok);
5058         LDKDecodeError err_var = (*val->contents.err);
5059         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5060         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5061         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5062         return err_ref;
5063 }
5064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5065         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
5066 }
5067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5068         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5069         CHECK(val->result_ok);
5070         return *val->contents.result;
5071 }
5072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5073         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5074         CHECK(!val->result_ok);
5075         LDKLightningError err_var = (*val->contents.err);
5076         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5077         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5078         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5079         return err_ref;
5080 }
5081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
5082         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5083         LDKChannelAnnouncement a_conv;
5084         a_conv.inner = (void*)(a & (~1));
5085         a_conv.is_owned = (a & 1) || (a == 0);
5086         a_conv = ChannelAnnouncement_clone(&a_conv);
5087         ret->a = a_conv;
5088         LDKChannelUpdate b_conv;
5089         b_conv.inner = (void*)(b & (~1));
5090         b_conv.is_owned = (b & 1) || (b == 0);
5091         b_conv = ChannelUpdate_clone(&b_conv);
5092         ret->b = b_conv;
5093         LDKChannelUpdate c_conv;
5094         c_conv.inner = (void*)(c & (~1));
5095         c_conv.is_owned = (c & 1) || (c == 0);
5096         c_conv = ChannelUpdate_clone(&c_conv);
5097         ret->c = c_conv;
5098         return (uint64_t)ret;
5099 }
5100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
5101         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5102         LDKChannelAnnouncement a_var = tuple->a;
5103         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5104         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5105         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
5106         return a_ref;
5107 }
5108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
5109         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5110         LDKChannelUpdate b_var = tuple->b;
5111         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5112         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5113         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
5114         return b_ref;
5115 }
5116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
5117         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5118         LDKChannelUpdate c_var = tuple->c;
5119         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5120         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5121         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
5122         return c_ref;
5123 }
5124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5125         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
5126         ret->datalen = (*env)->GetArrayLength(env, elems);
5127         if (ret->datalen == 0) {
5128                 ret->data = NULL;
5129         } else {
5130                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
5131                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5132                 for (size_t i = 0; i < ret->datalen; i++) {
5133                         int64_t arr_elem = java_elems[i];
5134                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
5135                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
5136                         ret->data[i] = arr_elem_conv;
5137                 }
5138                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5139         }
5140         return (uint64_t)ret;
5141 }
5142 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5143         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5144         for (size_t i = 0; i < ret.datalen; i++) {
5145                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5146         }
5147         return ret;
5148 }
5149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5150         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
5151         ret->datalen = (*env)->GetArrayLength(env, elems);
5152         if (ret->datalen == 0) {
5153                 ret->data = NULL;
5154         } else {
5155                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
5156                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5157                 for (size_t i = 0; i < ret->datalen; i++) {
5158                         int64_t arr_elem = java_elems[i];
5159                         LDKNodeAnnouncement arr_elem_conv;
5160                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5161                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5162                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5163                         ret->data[i] = arr_elem_conv;
5164                 }
5165                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5166         }
5167         return (uint64_t)ret;
5168 }
5169 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5170         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5171         for (size_t i = 0; i < ret.datalen; i++) {
5172                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5173         }
5174         return ret;
5175 }
5176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5177         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5178 }
5179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5180         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5181         CHECK(val->result_ok);
5182         return *val->contents.result;
5183 }
5184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5185         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5186         CHECK(!val->result_ok);
5187         LDKLightningError err_var = (*val->contents.err);
5188         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5189         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5190         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5191         return err_ref;
5192 }
5193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5194         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5195 }
5196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5197         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5198         CHECK(val->result_ok);
5199         LDKCVec_u8Z res_var = (*val->contents.result);
5200         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5201         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5202         return res_arr;
5203 }
5204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5205         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5206         CHECK(!val->result_ok);
5207         LDKPeerHandleError err_var = (*val->contents.err);
5208         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5209         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5210         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5211         return err_ref;
5212 }
5213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5214         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5215 }
5216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5217         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5218         CHECK(val->result_ok);
5219         return *val->contents.result;
5220 }
5221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5222         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5223         CHECK(!val->result_ok);
5224         LDKPeerHandleError err_var = (*val->contents.err);
5225         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5226         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5227         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5228         return err_ref;
5229 }
5230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5231         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5232 }
5233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5234         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5235         CHECK(val->result_ok);
5236         return *val->contents.result;
5237 }
5238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5239         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5240         CHECK(!val->result_ok);
5241         LDKPeerHandleError err_var = (*val->contents.err);
5242         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5243         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5244         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5245         return err_ref;
5246 }
5247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5248         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
5249 }
5250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5251         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5252         CHECK(val->result_ok);
5253         LDKDirectionalChannelInfo res_var = (*val->contents.result);
5254         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5255         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5256         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5257         return res_ref;
5258 }
5259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5260         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5261         CHECK(!val->result_ok);
5262         LDKDecodeError err_var = (*val->contents.err);
5263         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5264         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5265         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5266         return err_ref;
5267 }
5268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5269         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
5270 }
5271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5272         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5273         CHECK(val->result_ok);
5274         LDKChannelInfo res_var = (*val->contents.result);
5275         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5276         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5277         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5278         return res_ref;
5279 }
5280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5281         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5282         CHECK(!val->result_ok);
5283         LDKDecodeError err_var = (*val->contents.err);
5284         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5285         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5286         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5287         return err_ref;
5288 }
5289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5290         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
5291 }
5292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5293         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5294         CHECK(val->result_ok);
5295         LDKRoutingFees res_var = (*val->contents.result);
5296         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5297         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5298         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5299         return res_ref;
5300 }
5301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5302         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5303         CHECK(!val->result_ok);
5304         LDKDecodeError err_var = (*val->contents.err);
5305         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5306         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5307         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5308         return err_ref;
5309 }
5310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5311         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
5312 }
5313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5314         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5315         CHECK(val->result_ok);
5316         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5317         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5318         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5319         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5320         return res_ref;
5321 }
5322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5323         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5324         CHECK(!val->result_ok);
5325         LDKDecodeError err_var = (*val->contents.err);
5326         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5327         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5328         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5329         return err_ref;
5330 }
5331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5332         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5333         ret->datalen = (*env)->GetArrayLength(env, elems);
5334         if (ret->datalen == 0) {
5335                 ret->data = NULL;
5336         } else {
5337                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5338                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5339                 for (size_t i = 0; i < ret->datalen; i++) {
5340                         ret->data[i] = java_elems[i];
5341                 }
5342                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5343         }
5344         return (uint64_t)ret;
5345 }
5346 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5347         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5348         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5349         return ret;
5350 }
5351 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5352         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5353 }
5354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5355         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5356         CHECK(val->result_ok);
5357         LDKNodeInfo res_var = (*val->contents.result);
5358         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5359         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5360         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5361         return res_ref;
5362 }
5363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5364         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5365         CHECK(!val->result_ok);
5366         LDKDecodeError err_var = (*val->contents.err);
5367         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5368         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5369         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5370         return err_ref;
5371 }
5372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5373         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5374 }
5375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5376         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5377         CHECK(val->result_ok);
5378         LDKNetworkGraph res_var = (*val->contents.result);
5379         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5380         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5381         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5382         return res_ref;
5383 }
5384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5385         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5386         CHECK(!val->result_ok);
5387         LDKDecodeError err_var = (*val->contents.err);
5388         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5389         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5390         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5391         return err_ref;
5392 }
5393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5394         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5395 }
5396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5397         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5398         CHECK(val->result_ok);
5399         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5400         return res_ref;
5401 }
5402 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5403         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5404         CHECK(!val->result_ok);
5405         return *val->contents.err;
5406 }
5407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5408         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5409 }
5410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5411         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5412         CHECK(val->result_ok);
5413         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5414         *res_conv = (*val->contents.result);
5415         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5416         return (uint64_t)res_conv;
5417 }
5418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5419         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5420         CHECK(!val->result_ok);
5421         LDKDecodeError err_var = (*val->contents.err);
5422         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5423         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5424         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5425         return err_ref;
5426 }
5427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5428         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5429 }
5430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5431         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5432         CHECK(val->result_ok);
5433         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5434         return res_ref;
5435 }
5436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5437         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5438         CHECK(!val->result_ok);
5439         LDKDecodeError err_var = (*val->contents.err);
5440         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5441         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5442         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5443         return err_ref;
5444 }
5445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5446         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5447         ret->datalen = (*env)->GetArrayLength(env, elems);
5448         if (ret->datalen == 0) {
5449                 ret->data = NULL;
5450         } else {
5451                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5452                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5453                 for (size_t i = 0; i < ret->datalen; i++) {
5454                         int64_t arr_elem = java_elems[i];
5455                         LDKUpdateAddHTLC arr_elem_conv;
5456                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5457                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5458                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5459                         ret->data[i] = arr_elem_conv;
5460                 }
5461                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5462         }
5463         return (uint64_t)ret;
5464 }
5465 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5466         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5467         for (size_t i = 0; i < ret.datalen; i++) {
5468                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5469         }
5470         return ret;
5471 }
5472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5473         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5474         ret->datalen = (*env)->GetArrayLength(env, elems);
5475         if (ret->datalen == 0) {
5476                 ret->data = NULL;
5477         } else {
5478                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5479                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5480                 for (size_t i = 0; i < ret->datalen; i++) {
5481                         int64_t arr_elem = java_elems[i];
5482                         LDKUpdateFulfillHTLC arr_elem_conv;
5483                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5484                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5485                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5486                         ret->data[i] = arr_elem_conv;
5487                 }
5488                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5489         }
5490         return (uint64_t)ret;
5491 }
5492 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5493         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5494         for (size_t i = 0; i < ret.datalen; i++) {
5495                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5496         }
5497         return ret;
5498 }
5499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5500         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5501         ret->datalen = (*env)->GetArrayLength(env, elems);
5502         if (ret->datalen == 0) {
5503                 ret->data = NULL;
5504         } else {
5505                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5506                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5507                 for (size_t i = 0; i < ret->datalen; i++) {
5508                         int64_t arr_elem = java_elems[i];
5509                         LDKUpdateFailHTLC arr_elem_conv;
5510                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5511                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5512                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5513                         ret->data[i] = arr_elem_conv;
5514                 }
5515                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5516         }
5517         return (uint64_t)ret;
5518 }
5519 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5520         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5521         for (size_t i = 0; i < ret.datalen; i++) {
5522                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5523         }
5524         return ret;
5525 }
5526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5527         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5528         ret->datalen = (*env)->GetArrayLength(env, elems);
5529         if (ret->datalen == 0) {
5530                 ret->data = NULL;
5531         } else {
5532                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5533                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5534                 for (size_t i = 0; i < ret->datalen; i++) {
5535                         int64_t arr_elem = java_elems[i];
5536                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5537                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5538                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5539                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5540                         ret->data[i] = arr_elem_conv;
5541                 }
5542                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5543         }
5544         return (uint64_t)ret;
5545 }
5546 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5547         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5548         for (size_t i = 0; i < ret.datalen; i++) {
5549                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5550         }
5551         return ret;
5552 }
5553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5554         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5555 }
5556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5557         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5558         CHECK(val->result_ok);
5559         LDKAcceptChannel res_var = (*val->contents.result);
5560         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5561         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5562         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5563         return res_ref;
5564 }
5565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5566         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5567         CHECK(!val->result_ok);
5568         LDKDecodeError err_var = (*val->contents.err);
5569         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5570         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5571         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5572         return err_ref;
5573 }
5574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5575         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5576 }
5577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5578         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5579         CHECK(val->result_ok);
5580         LDKAnnouncementSignatures res_var = (*val->contents.result);
5581         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5582         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5583         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5584         return res_ref;
5585 }
5586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5587         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5588         CHECK(!val->result_ok);
5589         LDKDecodeError err_var = (*val->contents.err);
5590         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5591         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5592         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5593         return err_ref;
5594 }
5595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5596         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5597 }
5598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5599         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5600         CHECK(val->result_ok);
5601         LDKChannelReestablish res_var = (*val->contents.result);
5602         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5603         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5604         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5605         return res_ref;
5606 }
5607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5608         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5609         CHECK(!val->result_ok);
5610         LDKDecodeError err_var = (*val->contents.err);
5611         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5612         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5613         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5614         return err_ref;
5615 }
5616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5617         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5618 }
5619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5620         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5621         CHECK(val->result_ok);
5622         LDKClosingSigned res_var = (*val->contents.result);
5623         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5624         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5625         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5626         return res_ref;
5627 }
5628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5629         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5630         CHECK(!val->result_ok);
5631         LDKDecodeError err_var = (*val->contents.err);
5632         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5633         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5634         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5635         return err_ref;
5636 }
5637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5638         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5639 }
5640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5641         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5642         CHECK(val->result_ok);
5643         LDKCommitmentSigned res_var = (*val->contents.result);
5644         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5645         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5646         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5647         return res_ref;
5648 }
5649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5650         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5651         CHECK(!val->result_ok);
5652         LDKDecodeError err_var = (*val->contents.err);
5653         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5654         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5655         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5656         return err_ref;
5657 }
5658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5659         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5660 }
5661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5662         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5663         CHECK(val->result_ok);
5664         LDKFundingCreated res_var = (*val->contents.result);
5665         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5666         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5667         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5668         return res_ref;
5669 }
5670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5671         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5672         CHECK(!val->result_ok);
5673         LDKDecodeError err_var = (*val->contents.err);
5674         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5675         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5676         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5677         return err_ref;
5678 }
5679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5680         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5681 }
5682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5683         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5684         CHECK(val->result_ok);
5685         LDKFundingSigned res_var = (*val->contents.result);
5686         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5687         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5688         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5689         return res_ref;
5690 }
5691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5692         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5693         CHECK(!val->result_ok);
5694         LDKDecodeError err_var = (*val->contents.err);
5695         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5696         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5697         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5698         return err_ref;
5699 }
5700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5701         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5702 }
5703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5704         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5705         CHECK(val->result_ok);
5706         LDKFundingLocked res_var = (*val->contents.result);
5707         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5708         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5709         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5710         return res_ref;
5711 }
5712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5713         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5714         CHECK(!val->result_ok);
5715         LDKDecodeError err_var = (*val->contents.err);
5716         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5717         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5718         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5719         return err_ref;
5720 }
5721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5722         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5723 }
5724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5725         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5726         CHECK(val->result_ok);
5727         LDKInit res_var = (*val->contents.result);
5728         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5729         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5730         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5731         return res_ref;
5732 }
5733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5734         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5735         CHECK(!val->result_ok);
5736         LDKDecodeError err_var = (*val->contents.err);
5737         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5738         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5739         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5740         return err_ref;
5741 }
5742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5743         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5744 }
5745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5746         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5747         CHECK(val->result_ok);
5748         LDKOpenChannel res_var = (*val->contents.result);
5749         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5750         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5751         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5752         return res_ref;
5753 }
5754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5755         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5756         CHECK(!val->result_ok);
5757         LDKDecodeError err_var = (*val->contents.err);
5758         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5759         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5760         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5761         return err_ref;
5762 }
5763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5764         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5765 }
5766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5767         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5768         CHECK(val->result_ok);
5769         LDKRevokeAndACK res_var = (*val->contents.result);
5770         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5771         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5772         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5773         return res_ref;
5774 }
5775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5776         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5777         CHECK(!val->result_ok);
5778         LDKDecodeError err_var = (*val->contents.err);
5779         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5780         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5781         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5782         return err_ref;
5783 }
5784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5785         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5786 }
5787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5788         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5789         CHECK(val->result_ok);
5790         LDKShutdown res_var = (*val->contents.result);
5791         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5792         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5793         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5794         return res_ref;
5795 }
5796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5797         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5798         CHECK(!val->result_ok);
5799         LDKDecodeError err_var = (*val->contents.err);
5800         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5801         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5802         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5803         return err_ref;
5804 }
5805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5806         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5807 }
5808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5809         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5810         CHECK(val->result_ok);
5811         LDKUpdateFailHTLC res_var = (*val->contents.result);
5812         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5813         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5814         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5815         return res_ref;
5816 }
5817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5818         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5819         CHECK(!val->result_ok);
5820         LDKDecodeError err_var = (*val->contents.err);
5821         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5822         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5823         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5824         return err_ref;
5825 }
5826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5827         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5828 }
5829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5830         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5831         CHECK(val->result_ok);
5832         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5833         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5834         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5835         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5836         return res_ref;
5837 }
5838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5839         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5840         CHECK(!val->result_ok);
5841         LDKDecodeError err_var = (*val->contents.err);
5842         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5843         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5844         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5845         return err_ref;
5846 }
5847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5848         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5849 }
5850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5851         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5852         CHECK(val->result_ok);
5853         LDKUpdateFee res_var = (*val->contents.result);
5854         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5855         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5856         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5857         return res_ref;
5858 }
5859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5860         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5861         CHECK(!val->result_ok);
5862         LDKDecodeError err_var = (*val->contents.err);
5863         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5864         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5865         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5866         return err_ref;
5867 }
5868 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5869         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5870 }
5871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5872         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5873         CHECK(val->result_ok);
5874         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5875         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5876         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5877         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5878         return res_ref;
5879 }
5880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5881         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5882         CHECK(!val->result_ok);
5883         LDKDecodeError err_var = (*val->contents.err);
5884         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5885         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5886         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5887         return err_ref;
5888 }
5889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5890         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5891 }
5892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5893         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5894         CHECK(val->result_ok);
5895         LDKUpdateAddHTLC res_var = (*val->contents.result);
5896         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5897         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5898         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5899         return res_ref;
5900 }
5901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5902         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5903         CHECK(!val->result_ok);
5904         LDKDecodeError err_var = (*val->contents.err);
5905         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5906         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5907         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5908         return err_ref;
5909 }
5910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5911         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5912 }
5913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5914         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5915         CHECK(val->result_ok);
5916         LDKPing res_var = (*val->contents.result);
5917         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5918         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5919         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5920         return res_ref;
5921 }
5922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5923         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5924         CHECK(!val->result_ok);
5925         LDKDecodeError err_var = (*val->contents.err);
5926         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5927         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5928         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5929         return err_ref;
5930 }
5931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5932         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5933 }
5934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5935         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5936         CHECK(val->result_ok);
5937         LDKPong res_var = (*val->contents.result);
5938         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5939         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5940         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5941         return res_ref;
5942 }
5943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5944         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5945         CHECK(!val->result_ok);
5946         LDKDecodeError err_var = (*val->contents.err);
5947         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5948         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5949         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5950         return err_ref;
5951 }
5952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5953         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5954 }
5955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5956         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5957         CHECK(val->result_ok);
5958         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5959         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5960         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5961         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5962         return res_ref;
5963 }
5964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5965         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5966         CHECK(!val->result_ok);
5967         LDKDecodeError err_var = (*val->contents.err);
5968         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5969         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5970         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5971         return err_ref;
5972 }
5973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5974         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5975 }
5976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5977         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5978         CHECK(val->result_ok);
5979         LDKChannelAnnouncement res_var = (*val->contents.result);
5980         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5981         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5982         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5983         return res_ref;
5984 }
5985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5986         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5987         CHECK(!val->result_ok);
5988         LDKDecodeError err_var = (*val->contents.err);
5989         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5990         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5991         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5992         return err_ref;
5993 }
5994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5995         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5996 }
5997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5998         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5999         CHECK(val->result_ok);
6000         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
6001         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6002         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6003         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6004         return res_ref;
6005 }
6006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6007         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6008         CHECK(!val->result_ok);
6009         LDKDecodeError err_var = (*val->contents.err);
6010         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6011         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6012         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6013         return err_ref;
6014 }
6015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6016         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
6017 }
6018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6019         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6020         CHECK(val->result_ok);
6021         LDKChannelUpdate res_var = (*val->contents.result);
6022         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6023         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6024         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6025         return res_ref;
6026 }
6027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6028         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6029         CHECK(!val->result_ok);
6030         LDKDecodeError err_var = (*val->contents.err);
6031         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6032         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6033         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6034         return err_ref;
6035 }
6036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6037         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
6038 }
6039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6040         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6041         CHECK(val->result_ok);
6042         LDKErrorMessage res_var = (*val->contents.result);
6043         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6044         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6045         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6046         return res_ref;
6047 }
6048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6049         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6050         CHECK(!val->result_ok);
6051         LDKDecodeError err_var = (*val->contents.err);
6052         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6053         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6054         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6055         return err_ref;
6056 }
6057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6058         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6059 }
6060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6061         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6062         CHECK(val->result_ok);
6063         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
6064         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6065         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6066         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6067         return res_ref;
6068 }
6069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6070         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6071         CHECK(!val->result_ok);
6072         LDKDecodeError err_var = (*val->contents.err);
6073         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6074         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6075         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6076         return err_ref;
6077 }
6078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6079         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6080 }
6081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6082         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6083         CHECK(val->result_ok);
6084         LDKNodeAnnouncement res_var = (*val->contents.result);
6085         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6086         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6087         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6088         return res_ref;
6089 }
6090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6091         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6092         CHECK(!val->result_ok);
6093         LDKDecodeError err_var = (*val->contents.err);
6094         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6095         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6096         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6097         return err_ref;
6098 }
6099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6100         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
6101 }
6102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6103         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6104         CHECK(val->result_ok);
6105         LDKQueryShortChannelIds res_var = (*val->contents.result);
6106         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6107         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6108         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6109         return res_ref;
6110 }
6111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6112         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6113         CHECK(!val->result_ok);
6114         LDKDecodeError err_var = (*val->contents.err);
6115         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6116         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6117         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6118         return err_ref;
6119 }
6120 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6121         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
6122 }
6123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6124         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6125         CHECK(val->result_ok);
6126         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
6127         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6128         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6129         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6130         return res_ref;
6131 }
6132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6133         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6134         CHECK(!val->result_ok);
6135         LDKDecodeError err_var = (*val->contents.err);
6136         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6137         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6138         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6139         return err_ref;
6140 }
6141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6142         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
6143 }
6144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6145         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6146         CHECK(val->result_ok);
6147         LDKQueryChannelRange res_var = (*val->contents.result);
6148         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6149         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6150         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6151         return res_ref;
6152 }
6153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6154         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6155         CHECK(!val->result_ok);
6156         LDKDecodeError err_var = (*val->contents.err);
6157         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6158         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6159         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6160         return err_ref;
6161 }
6162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6163         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
6164 }
6165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6166         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6167         CHECK(val->result_ok);
6168         LDKReplyChannelRange res_var = (*val->contents.result);
6169         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6170         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6171         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6172         return res_ref;
6173 }
6174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6175         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6176         CHECK(!val->result_ok);
6177         LDKDecodeError err_var = (*val->contents.err);
6178         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6179         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6180         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6181         return err_ref;
6182 }
6183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6184         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
6185 }
6186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6187         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6188         CHECK(val->result_ok);
6189         LDKGossipTimestampFilter res_var = (*val->contents.result);
6190         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6191         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6192         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6193         return res_ref;
6194 }
6195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6196         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6197         CHECK(!val->result_ok);
6198         LDKDecodeError err_var = (*val->contents.err);
6199         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6200         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6201         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6202         return err_ref;
6203 }
6204 static jclass LDKSignOrCreationError_SignError_class = NULL;
6205 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
6206 static jclass LDKSignOrCreationError_CreationError_class = NULL;
6207 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
6208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
6209         LDKSignOrCreationError_SignError_class =
6210                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
6211         CHECK(LDKSignOrCreationError_SignError_class != NULL);
6212         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
6213         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
6214         LDKSignOrCreationError_CreationError_class =
6215                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
6216         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
6217         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
6218         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
6219 }
6220 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6221         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
6222         switch(obj->tag) {
6223                 case LDKSignOrCreationError_SignError: {
6224                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
6225                 }
6226                 case LDKSignOrCreationError_CreationError: {
6227                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
6228                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
6229                 }
6230                 default: abort();
6231         }
6232 }
6233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6234         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
6235 }
6236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6237         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6238         CHECK(val->result_ok);
6239         LDKInvoice res_var = (*val->contents.result);
6240         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6241         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6242         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6243         return res_ref;
6244 }
6245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6246         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6247         CHECK(!val->result_ok);
6248         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
6249         return err_ref;
6250 }
6251 typedef struct LDKMessageSendEventsProvider_JCalls {
6252         atomic_size_t refcnt;
6253         JavaVM *vm;
6254         jweak o;
6255         jmethodID get_and_clear_pending_msg_events_meth;
6256 } LDKMessageSendEventsProvider_JCalls;
6257 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6258         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6259         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6260                 JNIEnv *env;
6261                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6262                 if (get_jenv_res == JNI_EDETACHED) {
6263                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6264                 } else {
6265                         DO_ASSERT(get_jenv_res == JNI_OK);
6266                 }
6267                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6268                 if (get_jenv_res == JNI_EDETACHED) {
6269                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6270                 }
6271                 FREE(j_calls);
6272         }
6273 }
6274 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6275         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6276         JNIEnv *env;
6277         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6278         if (get_jenv_res == JNI_EDETACHED) {
6279                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6280         } else {
6281                 DO_ASSERT(get_jenv_res == JNI_OK);
6282         }
6283         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6284         CHECK(obj != NULL);
6285         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
6286         if ((*env)->ExceptionCheck(env)) {
6287                 (*env)->ExceptionDescribe(env);
6288                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
6289         }
6290         LDKCVec_MessageSendEventZ ret_constr;
6291         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6292         if (ret_constr.datalen > 0)
6293                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6294         else
6295                 ret_constr.data = NULL;
6296         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6297         for (size_t s = 0; s < ret_constr.datalen; s++) {
6298                 int64_t ret_conv_18 = ret_vals[s];
6299                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
6300                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
6301                 ret_constr.data[s] = ret_conv_18_conv;
6302         }
6303         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6304         if (get_jenv_res == JNI_EDETACHED) {
6305                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6306         }
6307         return ret_constr;
6308 }
6309 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6310         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6311         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6312 }
6313 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6314         jclass c = (*env)->GetObjectClass(env, o);
6315         CHECK(c != NULL);
6316         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6317         atomic_init(&calls->refcnt, 1);
6318         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6319         calls->o = (*env)->NewWeakGlobalRef(env, o);
6320         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6321         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6322
6323         LDKMessageSendEventsProvider ret = {
6324                 .this_arg = (void*) calls,
6325                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6326                 .free = LDKMessageSendEventsProvider_JCalls_free,
6327         };
6328         return ret;
6329 }
6330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6331         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6332         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6333         return (uint64_t)res_ptr;
6334 }
6335 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6336         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6337         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6338         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6339         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6340         for (size_t s = 0; s < ret_var.datalen; s++) {
6341                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6342                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6343                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6344                 ret_arr_ptr[s] = ret_conv_18_ref;
6345         }
6346         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6347         FREE(ret_var.data);
6348         return ret_arr;
6349 }
6350
6351 typedef struct LDKEventHandler_JCalls {
6352         atomic_size_t refcnt;
6353         JavaVM *vm;
6354         jweak o;
6355         jmethodID handle_event_meth;
6356 } LDKEventHandler_JCalls;
6357 static void LDKEventHandler_JCalls_free(void* this_arg) {
6358         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6359         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6360                 JNIEnv *env;
6361                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6362                 if (get_jenv_res == JNI_EDETACHED) {
6363                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6364                 } else {
6365                         DO_ASSERT(get_jenv_res == JNI_OK);
6366                 }
6367                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6368                 if (get_jenv_res == JNI_EDETACHED) {
6369                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6370                 }
6371                 FREE(j_calls);
6372         }
6373 }
6374 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6375         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6376         JNIEnv *env;
6377         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6378         if (get_jenv_res == JNI_EDETACHED) {
6379                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6380         } else {
6381                 DO_ASSERT(get_jenv_res == JNI_OK);
6382         }
6383         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6384         *event_copy = event;
6385         uint64_t event_ref = (uint64_t)event_copy;
6386         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6387         CHECK(obj != NULL);
6388         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6389         if ((*env)->ExceptionCheck(env)) {
6390                 (*env)->ExceptionDescribe(env);
6391                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
6392         }
6393         if (get_jenv_res == JNI_EDETACHED) {
6394                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6395         }
6396 }
6397 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6398         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6399         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6400 }
6401 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6402         jclass c = (*env)->GetObjectClass(env, o);
6403         CHECK(c != NULL);
6404         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6405         atomic_init(&calls->refcnt, 1);
6406         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6407         calls->o = (*env)->NewWeakGlobalRef(env, o);
6408         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6409         CHECK(calls->handle_event_meth != NULL);
6410
6411         LDKEventHandler ret = {
6412                 .this_arg = (void*) calls,
6413                 .handle_event = handle_event_LDKEventHandler_jcall,
6414                 .free = LDKEventHandler_JCalls_free,
6415         };
6416         return ret;
6417 }
6418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6419         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6420         *res_ptr = LDKEventHandler_init(env, clz, o);
6421         return (uint64_t)res_ptr;
6422 }
6423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6424         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6425         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6426         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6427 }
6428
6429 typedef struct LDKEventsProvider_JCalls {
6430         atomic_size_t refcnt;
6431         JavaVM *vm;
6432         jweak o;
6433         jmethodID process_pending_events_meth;
6434 } LDKEventsProvider_JCalls;
6435 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6436         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6437         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6438                 JNIEnv *env;
6439                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6440                 if (get_jenv_res == JNI_EDETACHED) {
6441                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6442                 } else {
6443                         DO_ASSERT(get_jenv_res == JNI_OK);
6444                 }
6445                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6446                 if (get_jenv_res == JNI_EDETACHED) {
6447                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6448                 }
6449                 FREE(j_calls);
6450         }
6451 }
6452 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6453         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6454         JNIEnv *env;
6455         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6456         if (get_jenv_res == JNI_EDETACHED) {
6457                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6458         } else {
6459                 DO_ASSERT(get_jenv_res == JNI_OK);
6460         }
6461         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6462         *ret = handler;
6463         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6464         CHECK(obj != NULL);
6465         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6466         if ((*env)->ExceptionCheck(env)) {
6467                 (*env)->ExceptionDescribe(env);
6468                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
6469         }
6470         if (get_jenv_res == JNI_EDETACHED) {
6471                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6472         }
6473 }
6474 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6475         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6476         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6477 }
6478 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6479         jclass c = (*env)->GetObjectClass(env, o);
6480         CHECK(c != NULL);
6481         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6482         atomic_init(&calls->refcnt, 1);
6483         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6484         calls->o = (*env)->NewWeakGlobalRef(env, o);
6485         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6486         CHECK(calls->process_pending_events_meth != NULL);
6487
6488         LDKEventsProvider ret = {
6489                 .this_arg = (void*) calls,
6490                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6491                 .free = LDKEventsProvider_JCalls_free,
6492         };
6493         return ret;
6494 }
6495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6496         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6497         *res_ptr = LDKEventsProvider_init(env, clz, o);
6498         return (uint64_t)res_ptr;
6499 }
6500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6501         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6502         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6503         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6504                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6505                 LDKEventHandler_JCalls_cloned(&handler_conv);
6506         }
6507         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6508 }
6509
6510 typedef struct LDKAccess_JCalls {
6511         atomic_size_t refcnt;
6512         JavaVM *vm;
6513         jweak o;
6514         jmethodID get_utxo_meth;
6515 } LDKAccess_JCalls;
6516 static void LDKAccess_JCalls_free(void* this_arg) {
6517         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6518         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6519                 JNIEnv *env;
6520                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6521                 if (get_jenv_res == JNI_EDETACHED) {
6522                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6523                 } else {
6524                         DO_ASSERT(get_jenv_res == JNI_OK);
6525                 }
6526                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6527                 if (get_jenv_res == JNI_EDETACHED) {
6528                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6529                 }
6530                 FREE(j_calls);
6531         }
6532 }
6533 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6534         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6535         JNIEnv *env;
6536         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6537         if (get_jenv_res == JNI_EDETACHED) {
6538                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6539         } else {
6540                 DO_ASSERT(get_jenv_res == JNI_OK);
6541         }
6542         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6543         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6544         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6545         CHECK(obj != NULL);
6546         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6547         if ((*env)->ExceptionCheck(env)) {
6548                 (*env)->ExceptionDescribe(env);
6549                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6550         }
6551         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6552         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6553         if (get_jenv_res == JNI_EDETACHED) {
6554                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6555         }
6556         return ret_conv;
6557 }
6558 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6559         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6560         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6561 }
6562 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6563         jclass c = (*env)->GetObjectClass(env, o);
6564         CHECK(c != NULL);
6565         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6566         atomic_init(&calls->refcnt, 1);
6567         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6568         calls->o = (*env)->NewWeakGlobalRef(env, o);
6569         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6570         CHECK(calls->get_utxo_meth != NULL);
6571
6572         LDKAccess ret = {
6573                 .this_arg = (void*) calls,
6574                 .get_utxo = get_utxo_LDKAccess_jcall,
6575                 .free = LDKAccess_JCalls_free,
6576         };
6577         return ret;
6578 }
6579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6580         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6581         *res_ptr = LDKAccess_init(env, clz, o);
6582         return (uint64_t)res_ptr;
6583 }
6584 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) {
6585         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6586         unsigned char genesis_hash_arr[32];
6587         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6588         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6589         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6590         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6591         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6592         return (uint64_t)ret_conv;
6593 }
6594
6595 typedef struct LDKListen_JCalls {
6596         atomic_size_t refcnt;
6597         JavaVM *vm;
6598         jweak o;
6599         jmethodID block_connected_meth;
6600         jmethodID block_disconnected_meth;
6601 } LDKListen_JCalls;
6602 static void LDKListen_JCalls_free(void* this_arg) {
6603         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6604         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6605                 JNIEnv *env;
6606                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6607                 if (get_jenv_res == JNI_EDETACHED) {
6608                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6609                 } else {
6610                         DO_ASSERT(get_jenv_res == JNI_OK);
6611                 }
6612                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6613                 if (get_jenv_res == JNI_EDETACHED) {
6614                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6615                 }
6616                 FREE(j_calls);
6617         }
6618 }
6619 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6620         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6621         JNIEnv *env;
6622         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6623         if (get_jenv_res == JNI_EDETACHED) {
6624                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6625         } else {
6626                 DO_ASSERT(get_jenv_res == JNI_OK);
6627         }
6628         LDKu8slice block_var = block;
6629         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6630         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6631         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6632         CHECK(obj != NULL);
6633         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6634         if ((*env)->ExceptionCheck(env)) {
6635                 (*env)->ExceptionDescribe(env);
6636                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
6637         }
6638         if (get_jenv_res == JNI_EDETACHED) {
6639                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6640         }
6641 }
6642 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6643         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6644         JNIEnv *env;
6645         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6646         if (get_jenv_res == JNI_EDETACHED) {
6647                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6648         } else {
6649                 DO_ASSERT(get_jenv_res == JNI_OK);
6650         }
6651         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6652         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6653         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6654         CHECK(obj != NULL);
6655         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6656         if ((*env)->ExceptionCheck(env)) {
6657                 (*env)->ExceptionDescribe(env);
6658                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
6659         }
6660         if (get_jenv_res == JNI_EDETACHED) {
6661                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6662         }
6663 }
6664 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
6665         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
6666         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6667 }
6668 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6669         jclass c = (*env)->GetObjectClass(env, o);
6670         CHECK(c != NULL);
6671         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6672         atomic_init(&calls->refcnt, 1);
6673         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6674         calls->o = (*env)->NewWeakGlobalRef(env, o);
6675         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6676         CHECK(calls->block_connected_meth != NULL);
6677         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6678         CHECK(calls->block_disconnected_meth != NULL);
6679
6680         LDKListen ret = {
6681                 .this_arg = (void*) calls,
6682                 .block_connected = block_connected_LDKListen_jcall,
6683                 .block_disconnected = block_disconnected_LDKListen_jcall,
6684                 .free = LDKListen_JCalls_free,
6685         };
6686         return ret;
6687 }
6688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6689         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6690         *res_ptr = LDKListen_init(env, clz, o);
6691         return (uint64_t)res_ptr;
6692 }
6693 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) {
6694         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6695         LDKu8slice block_ref;
6696         block_ref.datalen = (*env)->GetArrayLength(env, block);
6697         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6698         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6699         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6700 }
6701
6702 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) {
6703         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6704         unsigned char header_arr[80];
6705         CHECK((*env)->GetArrayLength(env, header) == 80);
6706         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6707         unsigned char (*header_ref)[80] = &header_arr;
6708         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6709 }
6710
6711 typedef struct LDKConfirm_JCalls {
6712         atomic_size_t refcnt;
6713         JavaVM *vm;
6714         jweak o;
6715         jmethodID transactions_confirmed_meth;
6716         jmethodID transaction_unconfirmed_meth;
6717         jmethodID best_block_updated_meth;
6718         jmethodID get_relevant_txids_meth;
6719 } LDKConfirm_JCalls;
6720 static void LDKConfirm_JCalls_free(void* this_arg) {
6721         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6722         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6723                 JNIEnv *env;
6724                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6725                 if (get_jenv_res == JNI_EDETACHED) {
6726                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6727                 } else {
6728                         DO_ASSERT(get_jenv_res == JNI_OK);
6729                 }
6730                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6731                 if (get_jenv_res == JNI_EDETACHED) {
6732                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6733                 }
6734                 FREE(j_calls);
6735         }
6736 }
6737 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6738         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6739         JNIEnv *env;
6740         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6741         if (get_jenv_res == JNI_EDETACHED) {
6742                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6743         } else {
6744                 DO_ASSERT(get_jenv_res == JNI_OK);
6745         }
6746         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6747         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6748         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6749         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6750         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6751         for (size_t y = 0; y < txdata_var.datalen; y++) {
6752                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6753                 *txdata_conv_24_ref = txdata_var.data[y];
6754                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6755         }
6756         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6757         FREE(txdata_var.data);
6758         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6759         CHECK(obj != NULL);
6760         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6761         if ((*env)->ExceptionCheck(env)) {
6762                 (*env)->ExceptionDescribe(env);
6763                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
6764         }
6765         if (get_jenv_res == JNI_EDETACHED) {
6766                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6767         }
6768 }
6769 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6770         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6771         JNIEnv *env;
6772         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6773         if (get_jenv_res == JNI_EDETACHED) {
6774                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6775         } else {
6776                 DO_ASSERT(get_jenv_res == JNI_OK);
6777         }
6778         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6779         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6780         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6781         CHECK(obj != NULL);
6782         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6783         if ((*env)->ExceptionCheck(env)) {
6784                 (*env)->ExceptionDescribe(env);
6785                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
6786         }
6787         if (get_jenv_res == JNI_EDETACHED) {
6788                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6789         }
6790 }
6791 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6792         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6793         JNIEnv *env;
6794         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6795         if (get_jenv_res == JNI_EDETACHED) {
6796                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6797         } else {
6798                 DO_ASSERT(get_jenv_res == JNI_OK);
6799         }
6800         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6801         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6802         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6803         CHECK(obj != NULL);
6804         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6805         if ((*env)->ExceptionCheck(env)) {
6806                 (*env)->ExceptionDescribe(env);
6807                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
6808         }
6809         if (get_jenv_res == JNI_EDETACHED) {
6810                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6811         }
6812 }
6813 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6814         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6815         JNIEnv *env;
6816         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6817         if (get_jenv_res == JNI_EDETACHED) {
6818                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6819         } else {
6820                 DO_ASSERT(get_jenv_res == JNI_OK);
6821         }
6822         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6823         CHECK(obj != NULL);
6824         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6825         if ((*env)->ExceptionCheck(env)) {
6826                 (*env)->ExceptionDescribe(env);
6827                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
6828         }
6829         LDKCVec_TxidZ ret_constr;
6830         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6831         if (ret_constr.datalen > 0)
6832                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6833         else
6834                 ret_constr.data = NULL;
6835         for (size_t i = 0; i < ret_constr.datalen; i++) {
6836                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6837                 LDKThirtyTwoBytes ret_conv_8_ref;
6838                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6839                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6840                 ret_constr.data[i] = ret_conv_8_ref;
6841         }
6842         if (get_jenv_res == JNI_EDETACHED) {
6843                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6844         }
6845         return ret_constr;
6846 }
6847 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
6848         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
6849         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6850 }
6851 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6852         jclass c = (*env)->GetObjectClass(env, o);
6853         CHECK(c != NULL);
6854         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6855         atomic_init(&calls->refcnt, 1);
6856         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6857         calls->o = (*env)->NewWeakGlobalRef(env, o);
6858         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6859         CHECK(calls->transactions_confirmed_meth != NULL);
6860         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6861         CHECK(calls->transaction_unconfirmed_meth != NULL);
6862         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6863         CHECK(calls->best_block_updated_meth != NULL);
6864         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6865         CHECK(calls->get_relevant_txids_meth != NULL);
6866
6867         LDKConfirm ret = {
6868                 .this_arg = (void*) calls,
6869                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6870                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6871                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6872                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6873                 .free = LDKConfirm_JCalls_free,
6874         };
6875         return ret;
6876 }
6877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6878         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6879         *res_ptr = LDKConfirm_init(env, clz, o);
6880         return (uint64_t)res_ptr;
6881 }
6882 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) {
6883         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6884         unsigned char header_arr[80];
6885         CHECK((*env)->GetArrayLength(env, header) == 80);
6886         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6887         unsigned char (*header_ref)[80] = &header_arr;
6888         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6889         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6890         if (txdata_constr.datalen > 0)
6891                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6892         else
6893                 txdata_constr.data = NULL;
6894         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6895         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6896                 int64_t txdata_conv_24 = txdata_vals[y];
6897                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6898                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6899                 txdata_constr.data[y] = txdata_conv_24_conv;
6900         }
6901         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6902         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6903 }
6904
6905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6906         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6907         unsigned char txid_arr[32];
6908         CHECK((*env)->GetArrayLength(env, txid) == 32);
6909         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6910         unsigned char (*txid_ref)[32] = &txid_arr;
6911         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6912 }
6913
6914 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) {
6915         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6916         unsigned char header_arr[80];
6917         CHECK((*env)->GetArrayLength(env, header) == 80);
6918         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6919         unsigned char (*header_ref)[80] = &header_arr;
6920         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6921 }
6922
6923 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6924         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6925         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6926         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6927         ;
6928         for (size_t i = 0; i < ret_var.datalen; i++) {
6929                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6930                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6931                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6932         }
6933         FREE(ret_var.data);
6934         return ret_arr;
6935 }
6936
6937 typedef struct LDKFilter_JCalls {
6938         atomic_size_t refcnt;
6939         JavaVM *vm;
6940         jweak o;
6941         jmethodID register_tx_meth;
6942         jmethodID register_output_meth;
6943 } LDKFilter_JCalls;
6944 static void LDKFilter_JCalls_free(void* this_arg) {
6945         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6946         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6947                 JNIEnv *env;
6948                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6949                 if (get_jenv_res == JNI_EDETACHED) {
6950                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6951                 } else {
6952                         DO_ASSERT(get_jenv_res == JNI_OK);
6953                 }
6954                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6955                 if (get_jenv_res == JNI_EDETACHED) {
6956                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6957                 }
6958                 FREE(j_calls);
6959         }
6960 }
6961 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6962         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6963         JNIEnv *env;
6964         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6965         if (get_jenv_res == JNI_EDETACHED) {
6966                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6967         } else {
6968                 DO_ASSERT(get_jenv_res == JNI_OK);
6969         }
6970         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6971         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6972         LDKu8slice script_pubkey_var = script_pubkey;
6973         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6974         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6975         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6976         CHECK(obj != NULL);
6977         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6978         if ((*env)->ExceptionCheck(env)) {
6979                 (*env)->ExceptionDescribe(env);
6980                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
6981         }
6982         if (get_jenv_res == JNI_EDETACHED) {
6983                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6984         }
6985 }
6986 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6987         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6988         JNIEnv *env;
6989         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6990         if (get_jenv_res == JNI_EDETACHED) {
6991                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6992         } else {
6993                 DO_ASSERT(get_jenv_res == JNI_OK);
6994         }
6995         LDKWatchedOutput output_var = output;
6996         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6997         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6998         uint64_t output_ref = (uint64_t)output_var.inner;
6999         if (output_var.is_owned) {
7000                 output_ref |= 1;
7001         }
7002         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7003         CHECK(obj != NULL);
7004         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7005         if ((*env)->ExceptionCheck(env)) {
7006                 (*env)->ExceptionDescribe(env);
7007                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7008         }
7009         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
7010         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
7011         if (get_jenv_res == JNI_EDETACHED) {
7012                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7013         }
7014         return ret_conv;
7015 }
7016 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7017         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7018         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7019 }
7020 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7021         jclass c = (*env)->GetObjectClass(env, o);
7022         CHECK(c != NULL);
7023         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7024         atomic_init(&calls->refcnt, 1);
7025         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7026         calls->o = (*env)->NewWeakGlobalRef(env, o);
7027         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7028         CHECK(calls->register_tx_meth != NULL);
7029         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7030         CHECK(calls->register_output_meth != NULL);
7031
7032         LDKFilter ret = {
7033                 .this_arg = (void*) calls,
7034                 .register_tx = register_tx_LDKFilter_jcall,
7035                 .register_output = register_output_LDKFilter_jcall,
7036                 .free = LDKFilter_JCalls_free,
7037         };
7038         return ret;
7039 }
7040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7041         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7042         *res_ptr = LDKFilter_init(env, clz, o);
7043         return (uint64_t)res_ptr;
7044 }
7045 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) {
7046         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7047         unsigned char txid_arr[32];
7048         CHECK((*env)->GetArrayLength(env, txid) == 32);
7049         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7050         unsigned char (*txid_ref)[32] = &txid_arr;
7051         LDKu8slice script_pubkey_ref;
7052         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7053         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7054         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7055         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7056 }
7057
7058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7059         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7060         LDKWatchedOutput output_conv;
7061         output_conv.inner = (void*)(output & (~1));
7062         output_conv.is_owned = (output & 1) || (output == 0);
7063         output_conv = WatchedOutput_clone(&output_conv);
7064         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7065         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7066         uint64_t ret_ref = (uint64_t)ret_copy;
7067         return ret_ref;
7068 }
7069
7070 typedef struct LDKPersist_JCalls {
7071         atomic_size_t refcnt;
7072         JavaVM *vm;
7073         jweak o;
7074         jmethodID persist_new_channel_meth;
7075         jmethodID update_persisted_channel_meth;
7076 } LDKPersist_JCalls;
7077 static void LDKPersist_JCalls_free(void* this_arg) {
7078         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7079         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7080                 JNIEnv *env;
7081                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7082                 if (get_jenv_res == JNI_EDETACHED) {
7083                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7084                 } else {
7085                         DO_ASSERT(get_jenv_res == JNI_OK);
7086                 }
7087                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7088                 if (get_jenv_res == JNI_EDETACHED) {
7089                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7090                 }
7091                 FREE(j_calls);
7092         }
7093 }
7094 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
7095         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7096         JNIEnv *env;
7097         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7098         if (get_jenv_res == JNI_EDETACHED) {
7099                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7100         } else {
7101                 DO_ASSERT(get_jenv_res == JNI_OK);
7102         }
7103         LDKOutPoint id_var = id;
7104         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7105         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7106         uint64_t id_ref = (uint64_t)id_var.inner;
7107         if (id_var.is_owned) {
7108                 id_ref |= 1;
7109         }
7110         LDKChannelMonitor data_var = *data;
7111         data_var = ChannelMonitor_clone(data);
7112         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7113         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7114         uint64_t data_ref = (uint64_t)data_var.inner;
7115         if (data_var.is_owned) {
7116                 data_ref |= 1;
7117         }
7118         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7119         CHECK(obj != NULL);
7120         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
7121         if ((*env)->ExceptionCheck(env)) {
7122                 (*env)->ExceptionDescribe(env);
7123                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
7124         }
7125         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7126         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7127         if (get_jenv_res == JNI_EDETACHED) {
7128                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7129         }
7130         return ret_conv;
7131 }
7132 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
7133         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7134         JNIEnv *env;
7135         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7136         if (get_jenv_res == JNI_EDETACHED) {
7137                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7138         } else {
7139                 DO_ASSERT(get_jenv_res == JNI_OK);
7140         }
7141         LDKOutPoint id_var = id;
7142         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7143         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7144         uint64_t id_ref = (uint64_t)id_var.inner;
7145         if (id_var.is_owned) {
7146                 id_ref |= 1;
7147         }
7148         LDKChannelMonitorUpdate update_var = *update;
7149         update_var = ChannelMonitorUpdate_clone(update);
7150         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7151         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7152         uint64_t update_ref = (uint64_t)update_var.inner;
7153         if (update_var.is_owned) {
7154                 update_ref |= 1;
7155         }
7156         LDKChannelMonitor data_var = *data;
7157         data_var = ChannelMonitor_clone(data);
7158         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7159         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7160         uint64_t data_ref = (uint64_t)data_var.inner;
7161         if (data_var.is_owned) {
7162                 data_ref |= 1;
7163         }
7164         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7165         CHECK(obj != NULL);
7166         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7167         if ((*env)->ExceptionCheck(env)) {
7168                 (*env)->ExceptionDescribe(env);
7169                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7170         }
7171         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7172         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7173         if (get_jenv_res == JNI_EDETACHED) {
7174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7175         }
7176         return ret_conv;
7177 }
7178 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7179         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7180         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7181 }
7182 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7183         jclass c = (*env)->GetObjectClass(env, o);
7184         CHECK(c != NULL);
7185         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7186         atomic_init(&calls->refcnt, 1);
7187         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7188         calls->o = (*env)->NewWeakGlobalRef(env, o);
7189         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7190         CHECK(calls->persist_new_channel_meth != NULL);
7191         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7192         CHECK(calls->update_persisted_channel_meth != NULL);
7193
7194         LDKPersist ret = {
7195                 .this_arg = (void*) calls,
7196                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7197                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7198                 .free = LDKPersist_JCalls_free,
7199         };
7200         return ret;
7201 }
7202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7203         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7204         *res_ptr = LDKPersist_init(env, clz, o);
7205         return (uint64_t)res_ptr;
7206 }
7207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t data) {
7208         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7209         LDKOutPoint id_conv;
7210         id_conv.inner = (void*)(id & (~1));
7211         id_conv.is_owned = (id & 1) || (id == 0);
7212         id_conv = OutPoint_clone(&id_conv);
7213         LDKChannelMonitor data_conv;
7214         data_conv.inner = (void*)(data & (~1));
7215         data_conv.is_owned = false;
7216         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7217         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
7218         return (uint64_t)ret_conv;
7219 }
7220
7221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t update, int64_t data) {
7222         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7223         LDKOutPoint id_conv;
7224         id_conv.inner = (void*)(id & (~1));
7225         id_conv.is_owned = (id & 1) || (id == 0);
7226         id_conv = OutPoint_clone(&id_conv);
7227         LDKChannelMonitorUpdate update_conv;
7228         update_conv.inner = (void*)(update & (~1));
7229         update_conv.is_owned = false;
7230         LDKChannelMonitor data_conv;
7231         data_conv.inner = (void*)(data & (~1));
7232         data_conv.is_owned = false;
7233         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7234         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
7235         return (uint64_t)ret_conv;
7236 }
7237
7238 typedef struct LDKChannelMessageHandler_JCalls {
7239         atomic_size_t refcnt;
7240         JavaVM *vm;
7241         jweak o;
7242         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7243         jmethodID handle_open_channel_meth;
7244         jmethodID handle_accept_channel_meth;
7245         jmethodID handle_funding_created_meth;
7246         jmethodID handle_funding_signed_meth;
7247         jmethodID handle_funding_locked_meth;
7248         jmethodID handle_shutdown_meth;
7249         jmethodID handle_closing_signed_meth;
7250         jmethodID handle_update_add_htlc_meth;
7251         jmethodID handle_update_fulfill_htlc_meth;
7252         jmethodID handle_update_fail_htlc_meth;
7253         jmethodID handle_update_fail_malformed_htlc_meth;
7254         jmethodID handle_commitment_signed_meth;
7255         jmethodID handle_revoke_and_ack_meth;
7256         jmethodID handle_update_fee_meth;
7257         jmethodID handle_announcement_signatures_meth;
7258         jmethodID peer_disconnected_meth;
7259         jmethodID peer_connected_meth;
7260         jmethodID handle_channel_reestablish_meth;
7261         jmethodID handle_channel_update_meth;
7262         jmethodID handle_error_meth;
7263 } LDKChannelMessageHandler_JCalls;
7264 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7265         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7266         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7267                 JNIEnv *env;
7268                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7269                 if (get_jenv_res == JNI_EDETACHED) {
7270                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7271                 } else {
7272                         DO_ASSERT(get_jenv_res == JNI_OK);
7273                 }
7274                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7275                 if (get_jenv_res == JNI_EDETACHED) {
7276                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7277                 }
7278                 FREE(j_calls);
7279         }
7280 }
7281 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7282         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7283         JNIEnv *env;
7284         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7285         if (get_jenv_res == JNI_EDETACHED) {
7286                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7287         } else {
7288                 DO_ASSERT(get_jenv_res == JNI_OK);
7289         }
7290         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7291         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7292         LDKInitFeatures their_features_var = their_features;
7293         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7294         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7295         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7296         if (their_features_var.is_owned) {
7297                 their_features_ref |= 1;
7298         }
7299         LDKOpenChannel msg_var = *msg;
7300         msg_var = OpenChannel_clone(msg);
7301         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7302         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7303         uint64_t msg_ref = (uint64_t)msg_var.inner;
7304         if (msg_var.is_owned) {
7305                 msg_ref |= 1;
7306         }
7307         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7308         CHECK(obj != NULL);
7309         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7310         if ((*env)->ExceptionCheck(env)) {
7311                 (*env)->ExceptionDescribe(env);
7312                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
7313         }
7314         if (get_jenv_res == JNI_EDETACHED) {
7315                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7316         }
7317 }
7318 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7319         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7320         JNIEnv *env;
7321         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7322         if (get_jenv_res == JNI_EDETACHED) {
7323                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7324         } else {
7325                 DO_ASSERT(get_jenv_res == JNI_OK);
7326         }
7327         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7328         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7329         LDKInitFeatures their_features_var = their_features;
7330         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7331         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7332         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7333         if (their_features_var.is_owned) {
7334                 their_features_ref |= 1;
7335         }
7336         LDKAcceptChannel msg_var = *msg;
7337         msg_var = AcceptChannel_clone(msg);
7338         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7339         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7340         uint64_t msg_ref = (uint64_t)msg_var.inner;
7341         if (msg_var.is_owned) {
7342                 msg_ref |= 1;
7343         }
7344         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7345         CHECK(obj != NULL);
7346         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7347         if ((*env)->ExceptionCheck(env)) {
7348                 (*env)->ExceptionDescribe(env);
7349                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
7350         }
7351         if (get_jenv_res == JNI_EDETACHED) {
7352                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7353         }
7354 }
7355 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7356         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7357         JNIEnv *env;
7358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7359         if (get_jenv_res == JNI_EDETACHED) {
7360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7361         } else {
7362                 DO_ASSERT(get_jenv_res == JNI_OK);
7363         }
7364         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7365         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7366         LDKFundingCreated msg_var = *msg;
7367         msg_var = FundingCreated_clone(msg);
7368         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7369         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7370         uint64_t msg_ref = (uint64_t)msg_var.inner;
7371         if (msg_var.is_owned) {
7372                 msg_ref |= 1;
7373         }
7374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7375         CHECK(obj != NULL);
7376         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7377         if ((*env)->ExceptionCheck(env)) {
7378                 (*env)->ExceptionDescribe(env);
7379                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
7380         }
7381         if (get_jenv_res == JNI_EDETACHED) {
7382                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7383         }
7384 }
7385 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7386         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7387         JNIEnv *env;
7388         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7389         if (get_jenv_res == JNI_EDETACHED) {
7390                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7391         } else {
7392                 DO_ASSERT(get_jenv_res == JNI_OK);
7393         }
7394         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7395         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7396         LDKFundingSigned msg_var = *msg;
7397         msg_var = FundingSigned_clone(msg);
7398         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7399         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7400         uint64_t msg_ref = (uint64_t)msg_var.inner;
7401         if (msg_var.is_owned) {
7402                 msg_ref |= 1;
7403         }
7404         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7405         CHECK(obj != NULL);
7406         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7407         if ((*env)->ExceptionCheck(env)) {
7408                 (*env)->ExceptionDescribe(env);
7409                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
7410         }
7411         if (get_jenv_res == JNI_EDETACHED) {
7412                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7413         }
7414 }
7415 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7416         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7417         JNIEnv *env;
7418         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7419         if (get_jenv_res == JNI_EDETACHED) {
7420                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7421         } else {
7422                 DO_ASSERT(get_jenv_res == JNI_OK);
7423         }
7424         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7425         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7426         LDKFundingLocked msg_var = *msg;
7427         msg_var = FundingLocked_clone(msg);
7428         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7429         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7430         uint64_t msg_ref = (uint64_t)msg_var.inner;
7431         if (msg_var.is_owned) {
7432                 msg_ref |= 1;
7433         }
7434         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7435         CHECK(obj != NULL);
7436         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7437         if ((*env)->ExceptionCheck(env)) {
7438                 (*env)->ExceptionDescribe(env);
7439                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
7440         }
7441         if (get_jenv_res == JNI_EDETACHED) {
7442                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7443         }
7444 }
7445 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7446         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7447         JNIEnv *env;
7448         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7449         if (get_jenv_res == JNI_EDETACHED) {
7450                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7451         } else {
7452                 DO_ASSERT(get_jenv_res == JNI_OK);
7453         }
7454         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7455         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7456         LDKInitFeatures their_features_var = *their_features;
7457         their_features_var = InitFeatures_clone(their_features);
7458         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7459         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7460         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7461         if (their_features_var.is_owned) {
7462                 their_features_ref |= 1;
7463         }
7464         LDKShutdown msg_var = *msg;
7465         msg_var = Shutdown_clone(msg);
7466         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7467         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7468         uint64_t msg_ref = (uint64_t)msg_var.inner;
7469         if (msg_var.is_owned) {
7470                 msg_ref |= 1;
7471         }
7472         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7473         CHECK(obj != NULL);
7474         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7475         if ((*env)->ExceptionCheck(env)) {
7476                 (*env)->ExceptionDescribe(env);
7477                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
7478         }
7479         if (get_jenv_res == JNI_EDETACHED) {
7480                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7481         }
7482 }
7483 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7484         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7485         JNIEnv *env;
7486         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7487         if (get_jenv_res == JNI_EDETACHED) {
7488                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7489         } else {
7490                 DO_ASSERT(get_jenv_res == JNI_OK);
7491         }
7492         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7493         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7494         LDKClosingSigned msg_var = *msg;
7495         msg_var = ClosingSigned_clone(msg);
7496         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7497         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7498         uint64_t msg_ref = (uint64_t)msg_var.inner;
7499         if (msg_var.is_owned) {
7500                 msg_ref |= 1;
7501         }
7502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7503         CHECK(obj != NULL);
7504         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7505         if ((*env)->ExceptionCheck(env)) {
7506                 (*env)->ExceptionDescribe(env);
7507                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
7508         }
7509         if (get_jenv_res == JNI_EDETACHED) {
7510                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7511         }
7512 }
7513 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7514         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7515         JNIEnv *env;
7516         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7517         if (get_jenv_res == JNI_EDETACHED) {
7518                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7519         } else {
7520                 DO_ASSERT(get_jenv_res == JNI_OK);
7521         }
7522         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7523         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7524         LDKUpdateAddHTLC msg_var = *msg;
7525         msg_var = UpdateAddHTLC_clone(msg);
7526         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7527         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7528         uint64_t msg_ref = (uint64_t)msg_var.inner;
7529         if (msg_var.is_owned) {
7530                 msg_ref |= 1;
7531         }
7532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7533         CHECK(obj != NULL);
7534         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7535         if ((*env)->ExceptionCheck(env)) {
7536                 (*env)->ExceptionDescribe(env);
7537                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
7538         }
7539         if (get_jenv_res == JNI_EDETACHED) {
7540                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7541         }
7542 }
7543 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7544         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7545         JNIEnv *env;
7546         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7547         if (get_jenv_res == JNI_EDETACHED) {
7548                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7549         } else {
7550                 DO_ASSERT(get_jenv_res == JNI_OK);
7551         }
7552         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7553         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7554         LDKUpdateFulfillHTLC msg_var = *msg;
7555         msg_var = UpdateFulfillHTLC_clone(msg);
7556         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7557         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7558         uint64_t msg_ref = (uint64_t)msg_var.inner;
7559         if (msg_var.is_owned) {
7560                 msg_ref |= 1;
7561         }
7562         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7563         CHECK(obj != NULL);
7564         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7565         if ((*env)->ExceptionCheck(env)) {
7566                 (*env)->ExceptionDescribe(env);
7567                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
7568         }
7569         if (get_jenv_res == JNI_EDETACHED) {
7570                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7571         }
7572 }
7573 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7574         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7575         JNIEnv *env;
7576         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7577         if (get_jenv_res == JNI_EDETACHED) {
7578                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7579         } else {
7580                 DO_ASSERT(get_jenv_res == JNI_OK);
7581         }
7582         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7583         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7584         LDKUpdateFailHTLC msg_var = *msg;
7585         msg_var = UpdateFailHTLC_clone(msg);
7586         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7587         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7588         uint64_t msg_ref = (uint64_t)msg_var.inner;
7589         if (msg_var.is_owned) {
7590                 msg_ref |= 1;
7591         }
7592         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7593         CHECK(obj != NULL);
7594         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7595         if ((*env)->ExceptionCheck(env)) {
7596                 (*env)->ExceptionDescribe(env);
7597                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
7598         }
7599         if (get_jenv_res == JNI_EDETACHED) {
7600                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7601         }
7602 }
7603 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7604         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7605         JNIEnv *env;
7606         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7607         if (get_jenv_res == JNI_EDETACHED) {
7608                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7609         } else {
7610                 DO_ASSERT(get_jenv_res == JNI_OK);
7611         }
7612         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7613         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7614         LDKUpdateFailMalformedHTLC msg_var = *msg;
7615         msg_var = UpdateFailMalformedHTLC_clone(msg);
7616         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7617         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7618         uint64_t msg_ref = (uint64_t)msg_var.inner;
7619         if (msg_var.is_owned) {
7620                 msg_ref |= 1;
7621         }
7622         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7623         CHECK(obj != NULL);
7624         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7625         if ((*env)->ExceptionCheck(env)) {
7626                 (*env)->ExceptionDescribe(env);
7627                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
7628         }
7629         if (get_jenv_res == JNI_EDETACHED) {
7630                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7631         }
7632 }
7633 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7634         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7635         JNIEnv *env;
7636         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7637         if (get_jenv_res == JNI_EDETACHED) {
7638                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7639         } else {
7640                 DO_ASSERT(get_jenv_res == JNI_OK);
7641         }
7642         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7643         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7644         LDKCommitmentSigned msg_var = *msg;
7645         msg_var = CommitmentSigned_clone(msg);
7646         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7647         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7648         uint64_t msg_ref = (uint64_t)msg_var.inner;
7649         if (msg_var.is_owned) {
7650                 msg_ref |= 1;
7651         }
7652         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7653         CHECK(obj != NULL);
7654         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7655         if ((*env)->ExceptionCheck(env)) {
7656                 (*env)->ExceptionDescribe(env);
7657                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
7658         }
7659         if (get_jenv_res == JNI_EDETACHED) {
7660                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7661         }
7662 }
7663 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7664         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7665         JNIEnv *env;
7666         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7667         if (get_jenv_res == JNI_EDETACHED) {
7668                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7669         } else {
7670                 DO_ASSERT(get_jenv_res == JNI_OK);
7671         }
7672         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7673         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7674         LDKRevokeAndACK msg_var = *msg;
7675         msg_var = RevokeAndACK_clone(msg);
7676         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7677         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7678         uint64_t msg_ref = (uint64_t)msg_var.inner;
7679         if (msg_var.is_owned) {
7680                 msg_ref |= 1;
7681         }
7682         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7683         CHECK(obj != NULL);
7684         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7685         if ((*env)->ExceptionCheck(env)) {
7686                 (*env)->ExceptionDescribe(env);
7687                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
7688         }
7689         if (get_jenv_res == JNI_EDETACHED) {
7690                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7691         }
7692 }
7693 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7694         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7695         JNIEnv *env;
7696         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7697         if (get_jenv_res == JNI_EDETACHED) {
7698                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7699         } else {
7700                 DO_ASSERT(get_jenv_res == JNI_OK);
7701         }
7702         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7703         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7704         LDKUpdateFee msg_var = *msg;
7705         msg_var = UpdateFee_clone(msg);
7706         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7707         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7708         uint64_t msg_ref = (uint64_t)msg_var.inner;
7709         if (msg_var.is_owned) {
7710                 msg_ref |= 1;
7711         }
7712         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7713         CHECK(obj != NULL);
7714         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7715         if ((*env)->ExceptionCheck(env)) {
7716                 (*env)->ExceptionDescribe(env);
7717                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
7718         }
7719         if (get_jenv_res == JNI_EDETACHED) {
7720                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7721         }
7722 }
7723 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7724         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7725         JNIEnv *env;
7726         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7727         if (get_jenv_res == JNI_EDETACHED) {
7728                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7729         } else {
7730                 DO_ASSERT(get_jenv_res == JNI_OK);
7731         }
7732         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7733         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7734         LDKAnnouncementSignatures msg_var = *msg;
7735         msg_var = AnnouncementSignatures_clone(msg);
7736         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7737         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7738         uint64_t msg_ref = (uint64_t)msg_var.inner;
7739         if (msg_var.is_owned) {
7740                 msg_ref |= 1;
7741         }
7742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7743         CHECK(obj != NULL);
7744         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7745         if ((*env)->ExceptionCheck(env)) {
7746                 (*env)->ExceptionDescribe(env);
7747                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
7748         }
7749         if (get_jenv_res == JNI_EDETACHED) {
7750                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7751         }
7752 }
7753 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7754         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7755         JNIEnv *env;
7756         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7757         if (get_jenv_res == JNI_EDETACHED) {
7758                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7759         } else {
7760                 DO_ASSERT(get_jenv_res == JNI_OK);
7761         }
7762         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7763         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7764         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7765         CHECK(obj != NULL);
7766         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7767         if ((*env)->ExceptionCheck(env)) {
7768                 (*env)->ExceptionDescribe(env);
7769                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
7770         }
7771         if (get_jenv_res == JNI_EDETACHED) {
7772                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7773         }
7774 }
7775 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7776         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7777         JNIEnv *env;
7778         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7779         if (get_jenv_res == JNI_EDETACHED) {
7780                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7781         } else {
7782                 DO_ASSERT(get_jenv_res == JNI_OK);
7783         }
7784         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7785         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7786         LDKInit msg_var = *msg;
7787         msg_var = Init_clone(msg);
7788         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7789         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7790         uint64_t msg_ref = (uint64_t)msg_var.inner;
7791         if (msg_var.is_owned) {
7792                 msg_ref |= 1;
7793         }
7794         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7795         CHECK(obj != NULL);
7796         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7797         if ((*env)->ExceptionCheck(env)) {
7798                 (*env)->ExceptionDescribe(env);
7799                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
7800         }
7801         if (get_jenv_res == JNI_EDETACHED) {
7802                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7803         }
7804 }
7805 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7806         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7807         JNIEnv *env;
7808         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7809         if (get_jenv_res == JNI_EDETACHED) {
7810                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7811         } else {
7812                 DO_ASSERT(get_jenv_res == JNI_OK);
7813         }
7814         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7815         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7816         LDKChannelReestablish msg_var = *msg;
7817         msg_var = ChannelReestablish_clone(msg);
7818         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7819         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7820         uint64_t msg_ref = (uint64_t)msg_var.inner;
7821         if (msg_var.is_owned) {
7822                 msg_ref |= 1;
7823         }
7824         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7825         CHECK(obj != NULL);
7826         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7827         if ((*env)->ExceptionCheck(env)) {
7828                 (*env)->ExceptionDescribe(env);
7829                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
7830         }
7831         if (get_jenv_res == JNI_EDETACHED) {
7832                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7833         }
7834 }
7835 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7836         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7837         JNIEnv *env;
7838         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7839         if (get_jenv_res == JNI_EDETACHED) {
7840                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7841         } else {
7842                 DO_ASSERT(get_jenv_res == JNI_OK);
7843         }
7844         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7845         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7846         LDKChannelUpdate msg_var = *msg;
7847         msg_var = ChannelUpdate_clone(msg);
7848         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7849         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7850         uint64_t msg_ref = (uint64_t)msg_var.inner;
7851         if (msg_var.is_owned) {
7852                 msg_ref |= 1;
7853         }
7854         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7855         CHECK(obj != NULL);
7856         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7857         if ((*env)->ExceptionCheck(env)) {
7858                 (*env)->ExceptionDescribe(env);
7859                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
7860         }
7861         if (get_jenv_res == JNI_EDETACHED) {
7862                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7863         }
7864 }
7865 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7866         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7867         JNIEnv *env;
7868         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7869         if (get_jenv_res == JNI_EDETACHED) {
7870                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7871         } else {
7872                 DO_ASSERT(get_jenv_res == JNI_OK);
7873         }
7874         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7875         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7876         LDKErrorMessage msg_var = *msg;
7877         msg_var = ErrorMessage_clone(msg);
7878         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7879         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7880         uint64_t msg_ref = (uint64_t)msg_var.inner;
7881         if (msg_var.is_owned) {
7882                 msg_ref |= 1;
7883         }
7884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7885         CHECK(obj != NULL);
7886         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7887         if ((*env)->ExceptionCheck(env)) {
7888                 (*env)->ExceptionDescribe(env);
7889                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
7890         }
7891         if (get_jenv_res == JNI_EDETACHED) {
7892                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7893         }
7894 }
7895 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7896         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7897         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7898         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7899 }
7900 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7901         jclass c = (*env)->GetObjectClass(env, o);
7902         CHECK(c != NULL);
7903         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7904         atomic_init(&calls->refcnt, 1);
7905         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7906         calls->o = (*env)->NewWeakGlobalRef(env, o);
7907         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7908         CHECK(calls->handle_open_channel_meth != NULL);
7909         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7910         CHECK(calls->handle_accept_channel_meth != NULL);
7911         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7912         CHECK(calls->handle_funding_created_meth != NULL);
7913         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7914         CHECK(calls->handle_funding_signed_meth != NULL);
7915         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7916         CHECK(calls->handle_funding_locked_meth != NULL);
7917         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7918         CHECK(calls->handle_shutdown_meth != NULL);
7919         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7920         CHECK(calls->handle_closing_signed_meth != NULL);
7921         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7922         CHECK(calls->handle_update_add_htlc_meth != NULL);
7923         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7924         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7925         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7926         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7927         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7928         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7929         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7930         CHECK(calls->handle_commitment_signed_meth != NULL);
7931         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7932         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7933         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7934         CHECK(calls->handle_update_fee_meth != NULL);
7935         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7936         CHECK(calls->handle_announcement_signatures_meth != NULL);
7937         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7938         CHECK(calls->peer_disconnected_meth != NULL);
7939         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7940         CHECK(calls->peer_connected_meth != NULL);
7941         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7942         CHECK(calls->handle_channel_reestablish_meth != NULL);
7943         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7944         CHECK(calls->handle_channel_update_meth != NULL);
7945         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7946         CHECK(calls->handle_error_meth != NULL);
7947
7948         LDKChannelMessageHandler ret = {
7949                 .this_arg = (void*) calls,
7950                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7951                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7952                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7953                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7954                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7955                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7956                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7957                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7958                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7959                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7960                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7961                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7962                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7963                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7964                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7965                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7966                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7967                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7968                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7969                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7970                 .free = LDKChannelMessageHandler_JCalls_free,
7971                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7972         };
7973         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7974         return ret;
7975 }
7976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7977         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7978         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7979         return (uint64_t)res_ptr;
7980 }
7981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
7982         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
7983         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
7984         DO_ASSERT((res_ptr & 1) == 0);
7985         return (int64_t)(res_ptr | 1);
7986 }
7987 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) {
7988         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7989         LDKPublicKey their_node_id_ref;
7990         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7991         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7992         LDKInitFeatures their_features_conv;
7993         their_features_conv.inner = (void*)(their_features & (~1));
7994         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7995         their_features_conv = InitFeatures_clone(&their_features_conv);
7996         LDKOpenChannel msg_conv;
7997         msg_conv.inner = (void*)(msg & (~1));
7998         msg_conv.is_owned = false;
7999         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8000 }
8001
8002 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) {
8003         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8004         LDKPublicKey their_node_id_ref;
8005         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8006         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8007         LDKInitFeatures their_features_conv;
8008         their_features_conv.inner = (void*)(their_features & (~1));
8009         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8010         their_features_conv = InitFeatures_clone(&their_features_conv);
8011         LDKAcceptChannel msg_conv;
8012         msg_conv.inner = (void*)(msg & (~1));
8013         msg_conv.is_owned = false;
8014         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8015 }
8016
8017 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) {
8018         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8019         LDKPublicKey their_node_id_ref;
8020         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8021         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8022         LDKFundingCreated msg_conv;
8023         msg_conv.inner = (void*)(msg & (~1));
8024         msg_conv.is_owned = false;
8025         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8026 }
8027
8028 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) {
8029         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8030         LDKPublicKey their_node_id_ref;
8031         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8032         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8033         LDKFundingSigned msg_conv;
8034         msg_conv.inner = (void*)(msg & (~1));
8035         msg_conv.is_owned = false;
8036         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8037 }
8038
8039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8040         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8041         LDKPublicKey their_node_id_ref;
8042         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8043         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8044         LDKFundingLocked msg_conv;
8045         msg_conv.inner = (void*)(msg & (~1));
8046         msg_conv.is_owned = false;
8047         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8048 }
8049
8050 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) {
8051         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8052         LDKPublicKey their_node_id_ref;
8053         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8054         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8055         LDKInitFeatures their_features_conv;
8056         their_features_conv.inner = (void*)(their_features & (~1));
8057         their_features_conv.is_owned = false;
8058         LDKShutdown msg_conv;
8059         msg_conv.inner = (void*)(msg & (~1));
8060         msg_conv.is_owned = false;
8061         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
8062 }
8063
8064 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) {
8065         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8066         LDKPublicKey their_node_id_ref;
8067         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8068         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8069         LDKClosingSigned msg_conv;
8070         msg_conv.inner = (void*)(msg & (~1));
8071         msg_conv.is_owned = false;
8072         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8073 }
8074
8075 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) {
8076         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8077         LDKPublicKey their_node_id_ref;
8078         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8079         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8080         LDKUpdateAddHTLC msg_conv;
8081         msg_conv.inner = (void*)(msg & (~1));
8082         msg_conv.is_owned = false;
8083         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8084 }
8085
8086 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) {
8087         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8088         LDKPublicKey their_node_id_ref;
8089         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8090         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8091         LDKUpdateFulfillHTLC msg_conv;
8092         msg_conv.inner = (void*)(msg & (~1));
8093         msg_conv.is_owned = false;
8094         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8095 }
8096
8097 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) {
8098         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8099         LDKPublicKey their_node_id_ref;
8100         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8101         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8102         LDKUpdateFailHTLC msg_conv;
8103         msg_conv.inner = (void*)(msg & (~1));
8104         msg_conv.is_owned = false;
8105         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8106 }
8107
8108 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) {
8109         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8110         LDKPublicKey their_node_id_ref;
8111         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8112         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8113         LDKUpdateFailMalformedHTLC msg_conv;
8114         msg_conv.inner = (void*)(msg & (~1));
8115         msg_conv.is_owned = false;
8116         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8117 }
8118
8119 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) {
8120         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8121         LDKPublicKey their_node_id_ref;
8122         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8123         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8124         LDKCommitmentSigned msg_conv;
8125         msg_conv.inner = (void*)(msg & (~1));
8126         msg_conv.is_owned = false;
8127         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8128 }
8129
8130 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) {
8131         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8132         LDKPublicKey their_node_id_ref;
8133         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8134         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8135         LDKRevokeAndACK msg_conv;
8136         msg_conv.inner = (void*)(msg & (~1));
8137         msg_conv.is_owned = false;
8138         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8139 }
8140
8141 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) {
8142         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8143         LDKPublicKey their_node_id_ref;
8144         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8145         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8146         LDKUpdateFee msg_conv;
8147         msg_conv.inner = (void*)(msg & (~1));
8148         msg_conv.is_owned = false;
8149         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8150 }
8151
8152 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) {
8153         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8154         LDKPublicKey their_node_id_ref;
8155         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8156         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8157         LDKAnnouncementSignatures msg_conv;
8158         msg_conv.inner = (void*)(msg & (~1));
8159         msg_conv.is_owned = false;
8160         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8161 }
8162
8163 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) {
8164         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8165         LDKPublicKey their_node_id_ref;
8166         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8167         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8168         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8169 }
8170
8171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8172         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8173         LDKPublicKey their_node_id_ref;
8174         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8175         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8176         LDKInit msg_conv;
8177         msg_conv.inner = (void*)(msg & (~1));
8178         msg_conv.is_owned = false;
8179         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8180 }
8181
8182 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) {
8183         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8184         LDKPublicKey their_node_id_ref;
8185         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8186         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8187         LDKChannelReestablish msg_conv;
8188         msg_conv.inner = (void*)(msg & (~1));
8189         msg_conv.is_owned = false;
8190         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8191 }
8192
8193 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) {
8194         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8195         LDKPublicKey their_node_id_ref;
8196         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8197         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8198         LDKChannelUpdate msg_conv;
8199         msg_conv.inner = (void*)(msg & (~1));
8200         msg_conv.is_owned = false;
8201         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8202 }
8203
8204 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) {
8205         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8206         LDKPublicKey their_node_id_ref;
8207         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8208         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8209         LDKErrorMessage msg_conv;
8210         msg_conv.inner = (void*)(msg & (~1));
8211         msg_conv.is_owned = false;
8212         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8213 }
8214
8215 typedef struct LDKRoutingMessageHandler_JCalls {
8216         atomic_size_t refcnt;
8217         JavaVM *vm;
8218         jweak o;
8219         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8220         jmethodID handle_node_announcement_meth;
8221         jmethodID handle_channel_announcement_meth;
8222         jmethodID handle_channel_update_meth;
8223         jmethodID handle_htlc_fail_channel_update_meth;
8224         jmethodID get_next_channel_announcements_meth;
8225         jmethodID get_next_node_announcements_meth;
8226         jmethodID sync_routing_table_meth;
8227         jmethodID handle_reply_channel_range_meth;
8228         jmethodID handle_reply_short_channel_ids_end_meth;
8229         jmethodID handle_query_channel_range_meth;
8230         jmethodID handle_query_short_channel_ids_meth;
8231 } LDKRoutingMessageHandler_JCalls;
8232 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8233         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8234         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8235                 JNIEnv *env;
8236                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8237                 if (get_jenv_res == JNI_EDETACHED) {
8238                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8239                 } else {
8240                         DO_ASSERT(get_jenv_res == JNI_OK);
8241                 }
8242                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8243                 if (get_jenv_res == JNI_EDETACHED) {
8244                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8245                 }
8246                 FREE(j_calls);
8247         }
8248 }
8249 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8250         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8251         JNIEnv *env;
8252         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8253         if (get_jenv_res == JNI_EDETACHED) {
8254                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8255         } else {
8256                 DO_ASSERT(get_jenv_res == JNI_OK);
8257         }
8258         LDKNodeAnnouncement msg_var = *msg;
8259         msg_var = NodeAnnouncement_clone(msg);
8260         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8261         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8262         uint64_t msg_ref = (uint64_t)msg_var.inner;
8263         if (msg_var.is_owned) {
8264                 msg_ref |= 1;
8265         }
8266         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8267         CHECK(obj != NULL);
8268         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
8269         if ((*env)->ExceptionCheck(env)) {
8270                 (*env)->ExceptionDescribe(env);
8271                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8272         }
8273         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8274         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8275         if (get_jenv_res == JNI_EDETACHED) {
8276                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8277         }
8278         return ret_conv;
8279 }
8280 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8281         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8282         JNIEnv *env;
8283         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8284         if (get_jenv_res == JNI_EDETACHED) {
8285                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8286         } else {
8287                 DO_ASSERT(get_jenv_res == JNI_OK);
8288         }
8289         LDKChannelAnnouncement msg_var = *msg;
8290         msg_var = ChannelAnnouncement_clone(msg);
8291         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8292         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8293         uint64_t msg_ref = (uint64_t)msg_var.inner;
8294         if (msg_var.is_owned) {
8295                 msg_ref |= 1;
8296         }
8297         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8298         CHECK(obj != NULL);
8299         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
8300         if ((*env)->ExceptionCheck(env)) {
8301                 (*env)->ExceptionDescribe(env);
8302                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8303         }
8304         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8305         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8306         if (get_jenv_res == JNI_EDETACHED) {
8307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8308         }
8309         return ret_conv;
8310 }
8311 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8312         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8313         JNIEnv *env;
8314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8315         if (get_jenv_res == JNI_EDETACHED) {
8316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8317         } else {
8318                 DO_ASSERT(get_jenv_res == JNI_OK);
8319         }
8320         LDKChannelUpdate msg_var = *msg;
8321         msg_var = ChannelUpdate_clone(msg);
8322         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8323         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8324         uint64_t msg_ref = (uint64_t)msg_var.inner;
8325         if (msg_var.is_owned) {
8326                 msg_ref |= 1;
8327         }
8328         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8329         CHECK(obj != NULL);
8330         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
8331         if ((*env)->ExceptionCheck(env)) {
8332                 (*env)->ExceptionDescribe(env);
8333                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8334         }
8335         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8336         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8337         if (get_jenv_res == JNI_EDETACHED) {
8338                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8339         }
8340         return ret_conv;
8341 }
8342 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
8343         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8344         JNIEnv *env;
8345         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8346         if (get_jenv_res == JNI_EDETACHED) {
8347                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8348         } else {
8349                 DO_ASSERT(get_jenv_res == JNI_OK);
8350         }
8351         uint64_t ret_update = (uint64_t)update;
8352         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8353         CHECK(obj != NULL);
8354         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
8355         if ((*env)->ExceptionCheck(env)) {
8356                 (*env)->ExceptionDescribe(env);
8357                 (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8358         }
8359         if (get_jenv_res == JNI_EDETACHED) {
8360                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8361         }
8362 }
8363 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8364         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8365         JNIEnv *env;
8366         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8367         if (get_jenv_res == JNI_EDETACHED) {
8368                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8369         } else {
8370                 DO_ASSERT(get_jenv_res == JNI_OK);
8371         }
8372         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8373         CHECK(obj != NULL);
8374         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
8375         if ((*env)->ExceptionCheck(env)) {
8376                 (*env)->ExceptionDescribe(env);
8377                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8378         }
8379         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8380         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8381         if (ret_constr.datalen > 0)
8382                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8383         else
8384                 ret_constr.data = NULL;
8385         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8386         for (size_t l = 0; l < ret_constr.datalen; l++) {
8387                 int64_t ret_conv_63 = ret_vals[l];
8388                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
8389                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
8390                 ret_constr.data[l] = ret_conv_63_conv;
8391         }
8392         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8393         if (get_jenv_res == JNI_EDETACHED) {
8394                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8395         }
8396         return ret_constr;
8397 }
8398 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8399         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8400         JNIEnv *env;
8401         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8402         if (get_jenv_res == JNI_EDETACHED) {
8403                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8404         } else {
8405                 DO_ASSERT(get_jenv_res == JNI_OK);
8406         }
8407         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
8408         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
8409         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8410         CHECK(obj != NULL);
8411         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
8412         if ((*env)->ExceptionCheck(env)) {
8413                 (*env)->ExceptionDescribe(env);
8414                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8415         }
8416         LDKCVec_NodeAnnouncementZ ret_constr;
8417         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8418         if (ret_constr.datalen > 0)
8419                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8420         else
8421                 ret_constr.data = NULL;
8422         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8423         for (size_t s = 0; s < ret_constr.datalen; s++) {
8424                 int64_t ret_conv_18 = ret_vals[s];
8425                 LDKNodeAnnouncement ret_conv_18_conv;
8426                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8427                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8428                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
8429                 ret_constr.data[s] = ret_conv_18_conv;
8430         }
8431         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8432         if (get_jenv_res == JNI_EDETACHED) {
8433                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8434         }
8435         return ret_constr;
8436 }
8437 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8438         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8439         JNIEnv *env;
8440         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8441         if (get_jenv_res == JNI_EDETACHED) {
8442                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8443         } else {
8444                 DO_ASSERT(get_jenv_res == JNI_OK);
8445         }
8446         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8447         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8448         LDKInit init_var = *init;
8449         init_var = Init_clone(init);
8450         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8451         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8452         uint64_t init_ref = (uint64_t)init_var.inner;
8453         if (init_var.is_owned) {
8454                 init_ref |= 1;
8455         }
8456         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8457         CHECK(obj != NULL);
8458         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
8459         if ((*env)->ExceptionCheck(env)) {
8460                 (*env)->ExceptionDescribe(env);
8461                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
8462         }
8463         if (get_jenv_res == JNI_EDETACHED) {
8464                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8465         }
8466 }
8467 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8468         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8469         JNIEnv *env;
8470         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8471         if (get_jenv_res == JNI_EDETACHED) {
8472                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8473         } else {
8474                 DO_ASSERT(get_jenv_res == JNI_OK);
8475         }
8476         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8477         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8478         LDKReplyChannelRange msg_var = msg;
8479         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8480         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8481         uint64_t msg_ref = (uint64_t)msg_var.inner;
8482         if (msg_var.is_owned) {
8483                 msg_ref |= 1;
8484         }
8485         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8486         CHECK(obj != NULL);
8487         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8488         if ((*env)->ExceptionCheck(env)) {
8489                 (*env)->ExceptionDescribe(env);
8490                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8491         }
8492         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8493         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8494         if (get_jenv_res == JNI_EDETACHED) {
8495                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8496         }
8497         return ret_conv;
8498 }
8499 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8500         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8501         JNIEnv *env;
8502         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8503         if (get_jenv_res == JNI_EDETACHED) {
8504                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8505         } else {
8506                 DO_ASSERT(get_jenv_res == JNI_OK);
8507         }
8508         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8509         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8510         LDKReplyShortChannelIdsEnd msg_var = msg;
8511         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8512         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8513         uint64_t msg_ref = (uint64_t)msg_var.inner;
8514         if (msg_var.is_owned) {
8515                 msg_ref |= 1;
8516         }
8517         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8518         CHECK(obj != NULL);
8519         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8520         if ((*env)->ExceptionCheck(env)) {
8521                 (*env)->ExceptionDescribe(env);
8522                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
8523         }
8524         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8525         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8526         if (get_jenv_res == JNI_EDETACHED) {
8527                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8528         }
8529         return ret_conv;
8530 }
8531 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8532         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8533         JNIEnv *env;
8534         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8535         if (get_jenv_res == JNI_EDETACHED) {
8536                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8537         } else {
8538                 DO_ASSERT(get_jenv_res == JNI_OK);
8539         }
8540         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8541         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8542         LDKQueryChannelRange msg_var = msg;
8543         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8544         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8545         uint64_t msg_ref = (uint64_t)msg_var.inner;
8546         if (msg_var.is_owned) {
8547                 msg_ref |= 1;
8548         }
8549         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8550         CHECK(obj != NULL);
8551         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8552         if ((*env)->ExceptionCheck(env)) {
8553                 (*env)->ExceptionDescribe(env);
8554                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8555         }
8556         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8557         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8558         if (get_jenv_res == JNI_EDETACHED) {
8559                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8560         }
8561         return ret_conv;
8562 }
8563 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8564         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8565         JNIEnv *env;
8566         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8567         if (get_jenv_res == JNI_EDETACHED) {
8568                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8569         } else {
8570                 DO_ASSERT(get_jenv_res == JNI_OK);
8571         }
8572         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8573         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8574         LDKQueryShortChannelIds msg_var = msg;
8575         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8576         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8577         uint64_t msg_ref = (uint64_t)msg_var.inner;
8578         if (msg_var.is_owned) {
8579                 msg_ref |= 1;
8580         }
8581         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8582         CHECK(obj != NULL);
8583         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8584         if ((*env)->ExceptionCheck(env)) {
8585                 (*env)->ExceptionDescribe(env);
8586                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
8587         }
8588         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8589         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8590         if (get_jenv_res == JNI_EDETACHED) {
8591                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8592         }
8593         return ret_conv;
8594 }
8595 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8596         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8597         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8598         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8599 }
8600 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8601         jclass c = (*env)->GetObjectClass(env, o);
8602         CHECK(c != NULL);
8603         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8604         atomic_init(&calls->refcnt, 1);
8605         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8606         calls->o = (*env)->NewWeakGlobalRef(env, o);
8607         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8608         CHECK(calls->handle_node_announcement_meth != NULL);
8609         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8610         CHECK(calls->handle_channel_announcement_meth != NULL);
8611         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8612         CHECK(calls->handle_channel_update_meth != NULL);
8613         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8614         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8615         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8616         CHECK(calls->get_next_channel_announcements_meth != NULL);
8617         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8618         CHECK(calls->get_next_node_announcements_meth != NULL);
8619         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8620         CHECK(calls->sync_routing_table_meth != NULL);
8621         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8622         CHECK(calls->handle_reply_channel_range_meth != NULL);
8623         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8624         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8625         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8626         CHECK(calls->handle_query_channel_range_meth != NULL);
8627         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8628         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8629
8630         LDKRoutingMessageHandler ret = {
8631                 .this_arg = (void*) calls,
8632                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8633                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8634                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8635                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8636                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8637                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8638                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8639                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8640                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8641                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8642                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8643                 .free = LDKRoutingMessageHandler_JCalls_free,
8644                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8645         };
8646         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8647         return ret;
8648 }
8649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8650         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8651         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8652         return (uint64_t)res_ptr;
8653 }
8654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8655         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
8656         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8657         DO_ASSERT((res_ptr & 1) == 0);
8658         return (int64_t)(res_ptr | 1);
8659 }
8660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8661         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8662         LDKNodeAnnouncement msg_conv;
8663         msg_conv.inner = (void*)(msg & (~1));
8664         msg_conv.is_owned = false;
8665         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8666         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8667         return (uint64_t)ret_conv;
8668 }
8669
8670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8671         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8672         LDKChannelAnnouncement msg_conv;
8673         msg_conv.inner = (void*)(msg & (~1));
8674         msg_conv.is_owned = false;
8675         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8676         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8677         return (uint64_t)ret_conv;
8678 }
8679
8680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8681         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8682         LDKChannelUpdate msg_conv;
8683         msg_conv.inner = (void*)(msg & (~1));
8684         msg_conv.is_owned = false;
8685         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8686         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8687         return (uint64_t)ret_conv;
8688 }
8689
8690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t update) {
8691         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8692         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8693         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8694 }
8695
8696 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) {
8697         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8698         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8699         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8700         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8701         for (size_t l = 0; l < ret_var.datalen; l++) {
8702                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8703                 *ret_conv_63_ref = ret_var.data[l];
8704                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8705         }
8706         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8707         FREE(ret_var.data);
8708         return ret_arr;
8709 }
8710
8711 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
8712         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8713         LDKPublicKey starting_point_ref;
8714         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8715         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8716         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8717         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8718         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8719         for (size_t s = 0; s < ret_var.datalen; s++) {
8720                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8721                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8722                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8723                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8724                 if (ret_conv_18_var.is_owned) {
8725                         ret_conv_18_ref |= 1;
8726                 }
8727                 ret_arr_ptr[s] = ret_conv_18_ref;
8728         }
8729         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8730         FREE(ret_var.data);
8731         return ret_arr;
8732 }
8733
8734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
8735         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8736         LDKPublicKey their_node_id_ref;
8737         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8738         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8739         LDKInit init_conv;
8740         init_conv.inner = (void*)(init & (~1));
8741         init_conv.is_owned = false;
8742         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8743 }
8744
8745 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) {
8746         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8747         LDKPublicKey their_node_id_ref;
8748         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8749         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8750         LDKReplyChannelRange msg_conv;
8751         msg_conv.inner = (void*)(msg & (~1));
8752         msg_conv.is_owned = (msg & 1) || (msg == 0);
8753         msg_conv = ReplyChannelRange_clone(&msg_conv);
8754         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8755         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8756         return (uint64_t)ret_conv;
8757 }
8758
8759 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) {
8760         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8761         LDKPublicKey their_node_id_ref;
8762         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8763         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8764         LDKReplyShortChannelIdsEnd msg_conv;
8765         msg_conv.inner = (void*)(msg & (~1));
8766         msg_conv.is_owned = (msg & 1) || (msg == 0);
8767         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8768         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8769         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8770         return (uint64_t)ret_conv;
8771 }
8772
8773 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) {
8774         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8775         LDKPublicKey their_node_id_ref;
8776         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8777         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8778         LDKQueryChannelRange msg_conv;
8779         msg_conv.inner = (void*)(msg & (~1));
8780         msg_conv.is_owned = (msg & 1) || (msg == 0);
8781         msg_conv = QueryChannelRange_clone(&msg_conv);
8782         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8783         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8784         return (uint64_t)ret_conv;
8785 }
8786
8787 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) {
8788         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8789         LDKPublicKey their_node_id_ref;
8790         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8791         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8792         LDKQueryShortChannelIds msg_conv;
8793         msg_conv.inner = (void*)(msg & (~1));
8794         msg_conv.is_owned = (msg & 1) || (msg == 0);
8795         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8796         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8797         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8798         return (uint64_t)ret_conv;
8799 }
8800
8801 typedef struct LDKSocketDescriptor_JCalls {
8802         atomic_size_t refcnt;
8803         JavaVM *vm;
8804         jweak o;
8805         jmethodID send_data_meth;
8806         jmethodID disconnect_socket_meth;
8807         jmethodID eq_meth;
8808         jmethodID hash_meth;
8809 } LDKSocketDescriptor_JCalls;
8810 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8811         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8812         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8813                 JNIEnv *env;
8814                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8815                 if (get_jenv_res == JNI_EDETACHED) {
8816                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8817                 } else {
8818                         DO_ASSERT(get_jenv_res == JNI_OK);
8819                 }
8820                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8821                 if (get_jenv_res == JNI_EDETACHED) {
8822                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8823                 }
8824                 FREE(j_calls);
8825         }
8826 }
8827 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8828         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8829         JNIEnv *env;
8830         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8831         if (get_jenv_res == JNI_EDETACHED) {
8832                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8833         } else {
8834                 DO_ASSERT(get_jenv_res == JNI_OK);
8835         }
8836         LDKu8slice data_var = data;
8837         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8838         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8839         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8840         CHECK(obj != NULL);
8841         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8842         if ((*env)->ExceptionCheck(env)) {
8843                 (*env)->ExceptionDescribe(env);
8844                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
8845         }
8846         if (get_jenv_res == JNI_EDETACHED) {
8847                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8848         }
8849         return ret;
8850 }
8851 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8852         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8853         JNIEnv *env;
8854         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8855         if (get_jenv_res == JNI_EDETACHED) {
8856                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8857         } else {
8858                 DO_ASSERT(get_jenv_res == JNI_OK);
8859         }
8860         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8861         CHECK(obj != NULL);
8862         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8863         if ((*env)->ExceptionCheck(env)) {
8864                 (*env)->ExceptionDescribe(env);
8865                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
8866         }
8867         if (get_jenv_res == JNI_EDETACHED) {
8868                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8869         }
8870 }
8871 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8872         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8873         JNIEnv *env;
8874         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8875         if (get_jenv_res == JNI_EDETACHED) {
8876                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8877         } else {
8878                 DO_ASSERT(get_jenv_res == JNI_OK);
8879         }
8880         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8881         *other_arg_clone = SocketDescriptor_clone(other_arg);
8882         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8883         CHECK(obj != NULL);
8884         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8885         if ((*env)->ExceptionCheck(env)) {
8886                 (*env)->ExceptionDescribe(env);
8887                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
8888         }
8889         if (get_jenv_res == JNI_EDETACHED) {
8890                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8891         }
8892         return ret;
8893 }
8894 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8895         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8896         JNIEnv *env;
8897         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8898         if (get_jenv_res == JNI_EDETACHED) {
8899                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8900         } else {
8901                 DO_ASSERT(get_jenv_res == JNI_OK);
8902         }
8903         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8904         CHECK(obj != NULL);
8905         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8906         if ((*env)->ExceptionCheck(env)) {
8907                 (*env)->ExceptionDescribe(env);
8908                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
8909         }
8910         if (get_jenv_res == JNI_EDETACHED) {
8911                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8912         }
8913         return ret;
8914 }
8915 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8916         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8917         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8918 }
8919 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8920         jclass c = (*env)->GetObjectClass(env, o);
8921         CHECK(c != NULL);
8922         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8923         atomic_init(&calls->refcnt, 1);
8924         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8925         calls->o = (*env)->NewWeakGlobalRef(env, o);
8926         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8927         CHECK(calls->send_data_meth != NULL);
8928         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8929         CHECK(calls->disconnect_socket_meth != NULL);
8930         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8931         CHECK(calls->eq_meth != NULL);
8932         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8933         CHECK(calls->hash_meth != NULL);
8934
8935         LDKSocketDescriptor ret = {
8936                 .this_arg = (void*) calls,
8937                 .send_data = send_data_LDKSocketDescriptor_jcall,
8938                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8939                 .eq = eq_LDKSocketDescriptor_jcall,
8940                 .hash = hash_LDKSocketDescriptor_jcall,
8941                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8942                 .free = LDKSocketDescriptor_JCalls_free,
8943         };
8944         return ret;
8945 }
8946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8947         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8948         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8949         return (uint64_t)res_ptr;
8950 }
8951 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) {
8952         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8953         LDKu8slice data_ref;
8954         data_ref.datalen = (*env)->GetArrayLength(env, data);
8955         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8956         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8957         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8958         return ret_val;
8959 }
8960
8961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8962         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8963         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8964 }
8965
8966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8967         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8968         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8969         return ret_val;
8970 }
8971
8972 typedef struct LDKChannelManagerPersister_JCalls {
8973         atomic_size_t refcnt;
8974         JavaVM *vm;
8975         jweak o;
8976         jmethodID persist_manager_meth;
8977 } LDKChannelManagerPersister_JCalls;
8978 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8979         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8980         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8981                 JNIEnv *env;
8982                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8983                 if (get_jenv_res == JNI_EDETACHED) {
8984                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8985                 } else {
8986                         DO_ASSERT(get_jenv_res == JNI_OK);
8987                 }
8988                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8989                 if (get_jenv_res == JNI_EDETACHED) {
8990                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8991                 }
8992                 FREE(j_calls);
8993         }
8994 }
8995 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8996         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
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         LDKChannelManager channel_manager_var = *channel_manager;
9005         // Warning: we may need a move here but no clone is available for LDKChannelManager
9006         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9007         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9008         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
9009         if (channel_manager_var.is_owned) {
9010                 channel_manager_ref |= 1;
9011         }
9012         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9013         CHECK(obj != NULL);
9014         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
9015         if ((*env)->ExceptionCheck(env)) {
9016                 (*env)->ExceptionDescribe(env);
9017                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
9018         }
9019         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
9020         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
9021         if (get_jenv_res == JNI_EDETACHED) {
9022                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9023         }
9024         return ret_conv;
9025 }
9026 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
9027         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
9028         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9029 }
9030 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
9031         jclass c = (*env)->GetObjectClass(env, o);
9032         CHECK(c != NULL);
9033         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
9034         atomic_init(&calls->refcnt, 1);
9035         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9036         calls->o = (*env)->NewWeakGlobalRef(env, o);
9037         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
9038         CHECK(calls->persist_manager_meth != NULL);
9039
9040         LDKChannelManagerPersister ret = {
9041                 .this_arg = (void*) calls,
9042                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
9043                 .free = LDKChannelManagerPersister_JCalls_free,
9044         };
9045         return ret;
9046 }
9047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
9048         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
9049         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
9050         return (uint64_t)res_ptr;
9051 }
9052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
9053         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
9054         LDKChannelManager channel_manager_conv;
9055         channel_manager_conv.inner = (void*)(channel_manager & (~1));
9056         channel_manager_conv.is_owned = false;
9057         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9058         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
9059         return (uint64_t)ret_conv;
9060 }
9061
9062 static jclass LDKFallback_SegWitProgram_class = NULL;
9063 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
9064 static jclass LDKFallback_PubKeyHash_class = NULL;
9065 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
9066 static jclass LDKFallback_ScriptHash_class = NULL;
9067 static jmethodID LDKFallback_ScriptHash_meth = NULL;
9068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
9069         LDKFallback_SegWitProgram_class =
9070                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
9071         CHECK(LDKFallback_SegWitProgram_class != NULL);
9072         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
9073         CHECK(LDKFallback_SegWitProgram_meth != NULL);
9074         LDKFallback_PubKeyHash_class =
9075                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
9076         CHECK(LDKFallback_PubKeyHash_class != NULL);
9077         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
9078         CHECK(LDKFallback_PubKeyHash_meth != NULL);
9079         LDKFallback_ScriptHash_class =
9080                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
9081         CHECK(LDKFallback_ScriptHash_class != NULL);
9082         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
9083         CHECK(LDKFallback_ScriptHash_meth != NULL);
9084 }
9085 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9086         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9087         switch(obj->tag) {
9088                 case LDKFallback_SegWitProgram: {
9089                         uint8_t version_val = obj->seg_wit_program.version._0;
9090                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
9091                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
9092                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
9093                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
9094                 }
9095                 case LDKFallback_PubKeyHash: {
9096                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
9097                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
9098                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
9099                 }
9100                 case LDKFallback_ScriptHash: {
9101                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
9102                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
9103                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
9104                 }
9105                 default: abort();
9106         }
9107 }
9108 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
9109         LDKStr ret_str = _ldk_get_compiled_version();
9110         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9111         Str_free(ret_str);
9112         return ret_conv;
9113 }
9114
9115 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
9116         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
9117         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9118         Str_free(ret_str);
9119         return ret_conv;
9120 }
9121
9122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
9123         LDKTransaction _res_ref;
9124         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
9125         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
9126         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
9127         _res_ref.data_is_owned = true;
9128         Transaction_free(_res_ref);
9129 }
9130
9131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
9132         if ((_res & 1) != 0) return;
9133         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
9134         FREE((void*)_res);
9135         TxOut_free(_res_conv);
9136 }
9137
9138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9139         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
9140         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9141         *ret_ref = TxOut_clone(orig_conv);
9142         return (uint64_t)ret_ref;
9143 }
9144
9145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
9146         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
9147         Str_free(dummy);
9148 }
9149
9150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9151         LDKSecretKey o_ref;
9152         CHECK((*env)->GetArrayLength(env, o) == 32);
9153         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
9154         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9155         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9156         return (uint64_t)ret_conv;
9157 }
9158
9159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9160         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9161         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9162         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9163         return (uint64_t)ret_conv;
9164 }
9165
9166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9167         if ((_res & 1) != 0) return;
9168         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
9169         FREE((void*)_res);
9170         CResult_SecretKeyErrorZ_free(_res_conv);
9171 }
9172
9173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9174         LDKPublicKey o_ref;
9175         CHECK((*env)->GetArrayLength(env, o) == 33);
9176         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
9177         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9178         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9179         return (uint64_t)ret_conv;
9180 }
9181
9182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9183         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9184         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9185         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9186         return (uint64_t)ret_conv;
9187 }
9188
9189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9190         if ((_res & 1) != 0) return;
9191         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
9192         FREE((void*)_res);
9193         CResult_PublicKeyErrorZ_free(_res_conv);
9194 }
9195
9196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9197         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9198         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9199         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9200         return (uint64_t)ret_conv;
9201 }
9202
9203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9204         LDKTxCreationKeys o_conv;
9205         o_conv.inner = (void*)(o & (~1));
9206         o_conv.is_owned = (o & 1) || (o == 0);
9207         o_conv = TxCreationKeys_clone(&o_conv);
9208         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9209         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9210         return (uint64_t)ret_conv;
9211 }
9212
9213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9214         LDKDecodeError e_conv;
9215         e_conv.inner = (void*)(e & (~1));
9216         e_conv.is_owned = (e & 1) || (e == 0);
9217         e_conv = DecodeError_clone(&e_conv);
9218         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9219         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9220         return (uint64_t)ret_conv;
9221 }
9222
9223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9224         if ((_res & 1) != 0) return;
9225         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9226         FREE((void*)_res);
9227         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9228 }
9229
9230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9231         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9232         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9233         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9234         return (uint64_t)ret_conv;
9235 }
9236
9237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9238         LDKChannelPublicKeys o_conv;
9239         o_conv.inner = (void*)(o & (~1));
9240         o_conv.is_owned = (o & 1) || (o == 0);
9241         o_conv = ChannelPublicKeys_clone(&o_conv);
9242         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9243         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9244         return (uint64_t)ret_conv;
9245 }
9246
9247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9248         LDKDecodeError e_conv;
9249         e_conv.inner = (void*)(e & (~1));
9250         e_conv.is_owned = (e & 1) || (e == 0);
9251         e_conv = DecodeError_clone(&e_conv);
9252         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9253         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9254         return (uint64_t)ret_conv;
9255 }
9256
9257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9258         if ((_res & 1) != 0) return;
9259         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9260         FREE((void*)_res);
9261         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9262 }
9263
9264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9265         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9266         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9267         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9268         return (uint64_t)ret_conv;
9269 }
9270
9271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9272         LDKTxCreationKeys o_conv;
9273         o_conv.inner = (void*)(o & (~1));
9274         o_conv.is_owned = (o & 1) || (o == 0);
9275         o_conv = TxCreationKeys_clone(&o_conv);
9276         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9277         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9278         return (uint64_t)ret_conv;
9279 }
9280
9281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9282         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9283         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9284         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9285         return (uint64_t)ret_conv;
9286 }
9287
9288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9289         if ((_res & 1) != 0) return;
9290         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
9291         FREE((void*)_res);
9292         CResult_TxCreationKeysErrorZ_free(_res_conv);
9293 }
9294
9295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9296         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9297         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9298         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9299         return (uint64_t)ret_conv;
9300 }
9301
9302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
9303         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9304         *ret_copy = COption_u32Z_some(o);
9305         uint64_t ret_ref = (uint64_t)ret_copy;
9306         return ret_ref;
9307 }
9308
9309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
9310         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9311         *ret_copy = COption_u32Z_none();
9312         uint64_t ret_ref = (uint64_t)ret_copy;
9313         return ret_ref;
9314 }
9315
9316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9317         if ((_res & 1) != 0) return;
9318         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
9319         FREE((void*)_res);
9320         COption_u32Z_free(_res_conv);
9321 }
9322
9323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9324         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9325         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9326         *ret_copy = COption_u32Z_clone(orig_conv);
9327         uint64_t ret_ref = (uint64_t)ret_copy;
9328         return ret_ref;
9329 }
9330
9331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9332         LDKHTLCOutputInCommitment o_conv;
9333         o_conv.inner = (void*)(o & (~1));
9334         o_conv.is_owned = (o & 1) || (o == 0);
9335         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9336         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9337         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9338         return (uint64_t)ret_conv;
9339 }
9340
9341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9342         LDKDecodeError e_conv;
9343         e_conv.inner = (void*)(e & (~1));
9344         e_conv.is_owned = (e & 1) || (e == 0);
9345         e_conv = DecodeError_clone(&e_conv);
9346         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9347         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9348         return (uint64_t)ret_conv;
9349 }
9350
9351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9352         if ((_res & 1) != 0) return;
9353         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
9354         FREE((void*)_res);
9355         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9356 }
9357
9358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9359         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9360         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9361         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9362         return (uint64_t)ret_conv;
9363 }
9364
9365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9366         LDKCounterpartyChannelTransactionParameters o_conv;
9367         o_conv.inner = (void*)(o & (~1));
9368         o_conv.is_owned = (o & 1) || (o == 0);
9369         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9370         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9371         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9372         return (uint64_t)ret_conv;
9373 }
9374
9375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9376         LDKDecodeError e_conv;
9377         e_conv.inner = (void*)(e & (~1));
9378         e_conv.is_owned = (e & 1) || (e == 0);
9379         e_conv = DecodeError_clone(&e_conv);
9380         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9381         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9382         return (uint64_t)ret_conv;
9383 }
9384
9385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9386         if ((_res & 1) != 0) return;
9387         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9388         FREE((void*)_res);
9389         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9390 }
9391
9392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9393         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9394         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9395         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9396         return (uint64_t)ret_conv;
9397 }
9398
9399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9400         LDKChannelTransactionParameters o_conv;
9401         o_conv.inner = (void*)(o & (~1));
9402         o_conv.is_owned = (o & 1) || (o == 0);
9403         o_conv = ChannelTransactionParameters_clone(&o_conv);
9404         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9405         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9406         return (uint64_t)ret_conv;
9407 }
9408
9409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9410         LDKDecodeError e_conv;
9411         e_conv.inner = (void*)(e & (~1));
9412         e_conv.is_owned = (e & 1) || (e == 0);
9413         e_conv = DecodeError_clone(&e_conv);
9414         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9415         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9416         return (uint64_t)ret_conv;
9417 }
9418
9419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9420         if ((_res & 1) != 0) return;
9421         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9422         FREE((void*)_res);
9423         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9424 }
9425
9426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9427         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9428         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9429         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9430         return (uint64_t)ret_conv;
9431 }
9432
9433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9434         LDKCVec_SignatureZ _res_constr;
9435         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9436         if (_res_constr.datalen > 0)
9437                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9438         else
9439                 _res_constr.data = NULL;
9440         for (size_t i = 0; i < _res_constr.datalen; i++) {
9441                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9442                 LDKSignature _res_conv_8_ref;
9443                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
9444                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
9445                 _res_constr.data[i] = _res_conv_8_ref;
9446         }
9447         CVec_SignatureZ_free(_res_constr);
9448 }
9449
9450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9451         LDKHolderCommitmentTransaction o_conv;
9452         o_conv.inner = (void*)(o & (~1));
9453         o_conv.is_owned = (o & 1) || (o == 0);
9454         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9455         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9456         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9457         return (uint64_t)ret_conv;
9458 }
9459
9460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9461         LDKDecodeError e_conv;
9462         e_conv.inner = (void*)(e & (~1));
9463         e_conv.is_owned = (e & 1) || (e == 0);
9464         e_conv = DecodeError_clone(&e_conv);
9465         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9466         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9467         return (uint64_t)ret_conv;
9468 }
9469
9470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9471         if ((_res & 1) != 0) return;
9472         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9473         FREE((void*)_res);
9474         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9475 }
9476
9477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9478         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9479         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9480         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9481         return (uint64_t)ret_conv;
9482 }
9483
9484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9485         LDKBuiltCommitmentTransaction o_conv;
9486         o_conv.inner = (void*)(o & (~1));
9487         o_conv.is_owned = (o & 1) || (o == 0);
9488         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9489         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9490         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9491         return (uint64_t)ret_conv;
9492 }
9493
9494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9495         LDKDecodeError e_conv;
9496         e_conv.inner = (void*)(e & (~1));
9497         e_conv.is_owned = (e & 1) || (e == 0);
9498         e_conv = DecodeError_clone(&e_conv);
9499         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9500         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9501         return (uint64_t)ret_conv;
9502 }
9503
9504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9505         if ((_res & 1) != 0) return;
9506         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9507         FREE((void*)_res);
9508         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9509 }
9510
9511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9512         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9513         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9514         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9515         return (uint64_t)ret_conv;
9516 }
9517
9518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9519         LDKCommitmentTransaction o_conv;
9520         o_conv.inner = (void*)(o & (~1));
9521         o_conv.is_owned = (o & 1) || (o == 0);
9522         o_conv = CommitmentTransaction_clone(&o_conv);
9523         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9524         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9525         return (uint64_t)ret_conv;
9526 }
9527
9528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9529         LDKDecodeError e_conv;
9530         e_conv.inner = (void*)(e & (~1));
9531         e_conv.is_owned = (e & 1) || (e == 0);
9532         e_conv = DecodeError_clone(&e_conv);
9533         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9534         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9535         return (uint64_t)ret_conv;
9536 }
9537
9538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9539         if ((_res & 1) != 0) return;
9540         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9541         FREE((void*)_res);
9542         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9543 }
9544
9545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9546         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9547         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9548         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9549         return (uint64_t)ret_conv;
9550 }
9551
9552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9553         LDKTrustedCommitmentTransaction o_conv;
9554         o_conv.inner = (void*)(o & (~1));
9555         o_conv.is_owned = (o & 1) || (o == 0);
9556         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9557         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9558         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9559         return (uint64_t)ret_conv;
9560 }
9561
9562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9563         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9564         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9565         return (uint64_t)ret_conv;
9566 }
9567
9568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9569         if ((_res & 1) != 0) return;
9570         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9571         FREE((void*)_res);
9572         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9573 }
9574
9575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9576         LDKCVec_SignatureZ o_constr;
9577         o_constr.datalen = (*env)->GetArrayLength(env, o);
9578         if (o_constr.datalen > 0)
9579                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9580         else
9581                 o_constr.data = NULL;
9582         for (size_t i = 0; i < o_constr.datalen; i++) {
9583                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9584                 LDKSignature o_conv_8_ref;
9585                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9586                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9587                 o_constr.data[i] = o_conv_8_ref;
9588         }
9589         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9590         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9591         return (uint64_t)ret_conv;
9592 }
9593
9594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9595         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9596         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9597         return (uint64_t)ret_conv;
9598 }
9599
9600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9601         if ((_res & 1) != 0) return;
9602         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9603         FREE((void*)_res);
9604         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9605 }
9606
9607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9608         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9609         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9610         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9611         return (uint64_t)ret_conv;
9612 }
9613
9614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9615         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9616         *ret_conv = CResult_NoneErrorZ_ok();
9617         return (uint64_t)ret_conv;
9618 }
9619
9620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9621         LDKIOError e_conv = LDKIOError_from_java(env, e);
9622         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9623         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9624         return (uint64_t)ret_conv;
9625 }
9626
9627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9628         if ((_res & 1) != 0) return;
9629         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9630         FREE((void*)_res);
9631         CResult_NoneErrorZ_free(_res_conv);
9632 }
9633
9634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9635         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9636         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9637         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9638         return (uint64_t)ret_conv;
9639 }
9640
9641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9642         LDKRouteHop o_conv;
9643         o_conv.inner = (void*)(o & (~1));
9644         o_conv.is_owned = (o & 1) || (o == 0);
9645         o_conv = RouteHop_clone(&o_conv);
9646         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9647         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9648         return (uint64_t)ret_conv;
9649 }
9650
9651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9652         LDKDecodeError e_conv;
9653         e_conv.inner = (void*)(e & (~1));
9654         e_conv.is_owned = (e & 1) || (e == 0);
9655         e_conv = DecodeError_clone(&e_conv);
9656         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9657         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9658         return (uint64_t)ret_conv;
9659 }
9660
9661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9662         if ((_res & 1) != 0) return;
9663         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9664         FREE((void*)_res);
9665         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9666 }
9667
9668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9669         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9670         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9671         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9672         return (uint64_t)ret_conv;
9673 }
9674
9675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9676         LDKCVec_RouteHopZ _res_constr;
9677         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9678         if (_res_constr.datalen > 0)
9679                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9680         else
9681                 _res_constr.data = NULL;
9682         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9683         for (size_t k = 0; k < _res_constr.datalen; k++) {
9684                 int64_t _res_conv_10 = _res_vals[k];
9685                 LDKRouteHop _res_conv_10_conv;
9686                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9687                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9688                 _res_constr.data[k] = _res_conv_10_conv;
9689         }
9690         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9691         CVec_RouteHopZ_free(_res_constr);
9692 }
9693
9694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9695         LDKCVec_CVec_RouteHopZZ _res_constr;
9696         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9697         if (_res_constr.datalen > 0)
9698                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9699         else
9700                 _res_constr.data = NULL;
9701         for (size_t m = 0; m < _res_constr.datalen; m++) {
9702                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9703                 LDKCVec_RouteHopZ _res_conv_12_constr;
9704                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9705                 if (_res_conv_12_constr.datalen > 0)
9706                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9707                 else
9708                         _res_conv_12_constr.data = NULL;
9709                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9710                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9711                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9712                         LDKRouteHop _res_conv_12_conv_10_conv;
9713                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9714                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9715                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9716                 }
9717                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9718                 _res_constr.data[m] = _res_conv_12_constr;
9719         }
9720         CVec_CVec_RouteHopZZ_free(_res_constr);
9721 }
9722
9723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9724         LDKRoute o_conv;
9725         o_conv.inner = (void*)(o & (~1));
9726         o_conv.is_owned = (o & 1) || (o == 0);
9727         o_conv = Route_clone(&o_conv);
9728         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9729         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9730         return (uint64_t)ret_conv;
9731 }
9732
9733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9734         LDKDecodeError e_conv;
9735         e_conv.inner = (void*)(e & (~1));
9736         e_conv.is_owned = (e & 1) || (e == 0);
9737         e_conv = DecodeError_clone(&e_conv);
9738         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9739         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9740         return (uint64_t)ret_conv;
9741 }
9742
9743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9744         if ((_res & 1) != 0) return;
9745         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9746         FREE((void*)_res);
9747         CResult_RouteDecodeErrorZ_free(_res_conv);
9748 }
9749
9750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9751         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9752         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9753         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9754         return (uint64_t)ret_conv;
9755 }
9756
9757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9758         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9759         *ret_copy = COption_u64Z_some(o);
9760         uint64_t ret_ref = (uint64_t)ret_copy;
9761         return ret_ref;
9762 }
9763
9764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9765         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9766         *ret_copy = COption_u64Z_none();
9767         uint64_t ret_ref = (uint64_t)ret_copy;
9768         return ret_ref;
9769 }
9770
9771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9772         if ((_res & 1) != 0) return;
9773         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9774         FREE((void*)_res);
9775         COption_u64Z_free(_res_conv);
9776 }
9777
9778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9779         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9780         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9781         *ret_copy = COption_u64Z_clone(orig_conv);
9782         uint64_t ret_ref = (uint64_t)ret_copy;
9783         return ret_ref;
9784 }
9785
9786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9787         LDKCVec_ChannelDetailsZ _res_constr;
9788         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9789         if (_res_constr.datalen > 0)
9790                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9791         else
9792                 _res_constr.data = NULL;
9793         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9794         for (size_t q = 0; q < _res_constr.datalen; q++) {
9795                 int64_t _res_conv_16 = _res_vals[q];
9796                 LDKChannelDetails _res_conv_16_conv;
9797                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9798                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9799                 _res_constr.data[q] = _res_conv_16_conv;
9800         }
9801         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9802         CVec_ChannelDetailsZ_free(_res_constr);
9803 }
9804
9805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9806         LDKCVec_RouteHintZ _res_constr;
9807         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9808         if (_res_constr.datalen > 0)
9809                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9810         else
9811                 _res_constr.data = NULL;
9812         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9813         for (size_t l = 0; l < _res_constr.datalen; l++) {
9814                 int64_t _res_conv_11 = _res_vals[l];
9815                 LDKRouteHint _res_conv_11_conv;
9816                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9817                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9818                 _res_constr.data[l] = _res_conv_11_conv;
9819         }
9820         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9821         CVec_RouteHintZ_free(_res_constr);
9822 }
9823
9824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9825         LDKRoute o_conv;
9826         o_conv.inner = (void*)(o & (~1));
9827         o_conv.is_owned = (o & 1) || (o == 0);
9828         o_conv = Route_clone(&o_conv);
9829         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9830         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9831         return (uint64_t)ret_conv;
9832 }
9833
9834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9835         LDKLightningError e_conv;
9836         e_conv.inner = (void*)(e & (~1));
9837         e_conv.is_owned = (e & 1) || (e == 0);
9838         e_conv = LightningError_clone(&e_conv);
9839         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9840         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9841         return (uint64_t)ret_conv;
9842 }
9843
9844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9845         if ((_res & 1) != 0) return;
9846         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9847         FREE((void*)_res);
9848         CResult_RouteLightningErrorZ_free(_res_conv);
9849 }
9850
9851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9852         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9853         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9854         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9855         return (uint64_t)ret_conv;
9856 }
9857
9858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9859         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9860         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9861         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9862         return (uint64_t)ret_conv;
9863 }
9864
9865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9866         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9867         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9868         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9869         return (uint64_t)ret_conv;
9870 }
9871
9872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9873         if ((_res & 1) != 0) return;
9874         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9875         FREE((void*)_res);
9876         CResult_TxOutAccessErrorZ_free(_res_conv);
9877 }
9878
9879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9880         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9881         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9882         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9883         return (uint64_t)ret_conv;
9884 }
9885
9886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9887         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9888         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9889         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9890         return (uint64_t)ret_ref;
9891 }
9892
9893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9894         LDKTransaction b_ref;
9895         b_ref.datalen = (*env)->GetArrayLength(env, b);
9896         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9897         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9898         b_ref.data_is_owned = true;
9899         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9900         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9901         return (uint64_t)ret_ref;
9902 }
9903
9904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9905         if ((_res & 1) != 0) return;
9906         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9907         FREE((void*)_res);
9908         C2Tuple_usizeTransactionZ_free(_res_conv);
9909 }
9910
9911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9912         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9913         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9914         if (_res_constr.datalen > 0)
9915                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9916         else
9917                 _res_constr.data = NULL;
9918         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9919         for (size_t y = 0; y < _res_constr.datalen; y++) {
9920                 int64_t _res_conv_24 = _res_vals[y];
9921                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9922                 FREE((void*)_res_conv_24);
9923                 _res_constr.data[y] = _res_conv_24_conv;
9924         }
9925         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9926         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9927 }
9928
9929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9930         LDKCVec_TxidZ _res_constr;
9931         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9932         if (_res_constr.datalen > 0)
9933                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9934         else
9935                 _res_constr.data = NULL;
9936         for (size_t i = 0; i < _res_constr.datalen; i++) {
9937                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9938                 LDKThirtyTwoBytes _res_conv_8_ref;
9939                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9940                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9941                 _res_constr.data[i] = _res_conv_8_ref;
9942         }
9943         CVec_TxidZ_free(_res_constr);
9944 }
9945
9946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9947         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9948         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9949         return (uint64_t)ret_conv;
9950 }
9951
9952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9953         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9954         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9955         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9956         return (uint64_t)ret_conv;
9957 }
9958
9959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9960         if ((_res & 1) != 0) return;
9961         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9962         FREE((void*)_res);
9963         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9964 }
9965
9966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9967         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9968         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9969         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9970         return (uint64_t)ret_conv;
9971 }
9972
9973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9974         LDKCVec_MonitorEventZ _res_constr;
9975         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9976         if (_res_constr.datalen > 0)
9977                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9978         else
9979                 _res_constr.data = NULL;
9980         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9981         for (size_t o = 0; o < _res_constr.datalen; o++) {
9982                 int64_t _res_conv_14 = _res_vals[o];
9983                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9984                 FREE((void*)_res_conv_14);
9985                 _res_constr.data[o] = _res_conv_14_conv;
9986         }
9987         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9988         CVec_MonitorEventZ_free(_res_constr);
9989 }
9990
9991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9992         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9993         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9994         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9995         uint64_t ret_ref = (uint64_t)ret_copy;
9996         return ret_ref;
9997 }
9998
9999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
10000         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10001         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
10002         uint64_t ret_ref = (uint64_t)ret_copy;
10003         return ret_ref;
10004 }
10005
10006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10007         if ((_res & 1) != 0) return;
10008         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
10009         FREE((void*)_res);
10010         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
10011 }
10012
10013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10014         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
10015         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10016         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
10017         uint64_t ret_ref = (uint64_t)ret_copy;
10018         return ret_ref;
10019 }
10020
10021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10022         LDKCVec_SpendableOutputDescriptorZ _res_constr;
10023         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10024         if (_res_constr.datalen > 0)
10025                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
10026         else
10027                 _res_constr.data = NULL;
10028         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10029         for (size_t b = 0; b < _res_constr.datalen; b++) {
10030                 int64_t _res_conv_27 = _res_vals[b];
10031                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
10032                 FREE((void*)_res_conv_27);
10033                 _res_constr.data[b] = _res_conv_27_conv;
10034         }
10035         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10036         CVec_SpendableOutputDescriptorZ_free(_res_constr);
10037 }
10038
10039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10040         LDKCVec_MessageSendEventZ _res_constr;
10041         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10042         if (_res_constr.datalen > 0)
10043                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10044         else
10045                 _res_constr.data = NULL;
10046         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10047         for (size_t s = 0; s < _res_constr.datalen; s++) {
10048                 int64_t _res_conv_18 = _res_vals[s];
10049                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
10050                 FREE((void*)_res_conv_18);
10051                 _res_constr.data[s] = _res_conv_18_conv;
10052         }
10053         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10054         CVec_MessageSendEventZ_free(_res_constr);
10055 }
10056
10057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10058         LDKInitFeatures o_conv;
10059         o_conv.inner = (void*)(o & (~1));
10060         o_conv.is_owned = (o & 1) || (o == 0);
10061         o_conv = InitFeatures_clone(&o_conv);
10062         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10063         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
10064         return (uint64_t)ret_conv;
10065 }
10066
10067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10068         LDKDecodeError e_conv;
10069         e_conv.inner = (void*)(e & (~1));
10070         e_conv.is_owned = (e & 1) || (e == 0);
10071         e_conv = DecodeError_clone(&e_conv);
10072         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10073         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
10074         return (uint64_t)ret_conv;
10075 }
10076
10077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10078         if ((_res & 1) != 0) return;
10079         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10080         FREE((void*)_res);
10081         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
10082 }
10083
10084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10085         LDKNodeFeatures o_conv;
10086         o_conv.inner = (void*)(o & (~1));
10087         o_conv.is_owned = (o & 1) || (o == 0);
10088         o_conv = NodeFeatures_clone(&o_conv);
10089         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10090         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
10091         return (uint64_t)ret_conv;
10092 }
10093
10094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10095         LDKDecodeError e_conv;
10096         e_conv.inner = (void*)(e & (~1));
10097         e_conv.is_owned = (e & 1) || (e == 0);
10098         e_conv = DecodeError_clone(&e_conv);
10099         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10100         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
10101         return (uint64_t)ret_conv;
10102 }
10103
10104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10105         if ((_res & 1) != 0) return;
10106         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10107         FREE((void*)_res);
10108         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
10109 }
10110
10111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10112         LDKChannelFeatures o_conv;
10113         o_conv.inner = (void*)(o & (~1));
10114         o_conv.is_owned = (o & 1) || (o == 0);
10115         o_conv = ChannelFeatures_clone(&o_conv);
10116         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10117         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
10118         return (uint64_t)ret_conv;
10119 }
10120
10121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10122         LDKDecodeError e_conv;
10123         e_conv.inner = (void*)(e & (~1));
10124         e_conv.is_owned = (e & 1) || (e == 0);
10125         e_conv = DecodeError_clone(&e_conv);
10126         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10127         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
10128         return (uint64_t)ret_conv;
10129 }
10130
10131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10132         if ((_res & 1) != 0) return;
10133         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10134         FREE((void*)_res);
10135         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
10136 }
10137
10138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10139         LDKInvoiceFeatures o_conv;
10140         o_conv.inner = (void*)(o & (~1));
10141         o_conv.is_owned = (o & 1) || (o == 0);
10142         o_conv = InvoiceFeatures_clone(&o_conv);
10143         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10144         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
10145         return (uint64_t)ret_conv;
10146 }
10147
10148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10149         LDKDecodeError e_conv;
10150         e_conv.inner = (void*)(e & (~1));
10151         e_conv.is_owned = (e & 1) || (e == 0);
10152         e_conv = DecodeError_clone(&e_conv);
10153         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10154         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
10155         return (uint64_t)ret_conv;
10156 }
10157
10158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10159         if ((_res & 1) != 0) return;
10160         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10161         FREE((void*)_res);
10162         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
10163 }
10164
10165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10166         LDKDelayedPaymentOutputDescriptor o_conv;
10167         o_conv.inner = (void*)(o & (~1));
10168         o_conv.is_owned = (o & 1) || (o == 0);
10169         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10170         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10171         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10172         return (uint64_t)ret_conv;
10173 }
10174
10175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10176         LDKDecodeError e_conv;
10177         e_conv.inner = (void*)(e & (~1));
10178         e_conv.is_owned = (e & 1) || (e == 0);
10179         e_conv = DecodeError_clone(&e_conv);
10180         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10181         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10182         return (uint64_t)ret_conv;
10183 }
10184
10185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10186         if ((_res & 1) != 0) return;
10187         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10188         FREE((void*)_res);
10189         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10190 }
10191
10192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10193         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10194         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10195         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10196         return (uint64_t)ret_conv;
10197 }
10198
10199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10200         LDKStaticPaymentOutputDescriptor o_conv;
10201         o_conv.inner = (void*)(o & (~1));
10202         o_conv.is_owned = (o & 1) || (o == 0);
10203         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10204         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10205         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10206         return (uint64_t)ret_conv;
10207 }
10208
10209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10210         LDKDecodeError e_conv;
10211         e_conv.inner = (void*)(e & (~1));
10212         e_conv.is_owned = (e & 1) || (e == 0);
10213         e_conv = DecodeError_clone(&e_conv);
10214         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10215         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10216         return (uint64_t)ret_conv;
10217 }
10218
10219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10220         if ((_res & 1) != 0) return;
10221         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10222         FREE((void*)_res);
10223         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10224 }
10225
10226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10227         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10228         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10229         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10230         return (uint64_t)ret_conv;
10231 }
10232
10233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10234         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
10235         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10236         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10237         return (uint64_t)ret_conv;
10238 }
10239
10240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10241         LDKDecodeError e_conv;
10242         e_conv.inner = (void*)(e & (~1));
10243         e_conv.is_owned = (e & 1) || (e == 0);
10244         e_conv = DecodeError_clone(&e_conv);
10245         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10246         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10247         return (uint64_t)ret_conv;
10248 }
10249
10250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10251         if ((_res & 1) != 0) return;
10252         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10253         FREE((void*)_res);
10254         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10255 }
10256
10257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10258         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10259         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10260         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10261         return (uint64_t)ret_conv;
10262 }
10263
10264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10265         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10266         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10267         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10268         return (uint64_t)ret_ref;
10269 }
10270
10271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
10272         LDKSignature a_ref;
10273         CHECK((*env)->GetArrayLength(env, a) == 64);
10274         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
10275         LDKCVec_SignatureZ b_constr;
10276         b_constr.datalen = (*env)->GetArrayLength(env, b);
10277         if (b_constr.datalen > 0)
10278                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10279         else
10280                 b_constr.data = NULL;
10281         for (size_t i = 0; i < b_constr.datalen; i++) {
10282                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
10283                 LDKSignature b_conv_8_ref;
10284                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
10285                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
10286                 b_constr.data[i] = b_conv_8_ref;
10287         }
10288         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10289         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10290         return (uint64_t)ret_ref;
10291 }
10292
10293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10294         if ((_res & 1) != 0) return;
10295         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
10296         FREE((void*)_res);
10297         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10298 }
10299
10300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10301         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
10302         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10303         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10304         return (uint64_t)ret_conv;
10305 }
10306
10307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
10308         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10309         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10310         return (uint64_t)ret_conv;
10311 }
10312
10313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10314         if ((_res & 1) != 0) return;
10315         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
10316         FREE((void*)_res);
10317         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10318 }
10319
10320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10321         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10322         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10323         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10324         return (uint64_t)ret_conv;
10325 }
10326
10327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10328         LDKSignature o_ref;
10329         CHECK((*env)->GetArrayLength(env, o) == 64);
10330         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
10331         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10332         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10333         return (uint64_t)ret_conv;
10334 }
10335
10336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10337         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10338         *ret_conv = CResult_SignatureNoneZ_err();
10339         return (uint64_t)ret_conv;
10340 }
10341
10342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10343         if ((_res & 1) != 0) return;
10344         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
10345         FREE((void*)_res);
10346         CResult_SignatureNoneZ_free(_res_conv);
10347 }
10348
10349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10350         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10351         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10352         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10353         return (uint64_t)ret_conv;
10354 }
10355
10356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10357         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
10358         if (o_conv.free == LDKSign_JCalls_free) {
10359                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10360                 LDKSign_JCalls_cloned(&o_conv);
10361         }
10362         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10363         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10364         return (uint64_t)ret_conv;
10365 }
10366
10367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10368         LDKDecodeError e_conv;
10369         e_conv.inner = (void*)(e & (~1));
10370         e_conv.is_owned = (e & 1) || (e == 0);
10371         e_conv = DecodeError_clone(&e_conv);
10372         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10373         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10374         return (uint64_t)ret_conv;
10375 }
10376
10377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10378         if ((_res & 1) != 0) return;
10379         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
10380         FREE((void*)_res);
10381         CResult_SignDecodeErrorZ_free(_res_conv);
10382 }
10383
10384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10385         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10386         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10387         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10388         return (uint64_t)ret_conv;
10389 }
10390
10391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10392         LDKCVec_u8Z _res_ref;
10393         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10394         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10395         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10396         CVec_u8Z_free(_res_ref);
10397 }
10398
10399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
10400         LDKRecoverableSignature arg_ref;
10401         CHECK((*env)->GetArrayLength(env, arg) == 68);
10402         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
10403         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10404         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10405         return (uint64_t)ret_conv;
10406 }
10407
10408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10409         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10410         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10411         return (uint64_t)ret_conv;
10412 }
10413
10414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10415         if ((_res & 1) != 0) return;
10416         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
10417         FREE((void*)_res);
10418         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10419 }
10420
10421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10422         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10423         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10424         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10425         return (uint64_t)ret_conv;
10426 }
10427
10428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10429         LDKCVec_CVec_u8ZZ _res_constr;
10430         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10431         if (_res_constr.datalen > 0)
10432                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10433         else
10434                 _res_constr.data = NULL;
10435         for (size_t i = 0; i < _res_constr.datalen; i++) {
10436                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10437                 LDKCVec_u8Z _res_conv_8_ref;
10438                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
10439                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10440                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10441                 _res_constr.data[i] = _res_conv_8_ref;
10442         }
10443         CVec_CVec_u8ZZ_free(_res_constr);
10444 }
10445
10446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10447         LDKCVec_CVec_u8ZZ o_constr;
10448         o_constr.datalen = (*env)->GetArrayLength(env, o);
10449         if (o_constr.datalen > 0)
10450                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10451         else
10452                 o_constr.data = NULL;
10453         for (size_t i = 0; i < o_constr.datalen; i++) {
10454                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10455                 LDKCVec_u8Z o_conv_8_ref;
10456                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10457                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10458                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10459                 o_constr.data[i] = o_conv_8_ref;
10460         }
10461         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10462         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10463         return (uint64_t)ret_conv;
10464 }
10465
10466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10467         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10468         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10469         return (uint64_t)ret_conv;
10470 }
10471
10472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10473         if ((_res & 1) != 0) return;
10474         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10475         FREE((void*)_res);
10476         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10477 }
10478
10479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10480         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10481         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10482         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10483         return (uint64_t)ret_conv;
10484 }
10485
10486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10487         LDKInMemorySigner o_conv;
10488         o_conv.inner = (void*)(o & (~1));
10489         o_conv.is_owned = (o & 1) || (o == 0);
10490         o_conv = InMemorySigner_clone(&o_conv);
10491         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10492         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10493         return (uint64_t)ret_conv;
10494 }
10495
10496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10497         LDKDecodeError e_conv;
10498         e_conv.inner = (void*)(e & (~1));
10499         e_conv.is_owned = (e & 1) || (e == 0);
10500         e_conv = DecodeError_clone(&e_conv);
10501         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10502         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10503         return (uint64_t)ret_conv;
10504 }
10505
10506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10507         if ((_res & 1) != 0) return;
10508         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10509         FREE((void*)_res);
10510         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10511 }
10512
10513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10514         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10515         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10516         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10517         return (uint64_t)ret_conv;
10518 }
10519
10520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10521         LDKCVec_TxOutZ _res_constr;
10522         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10523         if (_res_constr.datalen > 0)
10524                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10525         else
10526                 _res_constr.data = NULL;
10527         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10528         for (size_t h = 0; h < _res_constr.datalen; h++) {
10529                 int64_t _res_conv_7 = _res_vals[h];
10530                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10531                 FREE((void*)_res_conv_7);
10532                 _res_constr.data[h] = _res_conv_7_conv;
10533         }
10534         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10535         CVec_TxOutZ_free(_res_constr);
10536 }
10537
10538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10539         LDKTransaction o_ref;
10540         o_ref.datalen = (*env)->GetArrayLength(env, o);
10541         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10542         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10543         o_ref.data_is_owned = true;
10544         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10545         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10546         return (uint64_t)ret_conv;
10547 }
10548
10549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10550         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10551         *ret_conv = CResult_TransactionNoneZ_err();
10552         return (uint64_t)ret_conv;
10553 }
10554
10555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10556         if ((_res & 1) != 0) return;
10557         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10558         FREE((void*)_res);
10559         CResult_TransactionNoneZ_free(_res_conv);
10560 }
10561
10562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10563         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10564         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10565         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10566         return (uint64_t)ret_conv;
10567 }
10568
10569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10570         LDKThirtyTwoBytes a_ref;
10571         CHECK((*env)->GetArrayLength(env, a) == 32);
10572         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10573         LDKChannelMonitor b_conv;
10574         b_conv.inner = (void*)(b & (~1));
10575         b_conv.is_owned = (b & 1) || (b == 0);
10576         b_conv = ChannelMonitor_clone(&b_conv);
10577         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10578         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10579         return (uint64_t)ret_ref;
10580 }
10581
10582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10583         if ((_res & 1) != 0) return;
10584         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10585         FREE((void*)_res);
10586         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10587 }
10588
10589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10590         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10591         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10592         if (_res_constr.datalen > 0)
10593                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10594         else
10595                 _res_constr.data = NULL;
10596         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10597         for (size_t i = 0; i < _res_constr.datalen; i++) {
10598                 int64_t _res_conv_34 = _res_vals[i];
10599                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10600                 FREE((void*)_res_conv_34);
10601                 _res_constr.data[i] = _res_conv_34_conv;
10602         }
10603         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10604         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10605 }
10606
10607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10608         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10609         o_constr.datalen = (*env)->GetArrayLength(env, o);
10610         if (o_constr.datalen > 0)
10611                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10612         else
10613                 o_constr.data = NULL;
10614         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10615         for (size_t i = 0; i < o_constr.datalen; i++) {
10616                 int64_t o_conv_34 = o_vals[i];
10617                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10618                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10619                 o_constr.data[i] = o_conv_34_conv;
10620         }
10621         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10622         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10623         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10624         return (uint64_t)ret_conv;
10625 }
10626
10627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10628         LDKIOError e_conv = LDKIOError_from_java(env, e);
10629         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10630         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10631         return (uint64_t)ret_conv;
10632 }
10633
10634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10635         if ((_res & 1) != 0) return;
10636         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10637         FREE((void*)_res);
10638         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10639 }
10640
10641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
10642         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10643         *ret_copy = COption_u16Z_some(o);
10644         uint64_t ret_ref = (uint64_t)ret_copy;
10645         return ret_ref;
10646 }
10647
10648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
10649         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10650         *ret_copy = COption_u16Z_none();
10651         uint64_t ret_ref = (uint64_t)ret_copy;
10652         return ret_ref;
10653 }
10654
10655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10656         if ((_res & 1) != 0) return;
10657         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
10658         FREE((void*)_res);
10659         COption_u16Z_free(_res_conv);
10660 }
10661
10662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10663         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10664         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10665         *ret_copy = COption_u16Z_clone(orig_conv);
10666         uint64_t ret_ref = (uint64_t)ret_copy;
10667         return ret_ref;
10668 }
10669
10670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10671         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10672         *ret_conv = CResult_NoneAPIErrorZ_ok();
10673         return (uint64_t)ret_conv;
10674 }
10675
10676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10677         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10678         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10679         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10680         return (uint64_t)ret_conv;
10681 }
10682
10683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10684         if ((_res & 1) != 0) return;
10685         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10686         FREE((void*)_res);
10687         CResult_NoneAPIErrorZ_free(_res_conv);
10688 }
10689
10690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10691         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10692         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10693         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10694         return (uint64_t)ret_conv;
10695 }
10696
10697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10698         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10699         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10700         if (_res_constr.datalen > 0)
10701                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10702         else
10703                 _res_constr.data = NULL;
10704         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10705         for (size_t w = 0; w < _res_constr.datalen; w++) {
10706                 int64_t _res_conv_22 = _res_vals[w];
10707                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10708                 FREE((void*)_res_conv_22);
10709                 _res_constr.data[w] = _res_conv_22_conv;
10710         }
10711         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10712         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10713 }
10714
10715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10716         LDKCVec_APIErrorZ _res_constr;
10717         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10718         if (_res_constr.datalen > 0)
10719                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10720         else
10721                 _res_constr.data = NULL;
10722         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10723         for (size_t k = 0; k < _res_constr.datalen; k++) {
10724                 int64_t _res_conv_10 = _res_vals[k];
10725                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10726                 FREE((void*)_res_conv_10);
10727                 _res_constr.data[k] = _res_conv_10_conv;
10728         }
10729         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10730         CVec_APIErrorZ_free(_res_constr);
10731 }
10732
10733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10734         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10735         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10736         return (uint64_t)ret_conv;
10737 }
10738
10739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10740         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10741         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10742         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10743         return (uint64_t)ret_conv;
10744 }
10745
10746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10747         if ((_res & 1) != 0) return;
10748         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10749         FREE((void*)_res);
10750         CResult_NonePaymentSendFailureZ_free(_res_conv);
10751 }
10752
10753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10754         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10755         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10756         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10757         return (uint64_t)ret_conv;
10758 }
10759
10760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10761         LDKThirtyTwoBytes o_ref;
10762         CHECK((*env)->GetArrayLength(env, o) == 32);
10763         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10764         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10765         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
10766         return (uint64_t)ret_conv;
10767 }
10768
10769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10770         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10771         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10772         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
10773         return (uint64_t)ret_conv;
10774 }
10775
10776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10777         if ((_res & 1) != 0) return;
10778         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10779         FREE((void*)_res);
10780         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
10781 }
10782
10783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10784         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1);
10785         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10786         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
10787         return (uint64_t)ret_conv;
10788 }
10789
10790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10791         LDKCVec_NetAddressZ _res_constr;
10792         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10793         if (_res_constr.datalen > 0)
10794                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10795         else
10796                 _res_constr.data = NULL;
10797         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10798         for (size_t m = 0; m < _res_constr.datalen; m++) {
10799                 int64_t _res_conv_12 = _res_vals[m];
10800                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10801                 FREE((void*)_res_conv_12);
10802                 _res_constr.data[m] = _res_conv_12_conv;
10803         }
10804         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10805         CVec_NetAddressZ_free(_res_constr);
10806 }
10807
10808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10809         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10810         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10811         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10812         return (uint64_t)ret_ref;
10813 }
10814
10815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10816         LDKThirtyTwoBytes a_ref;
10817         CHECK((*env)->GetArrayLength(env, a) == 32);
10818         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10819         LDKThirtyTwoBytes b_ref;
10820         CHECK((*env)->GetArrayLength(env, b) == 32);
10821         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10822         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10823         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10824         return (uint64_t)ret_ref;
10825 }
10826
10827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10828         if ((_res & 1) != 0) return;
10829         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10830         FREE((void*)_res);
10831         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10832 }
10833
10834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10835         LDKThirtyTwoBytes o_ref;
10836         CHECK((*env)->GetArrayLength(env, o) == 32);
10837         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10838         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10839         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10840         return (uint64_t)ret_conv;
10841 }
10842
10843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10844         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10845         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10846         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10847         return (uint64_t)ret_conv;
10848 }
10849
10850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10851         if ((_res & 1) != 0) return;
10852         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10853         FREE((void*)_res);
10854         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10855 }
10856
10857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10858         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10859         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10860         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10861         return (uint64_t)ret_conv;
10862 }
10863
10864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10865         LDKCVec_ChannelMonitorZ _res_constr;
10866         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10867         if (_res_constr.datalen > 0)
10868                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10869         else
10870                 _res_constr.data = NULL;
10871         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10872         for (size_t q = 0; q < _res_constr.datalen; q++) {
10873                 int64_t _res_conv_16 = _res_vals[q];
10874                 LDKChannelMonitor _res_conv_16_conv;
10875                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10876                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10877                 _res_constr.data[q] = _res_conv_16_conv;
10878         }
10879         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10880         CVec_ChannelMonitorZ_free(_res_constr);
10881 }
10882
10883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10884         LDKThirtyTwoBytes a_ref;
10885         CHECK((*env)->GetArrayLength(env, a) == 32);
10886         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10887         LDKChannelManager b_conv;
10888         b_conv.inner = (void*)(b & (~1));
10889         b_conv.is_owned = (b & 1) || (b == 0);
10890         // Warning: we need a move here but no clone is available for LDKChannelManager
10891         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10892         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10893         return (uint64_t)ret_ref;
10894 }
10895
10896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10897         if ((_res & 1) != 0) return;
10898         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10899         FREE((void*)_res);
10900         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10901 }
10902
10903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10904         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10905         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10906         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10907         return (uint64_t)ret_conv;
10908 }
10909
10910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10911         LDKDecodeError e_conv;
10912         e_conv.inner = (void*)(e & (~1));
10913         e_conv.is_owned = (e & 1) || (e == 0);
10914         e_conv = DecodeError_clone(&e_conv);
10915         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10916         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10917         return (uint64_t)ret_conv;
10918 }
10919
10920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10921         if ((_res & 1) != 0) return;
10922         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10923         FREE((void*)_res);
10924         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10925 }
10926
10927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10928         LDKChannelConfig o_conv;
10929         o_conv.inner = (void*)(o & (~1));
10930         o_conv.is_owned = (o & 1) || (o == 0);
10931         o_conv = ChannelConfig_clone(&o_conv);
10932         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10933         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10934         return (uint64_t)ret_conv;
10935 }
10936
10937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10938         LDKDecodeError e_conv;
10939         e_conv.inner = (void*)(e & (~1));
10940         e_conv.is_owned = (e & 1) || (e == 0);
10941         e_conv = DecodeError_clone(&e_conv);
10942         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10943         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10944         return (uint64_t)ret_conv;
10945 }
10946
10947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10948         if ((_res & 1) != 0) return;
10949         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10950         FREE((void*)_res);
10951         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10952 }
10953
10954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10955         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10956         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10957         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10958         return (uint64_t)ret_conv;
10959 }
10960
10961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10962         LDKOutPoint o_conv;
10963         o_conv.inner = (void*)(o & (~1));
10964         o_conv.is_owned = (o & 1) || (o == 0);
10965         o_conv = OutPoint_clone(&o_conv);
10966         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10967         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10968         return (uint64_t)ret_conv;
10969 }
10970
10971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10972         LDKDecodeError e_conv;
10973         e_conv.inner = (void*)(e & (~1));
10974         e_conv.is_owned = (e & 1) || (e == 0);
10975         e_conv = DecodeError_clone(&e_conv);
10976         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10977         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10978         return (uint64_t)ret_conv;
10979 }
10980
10981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10982         if ((_res & 1) != 0) return;
10983         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10984         FREE((void*)_res);
10985         CResult_OutPointDecodeErrorZ_free(_res_conv);
10986 }
10987
10988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10989         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10990         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10991         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10992         return (uint64_t)ret_conv;
10993 }
10994
10995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10996         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10997         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10998         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10999         return (uint64_t)ret_conv;
11000 }
11001
11002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
11003         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11004         *ret_conv = CResult_SiPrefixNoneZ_err();
11005         return (uint64_t)ret_conv;
11006 }
11007
11008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11009         if ((_res & 1) != 0) return;
11010         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
11011         FREE((void*)_res);
11012         CResult_SiPrefixNoneZ_free(_res_conv);
11013 }
11014
11015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11016         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
11017         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11018         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
11019         return (uint64_t)ret_conv;
11020 }
11021
11022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11023         LDKInvoice o_conv;
11024         o_conv.inner = (void*)(o & (~1));
11025         o_conv.is_owned = (o & 1) || (o == 0);
11026         o_conv = Invoice_clone(&o_conv);
11027         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11028         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
11029         return (uint64_t)ret_conv;
11030 }
11031
11032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
11033         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11034         *ret_conv = CResult_InvoiceNoneZ_err();
11035         return (uint64_t)ret_conv;
11036 }
11037
11038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11039         if ((_res & 1) != 0) return;
11040         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
11041         FREE((void*)_res);
11042         CResult_InvoiceNoneZ_free(_res_conv);
11043 }
11044
11045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11046         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
11047         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11048         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
11049         return (uint64_t)ret_conv;
11050 }
11051
11052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11053         LDKSignedRawInvoice o_conv;
11054         o_conv.inner = (void*)(o & (~1));
11055         o_conv.is_owned = (o & 1) || (o == 0);
11056         o_conv = SignedRawInvoice_clone(&o_conv);
11057         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11058         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
11059         return (uint64_t)ret_conv;
11060 }
11061
11062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
11063         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11064         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
11065         return (uint64_t)ret_conv;
11066 }
11067
11068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11069         if ((_res & 1) != 0) return;
11070         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
11071         FREE((void*)_res);
11072         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
11073 }
11074
11075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11076         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
11077         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11078         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
11079         return (uint64_t)ret_conv;
11080 }
11081
11082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11083         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
11084         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11085         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
11086         return (uint64_t)ret_ref;
11087 }
11088
11089 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) {
11090         LDKRawInvoice a_conv;
11091         a_conv.inner = (void*)(a & (~1));
11092         a_conv.is_owned = (a & 1) || (a == 0);
11093         a_conv = RawInvoice_clone(&a_conv);
11094         LDKThirtyTwoBytes b_ref;
11095         CHECK((*env)->GetArrayLength(env, b) == 32);
11096         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
11097         LDKInvoiceSignature c_conv;
11098         c_conv.inner = (void*)(c & (~1));
11099         c_conv.is_owned = (c & 1) || (c == 0);
11100         c_conv = InvoiceSignature_clone(&c_conv);
11101         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11102         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
11103         return (uint64_t)ret_ref;
11104 }
11105
11106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11107         if ((_res & 1) != 0) return;
11108         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
11109         FREE((void*)_res);
11110         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
11111 }
11112
11113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11114         LDKPayeePubKey o_conv;
11115         o_conv.inner = (void*)(o & (~1));
11116         o_conv.is_owned = (o & 1) || (o == 0);
11117         o_conv = PayeePubKey_clone(&o_conv);
11118         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11119         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
11120         return (uint64_t)ret_conv;
11121 }
11122
11123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11124         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11125         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11126         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
11127         return (uint64_t)ret_conv;
11128 }
11129
11130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11131         if ((_res & 1) != 0) return;
11132         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
11133         FREE((void*)_res);
11134         CResult_PayeePubKeyErrorZ_free(_res_conv);
11135 }
11136
11137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11138         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
11139         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11140         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
11141         return (uint64_t)ret_conv;
11142 }
11143
11144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11145         LDKCVec_PrivateRouteZ _res_constr;
11146         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11147         if (_res_constr.datalen > 0)
11148                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
11149         else
11150                 _res_constr.data = NULL;
11151         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11152         for (size_t o = 0; o < _res_constr.datalen; o++) {
11153                 int64_t _res_conv_14 = _res_vals[o];
11154                 LDKPrivateRoute _res_conv_14_conv;
11155                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11156                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11157                 _res_constr.data[o] = _res_conv_14_conv;
11158         }
11159         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11160         CVec_PrivateRouteZ_free(_res_constr);
11161 }
11162
11163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11164         LDKPositiveTimestamp o_conv;
11165         o_conv.inner = (void*)(o & (~1));
11166         o_conv.is_owned = (o & 1) || (o == 0);
11167         o_conv = PositiveTimestamp_clone(&o_conv);
11168         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11169         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
11170         return (uint64_t)ret_conv;
11171 }
11172
11173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11174         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11175         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11176         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
11177         return (uint64_t)ret_conv;
11178 }
11179
11180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11181         if ((_res & 1) != 0) return;
11182         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
11183         FREE((void*)_res);
11184         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
11185 }
11186
11187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11188         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
11189         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11190         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
11191         return (uint64_t)ret_conv;
11192 }
11193
11194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
11195         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11196         *ret_conv = CResult_NoneSemanticErrorZ_ok();
11197         return (uint64_t)ret_conv;
11198 }
11199
11200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11201         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11202         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11203         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11204         return (uint64_t)ret_conv;
11205 }
11206
11207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11208         if ((_res & 1) != 0) return;
11209         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
11210         FREE((void*)_res);
11211         CResult_NoneSemanticErrorZ_free(_res_conv);
11212 }
11213
11214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11215         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11216         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11217         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11218         return (uint64_t)ret_conv;
11219 }
11220
11221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11222         LDKInvoice o_conv;
11223         o_conv.inner = (void*)(o & (~1));
11224         o_conv.is_owned = (o & 1) || (o == 0);
11225         o_conv = Invoice_clone(&o_conv);
11226         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11227         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11228         return (uint64_t)ret_conv;
11229 }
11230
11231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11232         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11233         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11234         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11235         return (uint64_t)ret_conv;
11236 }
11237
11238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11239         if ((_res & 1) != 0) return;
11240         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
11241         FREE((void*)_res);
11242         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11243 }
11244
11245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11246         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11247         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11248         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11249         return (uint64_t)ret_conv;
11250 }
11251
11252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11253         LDKDescription o_conv;
11254         o_conv.inner = (void*)(o & (~1));
11255         o_conv.is_owned = (o & 1) || (o == 0);
11256         o_conv = Description_clone(&o_conv);
11257         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11258         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11259         return (uint64_t)ret_conv;
11260 }
11261
11262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11263         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11264         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11265         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11266         return (uint64_t)ret_conv;
11267 }
11268
11269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11270         if ((_res & 1) != 0) return;
11271         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
11272         FREE((void*)_res);
11273         CResult_DescriptionCreationErrorZ_free(_res_conv);
11274 }
11275
11276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11277         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11278         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11279         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11280         return (uint64_t)ret_conv;
11281 }
11282
11283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11284         LDKExpiryTime o_conv;
11285         o_conv.inner = (void*)(o & (~1));
11286         o_conv.is_owned = (o & 1) || (o == 0);
11287         o_conv = ExpiryTime_clone(&o_conv);
11288         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11289         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11290         return (uint64_t)ret_conv;
11291 }
11292
11293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11294         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11295         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11296         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11297         return (uint64_t)ret_conv;
11298 }
11299
11300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11301         if ((_res & 1) != 0) return;
11302         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
11303         FREE((void*)_res);
11304         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11305 }
11306
11307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11308         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11309         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11310         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11311         return (uint64_t)ret_conv;
11312 }
11313
11314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11315         LDKPrivateRoute o_conv;
11316         o_conv.inner = (void*)(o & (~1));
11317         o_conv.is_owned = (o & 1) || (o == 0);
11318         o_conv = PrivateRoute_clone(&o_conv);
11319         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11320         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11321         return (uint64_t)ret_conv;
11322 }
11323
11324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11325         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11326         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11327         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11328         return (uint64_t)ret_conv;
11329 }
11330
11331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11332         if ((_res & 1) != 0) return;
11333         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
11334         FREE((void*)_res);
11335         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11336 }
11337
11338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11339         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11340         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11341         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11342         return (uint64_t)ret_conv;
11343 }
11344
11345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
11346         LDKStr o_conv = java_to_owned_str(env, o);
11347         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11348         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11349         return (uint64_t)ret_conv;
11350 }
11351
11352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11353         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11354         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11355         *ret_conv = CResult_StringErrorZ_err(e_conv);
11356         return (uint64_t)ret_conv;
11357 }
11358
11359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11360         if ((_res & 1) != 0) return;
11361         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
11362         FREE((void*)_res);
11363         CResult_StringErrorZ_free(_res_conv);
11364 }
11365
11366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11367         LDKChannelMonitorUpdate o_conv;
11368         o_conv.inner = (void*)(o & (~1));
11369         o_conv.is_owned = (o & 1) || (o == 0);
11370         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11371         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11372         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11373         return (uint64_t)ret_conv;
11374 }
11375
11376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11377         LDKDecodeError e_conv;
11378         e_conv.inner = (void*)(e & (~1));
11379         e_conv.is_owned = (e & 1) || (e == 0);
11380         e_conv = DecodeError_clone(&e_conv);
11381         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11382         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11383         return (uint64_t)ret_conv;
11384 }
11385
11386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11387         if ((_res & 1) != 0) return;
11388         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11389         FREE((void*)_res);
11390         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11391 }
11392
11393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11394         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11395         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11396         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11397         return (uint64_t)ret_conv;
11398 }
11399
11400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11401         LDKHTLCUpdate o_conv;
11402         o_conv.inner = (void*)(o & (~1));
11403         o_conv.is_owned = (o & 1) || (o == 0);
11404         o_conv = HTLCUpdate_clone(&o_conv);
11405         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11406         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11407         return (uint64_t)ret_conv;
11408 }
11409
11410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11411         LDKDecodeError e_conv;
11412         e_conv.inner = (void*)(e & (~1));
11413         e_conv.is_owned = (e & 1) || (e == 0);
11414         e_conv = DecodeError_clone(&e_conv);
11415         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11416         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11417         return (uint64_t)ret_conv;
11418 }
11419
11420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11421         if ((_res & 1) != 0) return;
11422         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11423         FREE((void*)_res);
11424         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11425 }
11426
11427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11428         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11429         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11430         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11431         return (uint64_t)ret_conv;
11432 }
11433
11434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
11435         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11436         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11437         return (uint64_t)ret_conv;
11438 }
11439
11440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11441         LDKMonitorUpdateError e_conv;
11442         e_conv.inner = (void*)(e & (~1));
11443         e_conv.is_owned = (e & 1) || (e == 0);
11444         e_conv = MonitorUpdateError_clone(&e_conv);
11445         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11446         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11447         return (uint64_t)ret_conv;
11448 }
11449
11450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11451         if ((_res & 1) != 0) return;
11452         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
11453         FREE((void*)_res);
11454         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11455 }
11456
11457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11458         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11459         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11460         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11461         return (uint64_t)ret_conv;
11462 }
11463
11464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11465         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11466         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11467         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
11468         return (uint64_t)ret_ref;
11469 }
11470
11471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11472         LDKOutPoint a_conv;
11473         a_conv.inner = (void*)(a & (~1));
11474         a_conv.is_owned = (a & 1) || (a == 0);
11475         a_conv = OutPoint_clone(&a_conv);
11476         LDKCVec_u8Z b_ref;
11477         b_ref.datalen = (*env)->GetArrayLength(env, b);
11478         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11479         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11480         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11481         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11482         return (uint64_t)ret_ref;
11483 }
11484
11485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11486         if ((_res & 1) != 0) return;
11487         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
11488         FREE((void*)_res);
11489         C2Tuple_OutPointScriptZ_free(_res_conv);
11490 }
11491
11492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11493         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11494         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11495         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
11496         return (uint64_t)ret_ref;
11497 }
11498
11499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
11500         LDKCVec_u8Z b_ref;
11501         b_ref.datalen = (*env)->GetArrayLength(env, b);
11502         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11503         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11504         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11505         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
11506         return (uint64_t)ret_ref;
11507 }
11508
11509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11510         if ((_res & 1) != 0) return;
11511         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
11512         FREE((void*)_res);
11513         C2Tuple_u32ScriptZ_free(_res_conv);
11514 }
11515
11516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11517         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11518         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11519         if (_res_constr.datalen > 0)
11520                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11521         else
11522                 _res_constr.data = NULL;
11523         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11524         for (size_t b = 0; b < _res_constr.datalen; b++) {
11525                 int64_t _res_conv_27 = _res_vals[b];
11526                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
11527                 FREE((void*)_res_conv_27);
11528                 _res_constr.data[b] = _res_conv_27_conv;
11529         }
11530         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11531         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11532 }
11533
11534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11535         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11536         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11537         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11538         return (uint64_t)ret_ref;
11539 }
11540
11541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11542         LDKThirtyTwoBytes a_ref;
11543         CHECK((*env)->GetArrayLength(env, a) == 32);
11544         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11545         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11546         b_constr.datalen = (*env)->GetArrayLength(env, b);
11547         if (b_constr.datalen > 0)
11548                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11549         else
11550                 b_constr.data = NULL;
11551         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11552         for (size_t b = 0; b < b_constr.datalen; b++) {
11553                 int64_t b_conv_27 = b_vals[b];
11554                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
11555                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
11556                 b_constr.data[b] = b_conv_27_conv;
11557         }
11558         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11559         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11560         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11561         return (uint64_t)ret_ref;
11562 }
11563
11564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11565         if ((_res & 1) != 0) return;
11566         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
11567         FREE((void*)_res);
11568         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11569 }
11570
11571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11572         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11573         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11574         if (_res_constr.datalen > 0)
11575                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11576         else
11577                 _res_constr.data = NULL;
11578         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11579         for (size_t v = 0; v < _res_constr.datalen; v++) {
11580                 int64_t _res_conv_47 = _res_vals[v];
11581                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11582                 FREE((void*)_res_conv_47);
11583                 _res_constr.data[v] = _res_conv_47_conv;
11584         }
11585         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11586         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11587 }
11588
11589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11590         LDKCVec_EventZ _res_constr;
11591         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11592         if (_res_constr.datalen > 0)
11593                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11594         else
11595                 _res_constr.data = NULL;
11596         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11597         for (size_t h = 0; h < _res_constr.datalen; h++) {
11598                 int64_t _res_conv_7 = _res_vals[h];
11599                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11600                 FREE((void*)_res_conv_7);
11601                 _res_constr.data[h] = _res_conv_7_conv;
11602         }
11603         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11604         CVec_EventZ_free(_res_constr);
11605 }
11606
11607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11608         LDKCVec_TransactionZ _res_constr;
11609         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11610         if (_res_constr.datalen > 0)
11611                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11612         else
11613                 _res_constr.data = NULL;
11614         for (size_t i = 0; i < _res_constr.datalen; i++) {
11615                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11616                 LDKTransaction _res_conv_8_ref;
11617                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11618                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11619                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11620                 _res_conv_8_ref.data_is_owned = true;
11621                 _res_constr.data[i] = _res_conv_8_ref;
11622         }
11623         CVec_TransactionZ_free(_res_constr);
11624 }
11625
11626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11627         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11628         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11629         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11630         return (uint64_t)ret_ref;
11631 }
11632
11633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11634         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11635         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11636         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11637         return (uint64_t)ret_ref;
11638 }
11639
11640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11641         if ((_res & 1) != 0) return;
11642         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11643         FREE((void*)_res);
11644         C2Tuple_u32TxOutZ_free(_res_conv);
11645 }
11646
11647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11648         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11649         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11650         if (_res_constr.datalen > 0)
11651                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11652         else
11653                 _res_constr.data = NULL;
11654         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11655         for (size_t a = 0; a < _res_constr.datalen; a++) {
11656                 int64_t _res_conv_26 = _res_vals[a];
11657                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11658                 FREE((void*)_res_conv_26);
11659                 _res_constr.data[a] = _res_conv_26_conv;
11660         }
11661         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11662         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11663 }
11664
11665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11666         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11667         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11668         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11669         return (uint64_t)ret_ref;
11670 }
11671
11672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11673         LDKThirtyTwoBytes a_ref;
11674         CHECK((*env)->GetArrayLength(env, a) == 32);
11675         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11676         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11677         b_constr.datalen = (*env)->GetArrayLength(env, b);
11678         if (b_constr.datalen > 0)
11679                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11680         else
11681                 b_constr.data = NULL;
11682         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11683         for (size_t a = 0; a < b_constr.datalen; a++) {
11684                 int64_t b_conv_26 = b_vals[a];
11685                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11686                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11687                 b_constr.data[a] = b_conv_26_conv;
11688         }
11689         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11690         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11691         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11692         return (uint64_t)ret_ref;
11693 }
11694
11695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11696         if ((_res & 1) != 0) return;
11697         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11698         FREE((void*)_res);
11699         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11700 }
11701
11702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11703         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11704         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11705         if (_res_constr.datalen > 0)
11706                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11707         else
11708                 _res_constr.data = NULL;
11709         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11710         for (size_t u = 0; u < _res_constr.datalen; u++) {
11711                 int64_t _res_conv_46 = _res_vals[u];
11712                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11713                 FREE((void*)_res_conv_46);
11714                 _res_constr.data[u] = _res_conv_46_conv;
11715         }
11716         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11717         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11718 }
11719
11720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11721         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11722         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11723         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11724         return (uint64_t)ret_conv;
11725 }
11726
11727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11728         LDKDecodeError e_conv;
11729         e_conv.inner = (void*)(e & (~1));
11730         e_conv.is_owned = (e & 1) || (e == 0);
11731         e_conv = DecodeError_clone(&e_conv);
11732         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11733         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11734         return (uint64_t)ret_conv;
11735 }
11736
11737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11738         if ((_res & 1) != 0) return;
11739         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11740         FREE((void*)_res);
11741         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11742 }
11743
11744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11745         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11746         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11747         return (uint64_t)ret_conv;
11748 }
11749
11750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11751         LDKLightningError e_conv;
11752         e_conv.inner = (void*)(e & (~1));
11753         e_conv.is_owned = (e & 1) || (e == 0);
11754         e_conv = LightningError_clone(&e_conv);
11755         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11756         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11757         return (uint64_t)ret_conv;
11758 }
11759
11760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11761         if ((_res & 1) != 0) return;
11762         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11763         FREE((void*)_res);
11764         CResult_boolLightningErrorZ_free(_res_conv);
11765 }
11766
11767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11768         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11769         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11770         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11771         return (uint64_t)ret_conv;
11772 }
11773
11774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11775         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11776         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11777         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11778         return (uint64_t)ret_ref;
11779 }
11780
11781 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) {
11782         LDKChannelAnnouncement a_conv;
11783         a_conv.inner = (void*)(a & (~1));
11784         a_conv.is_owned = (a & 1) || (a == 0);
11785         a_conv = ChannelAnnouncement_clone(&a_conv);
11786         LDKChannelUpdate b_conv;
11787         b_conv.inner = (void*)(b & (~1));
11788         b_conv.is_owned = (b & 1) || (b == 0);
11789         b_conv = ChannelUpdate_clone(&b_conv);
11790         LDKChannelUpdate c_conv;
11791         c_conv.inner = (void*)(c & (~1));
11792         c_conv.is_owned = (c & 1) || (c == 0);
11793         c_conv = ChannelUpdate_clone(&c_conv);
11794         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11795         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11796         return (uint64_t)ret_ref;
11797 }
11798
11799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11800         if ((_res & 1) != 0) return;
11801         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11802         FREE((void*)_res);
11803         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11804 }
11805
11806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11807         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11808         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11809         if (_res_constr.datalen > 0)
11810                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11811         else
11812                 _res_constr.data = NULL;
11813         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11814         for (size_t l = 0; l < _res_constr.datalen; l++) {
11815                 int64_t _res_conv_63 = _res_vals[l];
11816                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11817                 FREE((void*)_res_conv_63);
11818                 _res_constr.data[l] = _res_conv_63_conv;
11819         }
11820         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11821         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11822 }
11823
11824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11825         LDKCVec_NodeAnnouncementZ _res_constr;
11826         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11827         if (_res_constr.datalen > 0)
11828                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11829         else
11830                 _res_constr.data = NULL;
11831         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11832         for (size_t s = 0; s < _res_constr.datalen; s++) {
11833                 int64_t _res_conv_18 = _res_vals[s];
11834                 LDKNodeAnnouncement _res_conv_18_conv;
11835                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11836                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11837                 _res_constr.data[s] = _res_conv_18_conv;
11838         }
11839         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11840         CVec_NodeAnnouncementZ_free(_res_constr);
11841 }
11842
11843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11844         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11845         *ret_conv = CResult_NoneLightningErrorZ_ok();
11846         return (uint64_t)ret_conv;
11847 }
11848
11849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11850         LDKLightningError e_conv;
11851         e_conv.inner = (void*)(e & (~1));
11852         e_conv.is_owned = (e & 1) || (e == 0);
11853         e_conv = LightningError_clone(&e_conv);
11854         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11855         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11856         return (uint64_t)ret_conv;
11857 }
11858
11859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11860         if ((_res & 1) != 0) return;
11861         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11862         FREE((void*)_res);
11863         CResult_NoneLightningErrorZ_free(_res_conv);
11864 }
11865
11866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11867         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11868         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11869         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11870         return (uint64_t)ret_conv;
11871 }
11872
11873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11874         LDKCVec_PublicKeyZ _res_constr;
11875         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11876         if (_res_constr.datalen > 0)
11877                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11878         else
11879                 _res_constr.data = NULL;
11880         for (size_t i = 0; i < _res_constr.datalen; i++) {
11881                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11882                 LDKPublicKey _res_conv_8_ref;
11883                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11884                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11885                 _res_constr.data[i] = _res_conv_8_ref;
11886         }
11887         CVec_PublicKeyZ_free(_res_constr);
11888 }
11889
11890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11891         LDKCVec_u8Z o_ref;
11892         o_ref.datalen = (*env)->GetArrayLength(env, o);
11893         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11894         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11895         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11896         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11897         return (uint64_t)ret_conv;
11898 }
11899
11900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11901         LDKPeerHandleError e_conv;
11902         e_conv.inner = (void*)(e & (~1));
11903         e_conv.is_owned = (e & 1) || (e == 0);
11904         e_conv = PeerHandleError_clone(&e_conv);
11905         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11906         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11907         return (uint64_t)ret_conv;
11908 }
11909
11910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11911         if ((_res & 1) != 0) return;
11912         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11913         FREE((void*)_res);
11914         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11915 }
11916
11917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11918         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11919         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11920         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11921         return (uint64_t)ret_conv;
11922 }
11923
11924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11925         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11926         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11927         return (uint64_t)ret_conv;
11928 }
11929
11930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11931         LDKPeerHandleError e_conv;
11932         e_conv.inner = (void*)(e & (~1));
11933         e_conv.is_owned = (e & 1) || (e == 0);
11934         e_conv = PeerHandleError_clone(&e_conv);
11935         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11936         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11937         return (uint64_t)ret_conv;
11938 }
11939
11940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11941         if ((_res & 1) != 0) return;
11942         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11943         FREE((void*)_res);
11944         CResult_NonePeerHandleErrorZ_free(_res_conv);
11945 }
11946
11947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11948         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11949         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11950         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11951         return (uint64_t)ret_conv;
11952 }
11953
11954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11955         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11956         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11957         return (uint64_t)ret_conv;
11958 }
11959
11960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11961         LDKPeerHandleError e_conv;
11962         e_conv.inner = (void*)(e & (~1));
11963         e_conv.is_owned = (e & 1) || (e == 0);
11964         e_conv = PeerHandleError_clone(&e_conv);
11965         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11966         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11967         return (uint64_t)ret_conv;
11968 }
11969
11970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11971         if ((_res & 1) != 0) return;
11972         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11973         FREE((void*)_res);
11974         CResult_boolPeerHandleErrorZ_free(_res_conv);
11975 }
11976
11977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11978         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11979         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11980         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11981         return (uint64_t)ret_conv;
11982 }
11983
11984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11985         LDKDirectionalChannelInfo o_conv;
11986         o_conv.inner = (void*)(o & (~1));
11987         o_conv.is_owned = (o & 1) || (o == 0);
11988         o_conv = DirectionalChannelInfo_clone(&o_conv);
11989         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11990         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11991         return (uint64_t)ret_conv;
11992 }
11993
11994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11995         LDKDecodeError e_conv;
11996         e_conv.inner = (void*)(e & (~1));
11997         e_conv.is_owned = (e & 1) || (e == 0);
11998         e_conv = DecodeError_clone(&e_conv);
11999         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12000         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
12001         return (uint64_t)ret_conv;
12002 }
12003
12004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12005         if ((_res & 1) != 0) return;
12006         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12007         FREE((void*)_res);
12008         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
12009 }
12010
12011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12012         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
12013         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12014         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
12015         return (uint64_t)ret_conv;
12016 }
12017
12018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12019         LDKChannelInfo o_conv;
12020         o_conv.inner = (void*)(o & (~1));
12021         o_conv.is_owned = (o & 1) || (o == 0);
12022         o_conv = ChannelInfo_clone(&o_conv);
12023         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12024         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
12025         return (uint64_t)ret_conv;
12026 }
12027
12028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12029         LDKDecodeError e_conv;
12030         e_conv.inner = (void*)(e & (~1));
12031         e_conv.is_owned = (e & 1) || (e == 0);
12032         e_conv = DecodeError_clone(&e_conv);
12033         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12034         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
12035         return (uint64_t)ret_conv;
12036 }
12037
12038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12039         if ((_res & 1) != 0) return;
12040         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12041         FREE((void*)_res);
12042         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
12043 }
12044
12045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12046         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
12047         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12048         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
12049         return (uint64_t)ret_conv;
12050 }
12051
12052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12053         LDKRoutingFees o_conv;
12054         o_conv.inner = (void*)(o & (~1));
12055         o_conv.is_owned = (o & 1) || (o == 0);
12056         o_conv = RoutingFees_clone(&o_conv);
12057         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12058         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
12059         return (uint64_t)ret_conv;
12060 }
12061
12062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12063         LDKDecodeError e_conv;
12064         e_conv.inner = (void*)(e & (~1));
12065         e_conv.is_owned = (e & 1) || (e == 0);
12066         e_conv = DecodeError_clone(&e_conv);
12067         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12068         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
12069         return (uint64_t)ret_conv;
12070 }
12071
12072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12073         if ((_res & 1) != 0) return;
12074         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12075         FREE((void*)_res);
12076         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
12077 }
12078
12079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12080         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
12081         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12082         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
12083         return (uint64_t)ret_conv;
12084 }
12085
12086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12087         LDKNodeAnnouncementInfo o_conv;
12088         o_conv.inner = (void*)(o & (~1));
12089         o_conv.is_owned = (o & 1) || (o == 0);
12090         o_conv = NodeAnnouncementInfo_clone(&o_conv);
12091         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12092         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
12093         return (uint64_t)ret_conv;
12094 }
12095
12096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12097         LDKDecodeError e_conv;
12098         e_conv.inner = (void*)(e & (~1));
12099         e_conv.is_owned = (e & 1) || (e == 0);
12100         e_conv = DecodeError_clone(&e_conv);
12101         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12102         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
12103         return (uint64_t)ret_conv;
12104 }
12105
12106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12107         if ((_res & 1) != 0) return;
12108         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12109         FREE((void*)_res);
12110         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
12111 }
12112
12113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12114         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
12115         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12116         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
12117         return (uint64_t)ret_conv;
12118 }
12119
12120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12121         LDKCVec_u64Z _res_constr;
12122         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12123         if (_res_constr.datalen > 0)
12124                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12125         else
12126                 _res_constr.data = NULL;
12127         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12128         for (size_t g = 0; g < _res_constr.datalen; g++) {
12129                 int64_t _res_conv_6 = _res_vals[g];
12130                 _res_constr.data[g] = _res_conv_6;
12131         }
12132         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12133         CVec_u64Z_free(_res_constr);
12134 }
12135
12136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12137         LDKNodeInfo o_conv;
12138         o_conv.inner = (void*)(o & (~1));
12139         o_conv.is_owned = (o & 1) || (o == 0);
12140         o_conv = NodeInfo_clone(&o_conv);
12141         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12142         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
12143         return (uint64_t)ret_conv;
12144 }
12145
12146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12147         LDKDecodeError e_conv;
12148         e_conv.inner = (void*)(e & (~1));
12149         e_conv.is_owned = (e & 1) || (e == 0);
12150         e_conv = DecodeError_clone(&e_conv);
12151         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12152         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
12153         return (uint64_t)ret_conv;
12154 }
12155
12156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12157         if ((_res & 1) != 0) return;
12158         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12159         FREE((void*)_res);
12160         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
12161 }
12162
12163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12164         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
12165         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12166         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
12167         return (uint64_t)ret_conv;
12168 }
12169
12170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12171         LDKNetworkGraph o_conv;
12172         o_conv.inner = (void*)(o & (~1));
12173         o_conv.is_owned = (o & 1) || (o == 0);
12174         o_conv = NetworkGraph_clone(&o_conv);
12175         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12176         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12177         return (uint64_t)ret_conv;
12178 }
12179
12180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12181         LDKDecodeError e_conv;
12182         e_conv.inner = (void*)(e & (~1));
12183         e_conv.is_owned = (e & 1) || (e == 0);
12184         e_conv = DecodeError_clone(&e_conv);
12185         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12186         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12187         return (uint64_t)ret_conv;
12188 }
12189
12190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12191         if ((_res & 1) != 0) return;
12192         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
12193         FREE((void*)_res);
12194         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12195 }
12196
12197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12198         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12199         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12200         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12201         return (uint64_t)ret_conv;
12202 }
12203
12204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
12205         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12206         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12207         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
12208         return (uint64_t)ret_conv;
12209 }
12210
12211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
12212         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12213         *ret_conv = CResult_NetAddressu8Z_err(e);
12214         return (uint64_t)ret_conv;
12215 }
12216
12217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12218         if ((_res & 1) != 0) return;
12219         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
12220         FREE((void*)_res);
12221         CResult_NetAddressu8Z_free(_res_conv);
12222 }
12223
12224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12225         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
12226         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12227         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
12228         return (uint64_t)ret_conv;
12229 }
12230
12231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12232         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
12233         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12234         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
12235         return (uint64_t)ret_conv;
12236 }
12237
12238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12239         LDKDecodeError e_conv;
12240         e_conv.inner = (void*)(e & (~1));
12241         e_conv.is_owned = (e & 1) || (e == 0);
12242         e_conv = DecodeError_clone(&e_conv);
12243         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12244         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
12245         return (uint64_t)ret_conv;
12246 }
12247
12248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12249         if ((_res & 1) != 0) return;
12250         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12251         FREE((void*)_res);
12252         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
12253 }
12254
12255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12256         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
12257         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12258         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
12259         return (uint64_t)ret_conv;
12260 }
12261
12262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12263         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12264         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12265         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12266         return (uint64_t)ret_conv;
12267 }
12268
12269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12270         LDKDecodeError e_conv;
12271         e_conv.inner = (void*)(e & (~1));
12272         e_conv.is_owned = (e & 1) || (e == 0);
12273         e_conv = DecodeError_clone(&e_conv);
12274         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12275         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12276         return (uint64_t)ret_conv;
12277 }
12278
12279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12280         if ((_res & 1) != 0) return;
12281         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
12282         FREE((void*)_res);
12283         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12284 }
12285
12286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12287         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12288         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12289         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12290         return (uint64_t)ret_conv;
12291 }
12292
12293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12294         LDKCVec_UpdateAddHTLCZ _res_constr;
12295         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12296         if (_res_constr.datalen > 0)
12297                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12298         else
12299                 _res_constr.data = NULL;
12300         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12301         for (size_t p = 0; p < _res_constr.datalen; p++) {
12302                 int64_t _res_conv_15 = _res_vals[p];
12303                 LDKUpdateAddHTLC _res_conv_15_conv;
12304                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12305                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12306                 _res_constr.data[p] = _res_conv_15_conv;
12307         }
12308         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12309         CVec_UpdateAddHTLCZ_free(_res_constr);
12310 }
12311
12312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12313         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12314         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12315         if (_res_constr.datalen > 0)
12316                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12317         else
12318                 _res_constr.data = NULL;
12319         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12320         for (size_t t = 0; t < _res_constr.datalen; t++) {
12321                 int64_t _res_conv_19 = _res_vals[t];
12322                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12323                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12324                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12325                 _res_constr.data[t] = _res_conv_19_conv;
12326         }
12327         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12328         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12329 }
12330
12331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12332         LDKCVec_UpdateFailHTLCZ _res_constr;
12333         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12334         if (_res_constr.datalen > 0)
12335                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12336         else
12337                 _res_constr.data = NULL;
12338         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12339         for (size_t q = 0; q < _res_constr.datalen; q++) {
12340                 int64_t _res_conv_16 = _res_vals[q];
12341                 LDKUpdateFailHTLC _res_conv_16_conv;
12342                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12343                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12344                 _res_constr.data[q] = _res_conv_16_conv;
12345         }
12346         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12347         CVec_UpdateFailHTLCZ_free(_res_constr);
12348 }
12349
12350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12351         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12352         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12353         if (_res_constr.datalen > 0)
12354                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12355         else
12356                 _res_constr.data = NULL;
12357         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12358         for (size_t z = 0; z < _res_constr.datalen; z++) {
12359                 int64_t _res_conv_25 = _res_vals[z];
12360                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12361                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12362                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12363                 _res_constr.data[z] = _res_conv_25_conv;
12364         }
12365         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12366         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12367 }
12368
12369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12370         LDKAcceptChannel o_conv;
12371         o_conv.inner = (void*)(o & (~1));
12372         o_conv.is_owned = (o & 1) || (o == 0);
12373         o_conv = AcceptChannel_clone(&o_conv);
12374         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12375         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12376         return (uint64_t)ret_conv;
12377 }
12378
12379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12380         LDKDecodeError e_conv;
12381         e_conv.inner = (void*)(e & (~1));
12382         e_conv.is_owned = (e & 1) || (e == 0);
12383         e_conv = DecodeError_clone(&e_conv);
12384         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12385         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12386         return (uint64_t)ret_conv;
12387 }
12388
12389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12390         if ((_res & 1) != 0) return;
12391         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12392         FREE((void*)_res);
12393         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12394 }
12395
12396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12397         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12398         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12399         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12400         return (uint64_t)ret_conv;
12401 }
12402
12403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12404         LDKAnnouncementSignatures o_conv;
12405         o_conv.inner = (void*)(o & (~1));
12406         o_conv.is_owned = (o & 1) || (o == 0);
12407         o_conv = AnnouncementSignatures_clone(&o_conv);
12408         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12409         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12410         return (uint64_t)ret_conv;
12411 }
12412
12413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12414         LDKDecodeError e_conv;
12415         e_conv.inner = (void*)(e & (~1));
12416         e_conv.is_owned = (e & 1) || (e == 0);
12417         e_conv = DecodeError_clone(&e_conv);
12418         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12419         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12420         return (uint64_t)ret_conv;
12421 }
12422
12423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12424         if ((_res & 1) != 0) return;
12425         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12426         FREE((void*)_res);
12427         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12428 }
12429
12430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12431         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12432         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12433         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12434         return (uint64_t)ret_conv;
12435 }
12436
12437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12438         LDKChannelReestablish o_conv;
12439         o_conv.inner = (void*)(o & (~1));
12440         o_conv.is_owned = (o & 1) || (o == 0);
12441         o_conv = ChannelReestablish_clone(&o_conv);
12442         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12443         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12444         return (uint64_t)ret_conv;
12445 }
12446
12447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12448         LDKDecodeError e_conv;
12449         e_conv.inner = (void*)(e & (~1));
12450         e_conv.is_owned = (e & 1) || (e == 0);
12451         e_conv = DecodeError_clone(&e_conv);
12452         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12453         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12454         return (uint64_t)ret_conv;
12455 }
12456
12457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12458         if ((_res & 1) != 0) return;
12459         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
12460         FREE((void*)_res);
12461         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12462 }
12463
12464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12465         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12466         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12467         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12468         return (uint64_t)ret_conv;
12469 }
12470
12471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12472         LDKClosingSigned o_conv;
12473         o_conv.inner = (void*)(o & (~1));
12474         o_conv.is_owned = (o & 1) || (o == 0);
12475         o_conv = ClosingSigned_clone(&o_conv);
12476         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12477         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12478         return (uint64_t)ret_conv;
12479 }
12480
12481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12482         LDKDecodeError e_conv;
12483         e_conv.inner = (void*)(e & (~1));
12484         e_conv.is_owned = (e & 1) || (e == 0);
12485         e_conv = DecodeError_clone(&e_conv);
12486         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12487         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12488         return (uint64_t)ret_conv;
12489 }
12490
12491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12492         if ((_res & 1) != 0) return;
12493         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12494         FREE((void*)_res);
12495         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12496 }
12497
12498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12499         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12500         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12501         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12502         return (uint64_t)ret_conv;
12503 }
12504
12505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12506         LDKCommitmentSigned o_conv;
12507         o_conv.inner = (void*)(o & (~1));
12508         o_conv.is_owned = (o & 1) || (o == 0);
12509         o_conv = CommitmentSigned_clone(&o_conv);
12510         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12511         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12512         return (uint64_t)ret_conv;
12513 }
12514
12515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12516         LDKDecodeError e_conv;
12517         e_conv.inner = (void*)(e & (~1));
12518         e_conv.is_owned = (e & 1) || (e == 0);
12519         e_conv = DecodeError_clone(&e_conv);
12520         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12521         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12522         return (uint64_t)ret_conv;
12523 }
12524
12525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12526         if ((_res & 1) != 0) return;
12527         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12528         FREE((void*)_res);
12529         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12530 }
12531
12532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12533         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12534         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12535         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12536         return (uint64_t)ret_conv;
12537 }
12538
12539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12540         LDKFundingCreated o_conv;
12541         o_conv.inner = (void*)(o & (~1));
12542         o_conv.is_owned = (o & 1) || (o == 0);
12543         o_conv = FundingCreated_clone(&o_conv);
12544         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12545         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12546         return (uint64_t)ret_conv;
12547 }
12548
12549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12550         LDKDecodeError e_conv;
12551         e_conv.inner = (void*)(e & (~1));
12552         e_conv.is_owned = (e & 1) || (e == 0);
12553         e_conv = DecodeError_clone(&e_conv);
12554         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12555         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12556         return (uint64_t)ret_conv;
12557 }
12558
12559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12560         if ((_res & 1) != 0) return;
12561         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12562         FREE((void*)_res);
12563         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12564 }
12565
12566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12567         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12568         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12569         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12570         return (uint64_t)ret_conv;
12571 }
12572
12573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12574         LDKFundingSigned o_conv;
12575         o_conv.inner = (void*)(o & (~1));
12576         o_conv.is_owned = (o & 1) || (o == 0);
12577         o_conv = FundingSigned_clone(&o_conv);
12578         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12579         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12580         return (uint64_t)ret_conv;
12581 }
12582
12583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12584         LDKDecodeError e_conv;
12585         e_conv.inner = (void*)(e & (~1));
12586         e_conv.is_owned = (e & 1) || (e == 0);
12587         e_conv = DecodeError_clone(&e_conv);
12588         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12589         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12590         return (uint64_t)ret_conv;
12591 }
12592
12593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12594         if ((_res & 1) != 0) return;
12595         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12596         FREE((void*)_res);
12597         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12598 }
12599
12600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12601         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12602         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12603         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12604         return (uint64_t)ret_conv;
12605 }
12606
12607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12608         LDKFundingLocked o_conv;
12609         o_conv.inner = (void*)(o & (~1));
12610         o_conv.is_owned = (o & 1) || (o == 0);
12611         o_conv = FundingLocked_clone(&o_conv);
12612         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12613         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12614         return (uint64_t)ret_conv;
12615 }
12616
12617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12618         LDKDecodeError e_conv;
12619         e_conv.inner = (void*)(e & (~1));
12620         e_conv.is_owned = (e & 1) || (e == 0);
12621         e_conv = DecodeError_clone(&e_conv);
12622         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12623         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12624         return (uint64_t)ret_conv;
12625 }
12626
12627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12628         if ((_res & 1) != 0) return;
12629         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12630         FREE((void*)_res);
12631         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12632 }
12633
12634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12635         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12636         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12637         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12638         return (uint64_t)ret_conv;
12639 }
12640
12641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12642         LDKInit o_conv;
12643         o_conv.inner = (void*)(o & (~1));
12644         o_conv.is_owned = (o & 1) || (o == 0);
12645         o_conv = Init_clone(&o_conv);
12646         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12647         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12648         return (uint64_t)ret_conv;
12649 }
12650
12651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12652         LDKDecodeError e_conv;
12653         e_conv.inner = (void*)(e & (~1));
12654         e_conv.is_owned = (e & 1) || (e == 0);
12655         e_conv = DecodeError_clone(&e_conv);
12656         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12657         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12658         return (uint64_t)ret_conv;
12659 }
12660
12661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12662         if ((_res & 1) != 0) return;
12663         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12664         FREE((void*)_res);
12665         CResult_InitDecodeErrorZ_free(_res_conv);
12666 }
12667
12668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12669         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12670         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12671         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12672         return (uint64_t)ret_conv;
12673 }
12674
12675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12676         LDKOpenChannel o_conv;
12677         o_conv.inner = (void*)(o & (~1));
12678         o_conv.is_owned = (o & 1) || (o == 0);
12679         o_conv = OpenChannel_clone(&o_conv);
12680         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12681         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12682         return (uint64_t)ret_conv;
12683 }
12684
12685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12686         LDKDecodeError e_conv;
12687         e_conv.inner = (void*)(e & (~1));
12688         e_conv.is_owned = (e & 1) || (e == 0);
12689         e_conv = DecodeError_clone(&e_conv);
12690         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12691         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12692         return (uint64_t)ret_conv;
12693 }
12694
12695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12696         if ((_res & 1) != 0) return;
12697         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12698         FREE((void*)_res);
12699         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12700 }
12701
12702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12703         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12704         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12705         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12706         return (uint64_t)ret_conv;
12707 }
12708
12709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12710         LDKRevokeAndACK o_conv;
12711         o_conv.inner = (void*)(o & (~1));
12712         o_conv.is_owned = (o & 1) || (o == 0);
12713         o_conv = RevokeAndACK_clone(&o_conv);
12714         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12715         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12716         return (uint64_t)ret_conv;
12717 }
12718
12719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12720         LDKDecodeError e_conv;
12721         e_conv.inner = (void*)(e & (~1));
12722         e_conv.is_owned = (e & 1) || (e == 0);
12723         e_conv = DecodeError_clone(&e_conv);
12724         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12725         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12726         return (uint64_t)ret_conv;
12727 }
12728
12729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12730         if ((_res & 1) != 0) return;
12731         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12732         FREE((void*)_res);
12733         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12734 }
12735
12736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12737         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12738         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12739         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12740         return (uint64_t)ret_conv;
12741 }
12742
12743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12744         LDKShutdown o_conv;
12745         o_conv.inner = (void*)(o & (~1));
12746         o_conv.is_owned = (o & 1) || (o == 0);
12747         o_conv = Shutdown_clone(&o_conv);
12748         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12749         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12750         return (uint64_t)ret_conv;
12751 }
12752
12753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12754         LDKDecodeError e_conv;
12755         e_conv.inner = (void*)(e & (~1));
12756         e_conv.is_owned = (e & 1) || (e == 0);
12757         e_conv = DecodeError_clone(&e_conv);
12758         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12759         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12760         return (uint64_t)ret_conv;
12761 }
12762
12763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12764         if ((_res & 1) != 0) return;
12765         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12766         FREE((void*)_res);
12767         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12768 }
12769
12770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12771         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12772         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12773         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12774         return (uint64_t)ret_conv;
12775 }
12776
12777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12778         LDKUpdateFailHTLC o_conv;
12779         o_conv.inner = (void*)(o & (~1));
12780         o_conv.is_owned = (o & 1) || (o == 0);
12781         o_conv = UpdateFailHTLC_clone(&o_conv);
12782         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12783         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12784         return (uint64_t)ret_conv;
12785 }
12786
12787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12788         LDKDecodeError e_conv;
12789         e_conv.inner = (void*)(e & (~1));
12790         e_conv.is_owned = (e & 1) || (e == 0);
12791         e_conv = DecodeError_clone(&e_conv);
12792         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12793         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12794         return (uint64_t)ret_conv;
12795 }
12796
12797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12798         if ((_res & 1) != 0) return;
12799         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12800         FREE((void*)_res);
12801         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12802 }
12803
12804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12805         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12806         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12807         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12808         return (uint64_t)ret_conv;
12809 }
12810
12811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12812         LDKUpdateFailMalformedHTLC o_conv;
12813         o_conv.inner = (void*)(o & (~1));
12814         o_conv.is_owned = (o & 1) || (o == 0);
12815         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12816         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12817         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12818         return (uint64_t)ret_conv;
12819 }
12820
12821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12822         LDKDecodeError e_conv;
12823         e_conv.inner = (void*)(e & (~1));
12824         e_conv.is_owned = (e & 1) || (e == 0);
12825         e_conv = DecodeError_clone(&e_conv);
12826         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12827         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12828         return (uint64_t)ret_conv;
12829 }
12830
12831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12832         if ((_res & 1) != 0) return;
12833         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12834         FREE((void*)_res);
12835         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12836 }
12837
12838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12839         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12840         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12841         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12842         return (uint64_t)ret_conv;
12843 }
12844
12845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12846         LDKUpdateFee o_conv;
12847         o_conv.inner = (void*)(o & (~1));
12848         o_conv.is_owned = (o & 1) || (o == 0);
12849         o_conv = UpdateFee_clone(&o_conv);
12850         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12851         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12852         return (uint64_t)ret_conv;
12853 }
12854
12855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12856         LDKDecodeError e_conv;
12857         e_conv.inner = (void*)(e & (~1));
12858         e_conv.is_owned = (e & 1) || (e == 0);
12859         e_conv = DecodeError_clone(&e_conv);
12860         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12861         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12862         return (uint64_t)ret_conv;
12863 }
12864
12865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12866         if ((_res & 1) != 0) return;
12867         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12868         FREE((void*)_res);
12869         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12870 }
12871
12872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12873         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12874         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12875         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12876         return (uint64_t)ret_conv;
12877 }
12878
12879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12880         LDKUpdateFulfillHTLC o_conv;
12881         o_conv.inner = (void*)(o & (~1));
12882         o_conv.is_owned = (o & 1) || (o == 0);
12883         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12884         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12885         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12886         return (uint64_t)ret_conv;
12887 }
12888
12889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12890         LDKDecodeError e_conv;
12891         e_conv.inner = (void*)(e & (~1));
12892         e_conv.is_owned = (e & 1) || (e == 0);
12893         e_conv = DecodeError_clone(&e_conv);
12894         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12895         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12896         return (uint64_t)ret_conv;
12897 }
12898
12899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12900         if ((_res & 1) != 0) return;
12901         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12902         FREE((void*)_res);
12903         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12904 }
12905
12906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12907         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12908         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12909         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12910         return (uint64_t)ret_conv;
12911 }
12912
12913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12914         LDKUpdateAddHTLC o_conv;
12915         o_conv.inner = (void*)(o & (~1));
12916         o_conv.is_owned = (o & 1) || (o == 0);
12917         o_conv = UpdateAddHTLC_clone(&o_conv);
12918         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12919         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12920         return (uint64_t)ret_conv;
12921 }
12922
12923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12924         LDKDecodeError e_conv;
12925         e_conv.inner = (void*)(e & (~1));
12926         e_conv.is_owned = (e & 1) || (e == 0);
12927         e_conv = DecodeError_clone(&e_conv);
12928         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12929         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12930         return (uint64_t)ret_conv;
12931 }
12932
12933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12934         if ((_res & 1) != 0) return;
12935         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12936         FREE((void*)_res);
12937         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12938 }
12939
12940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12941         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12942         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12943         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12944         return (uint64_t)ret_conv;
12945 }
12946
12947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12948         LDKPing o_conv;
12949         o_conv.inner = (void*)(o & (~1));
12950         o_conv.is_owned = (o & 1) || (o == 0);
12951         o_conv = Ping_clone(&o_conv);
12952         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12953         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12954         return (uint64_t)ret_conv;
12955 }
12956
12957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12958         LDKDecodeError e_conv;
12959         e_conv.inner = (void*)(e & (~1));
12960         e_conv.is_owned = (e & 1) || (e == 0);
12961         e_conv = DecodeError_clone(&e_conv);
12962         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12963         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12964         return (uint64_t)ret_conv;
12965 }
12966
12967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12968         if ((_res & 1) != 0) return;
12969         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12970         FREE((void*)_res);
12971         CResult_PingDecodeErrorZ_free(_res_conv);
12972 }
12973
12974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12975         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12976         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12977         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12978         return (uint64_t)ret_conv;
12979 }
12980
12981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12982         LDKPong o_conv;
12983         o_conv.inner = (void*)(o & (~1));
12984         o_conv.is_owned = (o & 1) || (o == 0);
12985         o_conv = Pong_clone(&o_conv);
12986         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12987         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12988         return (uint64_t)ret_conv;
12989 }
12990
12991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12992         LDKDecodeError e_conv;
12993         e_conv.inner = (void*)(e & (~1));
12994         e_conv.is_owned = (e & 1) || (e == 0);
12995         e_conv = DecodeError_clone(&e_conv);
12996         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12997         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
12998         return (uint64_t)ret_conv;
12999 }
13000
13001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13002         if ((_res & 1) != 0) return;
13003         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
13004         FREE((void*)_res);
13005         CResult_PongDecodeErrorZ_free(_res_conv);
13006 }
13007
13008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13009         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
13010         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13011         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
13012         return (uint64_t)ret_conv;
13013 }
13014
13015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13016         LDKUnsignedChannelAnnouncement o_conv;
13017         o_conv.inner = (void*)(o & (~1));
13018         o_conv.is_owned = (o & 1) || (o == 0);
13019         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
13020         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13021         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
13022         return (uint64_t)ret_conv;
13023 }
13024
13025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13026         LDKDecodeError e_conv;
13027         e_conv.inner = (void*)(e & (~1));
13028         e_conv.is_owned = (e & 1) || (e == 0);
13029         e_conv = DecodeError_clone(&e_conv);
13030         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13031         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
13032         return (uint64_t)ret_conv;
13033 }
13034
13035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13036         if ((_res & 1) != 0) return;
13037         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13038         FREE((void*)_res);
13039         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
13040 }
13041
13042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13043         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13044         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13045         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13046         return (uint64_t)ret_conv;
13047 }
13048
13049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13050         LDKChannelAnnouncement o_conv;
13051         o_conv.inner = (void*)(o & (~1));
13052         o_conv.is_owned = (o & 1) || (o == 0);
13053         o_conv = ChannelAnnouncement_clone(&o_conv);
13054         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13055         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
13056         return (uint64_t)ret_conv;
13057 }
13058
13059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13060         LDKDecodeError e_conv;
13061         e_conv.inner = (void*)(e & (~1));
13062         e_conv.is_owned = (e & 1) || (e == 0);
13063         e_conv = DecodeError_clone(&e_conv);
13064         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13065         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
13066         return (uint64_t)ret_conv;
13067 }
13068
13069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13070         if ((_res & 1) != 0) return;
13071         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13072         FREE((void*)_res);
13073         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
13074 }
13075
13076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13077         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13078         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13079         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13080         return (uint64_t)ret_conv;
13081 }
13082
13083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13084         LDKUnsignedChannelUpdate o_conv;
13085         o_conv.inner = (void*)(o & (~1));
13086         o_conv.is_owned = (o & 1) || (o == 0);
13087         o_conv = UnsignedChannelUpdate_clone(&o_conv);
13088         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13089         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
13090         return (uint64_t)ret_conv;
13091 }
13092
13093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13094         LDKDecodeError e_conv;
13095         e_conv.inner = (void*)(e & (~1));
13096         e_conv.is_owned = (e & 1) || (e == 0);
13097         e_conv = DecodeError_clone(&e_conv);
13098         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13099         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
13100         return (uint64_t)ret_conv;
13101 }
13102
13103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13104         if ((_res & 1) != 0) return;
13105         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13106         FREE((void*)_res);
13107         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
13108 }
13109
13110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13111         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
13112         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13113         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
13114         return (uint64_t)ret_conv;
13115 }
13116
13117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13118         LDKChannelUpdate o_conv;
13119         o_conv.inner = (void*)(o & (~1));
13120         o_conv.is_owned = (o & 1) || (o == 0);
13121         o_conv = ChannelUpdate_clone(&o_conv);
13122         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13123         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
13124         return (uint64_t)ret_conv;
13125 }
13126
13127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13128         LDKDecodeError e_conv;
13129         e_conv.inner = (void*)(e & (~1));
13130         e_conv.is_owned = (e & 1) || (e == 0);
13131         e_conv = DecodeError_clone(&e_conv);
13132         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13133         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
13134         return (uint64_t)ret_conv;
13135 }
13136
13137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13138         if ((_res & 1) != 0) return;
13139         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13140         FREE((void*)_res);
13141         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
13142 }
13143
13144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13145         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
13146         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13147         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
13148         return (uint64_t)ret_conv;
13149 }
13150
13151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13152         LDKErrorMessage o_conv;
13153         o_conv.inner = (void*)(o & (~1));
13154         o_conv.is_owned = (o & 1) || (o == 0);
13155         o_conv = ErrorMessage_clone(&o_conv);
13156         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13157         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
13158         return (uint64_t)ret_conv;
13159 }
13160
13161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13162         LDKDecodeError e_conv;
13163         e_conv.inner = (void*)(e & (~1));
13164         e_conv.is_owned = (e & 1) || (e == 0);
13165         e_conv = DecodeError_clone(&e_conv);
13166         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13167         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
13168         return (uint64_t)ret_conv;
13169 }
13170
13171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13172         if ((_res & 1) != 0) return;
13173         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
13174         FREE((void*)_res);
13175         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
13176 }
13177
13178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13179         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
13180         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13181         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
13182         return (uint64_t)ret_conv;
13183 }
13184
13185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13186         LDKUnsignedNodeAnnouncement o_conv;
13187         o_conv.inner = (void*)(o & (~1));
13188         o_conv.is_owned = (o & 1) || (o == 0);
13189         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
13190         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13191         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
13192         return (uint64_t)ret_conv;
13193 }
13194
13195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13196         LDKDecodeError e_conv;
13197         e_conv.inner = (void*)(e & (~1));
13198         e_conv.is_owned = (e & 1) || (e == 0);
13199         e_conv = DecodeError_clone(&e_conv);
13200         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13201         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13202         return (uint64_t)ret_conv;
13203 }
13204
13205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13206         if ((_res & 1) != 0) return;
13207         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13208         FREE((void*)_res);
13209         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13210 }
13211
13212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13213         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13214         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13215         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13216         return (uint64_t)ret_conv;
13217 }
13218
13219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13220         LDKNodeAnnouncement o_conv;
13221         o_conv.inner = (void*)(o & (~1));
13222         o_conv.is_owned = (o & 1) || (o == 0);
13223         o_conv = NodeAnnouncement_clone(&o_conv);
13224         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13225         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13226         return (uint64_t)ret_conv;
13227 }
13228
13229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13230         LDKDecodeError e_conv;
13231         e_conv.inner = (void*)(e & (~1));
13232         e_conv.is_owned = (e & 1) || (e == 0);
13233         e_conv = DecodeError_clone(&e_conv);
13234         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13235         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13236         return (uint64_t)ret_conv;
13237 }
13238
13239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13240         if ((_res & 1) != 0) return;
13241         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13242         FREE((void*)_res);
13243         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13244 }
13245
13246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13247         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13248         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13249         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13250         return (uint64_t)ret_conv;
13251 }
13252
13253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13254         LDKQueryShortChannelIds o_conv;
13255         o_conv.inner = (void*)(o & (~1));
13256         o_conv.is_owned = (o & 1) || (o == 0);
13257         o_conv = QueryShortChannelIds_clone(&o_conv);
13258         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13259         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13260         return (uint64_t)ret_conv;
13261 }
13262
13263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13264         LDKDecodeError e_conv;
13265         e_conv.inner = (void*)(e & (~1));
13266         e_conv.is_owned = (e & 1) || (e == 0);
13267         e_conv = DecodeError_clone(&e_conv);
13268         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13269         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13270         return (uint64_t)ret_conv;
13271 }
13272
13273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13274         if ((_res & 1) != 0) return;
13275         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
13276         FREE((void*)_res);
13277         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13278 }
13279
13280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13281         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13282         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13283         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13284         return (uint64_t)ret_conv;
13285 }
13286
13287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13288         LDKReplyShortChannelIdsEnd o_conv;
13289         o_conv.inner = (void*)(o & (~1));
13290         o_conv.is_owned = (o & 1) || (o == 0);
13291         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13292         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13293         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13294         return (uint64_t)ret_conv;
13295 }
13296
13297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13298         LDKDecodeError e_conv;
13299         e_conv.inner = (void*)(e & (~1));
13300         e_conv.is_owned = (e & 1) || (e == 0);
13301         e_conv = DecodeError_clone(&e_conv);
13302         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13303         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13304         return (uint64_t)ret_conv;
13305 }
13306
13307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13308         if ((_res & 1) != 0) return;
13309         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
13310         FREE((void*)_res);
13311         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13312 }
13313
13314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13315         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13316         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13317         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13318         return (uint64_t)ret_conv;
13319 }
13320
13321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13322         LDKQueryChannelRange o_conv;
13323         o_conv.inner = (void*)(o & (~1));
13324         o_conv.is_owned = (o & 1) || (o == 0);
13325         o_conv = QueryChannelRange_clone(&o_conv);
13326         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13327         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13328         return (uint64_t)ret_conv;
13329 }
13330
13331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13332         LDKDecodeError e_conv;
13333         e_conv.inner = (void*)(e & (~1));
13334         e_conv.is_owned = (e & 1) || (e == 0);
13335         e_conv = DecodeError_clone(&e_conv);
13336         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13337         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13338         return (uint64_t)ret_conv;
13339 }
13340
13341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13342         if ((_res & 1) != 0) return;
13343         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13344         FREE((void*)_res);
13345         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13346 }
13347
13348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13349         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13350         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13351         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13352         return (uint64_t)ret_conv;
13353 }
13354
13355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13356         LDKReplyChannelRange o_conv;
13357         o_conv.inner = (void*)(o & (~1));
13358         o_conv.is_owned = (o & 1) || (o == 0);
13359         o_conv = ReplyChannelRange_clone(&o_conv);
13360         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13361         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13362         return (uint64_t)ret_conv;
13363 }
13364
13365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13366         LDKDecodeError e_conv;
13367         e_conv.inner = (void*)(e & (~1));
13368         e_conv.is_owned = (e & 1) || (e == 0);
13369         e_conv = DecodeError_clone(&e_conv);
13370         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13371         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13372         return (uint64_t)ret_conv;
13373 }
13374
13375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13376         if ((_res & 1) != 0) return;
13377         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13378         FREE((void*)_res);
13379         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13380 }
13381
13382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13383         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13384         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13385         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13386         return (uint64_t)ret_conv;
13387 }
13388
13389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13390         LDKGossipTimestampFilter o_conv;
13391         o_conv.inner = (void*)(o & (~1));
13392         o_conv.is_owned = (o & 1) || (o == 0);
13393         o_conv = GossipTimestampFilter_clone(&o_conv);
13394         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13395         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13396         return (uint64_t)ret_conv;
13397 }
13398
13399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13400         LDKDecodeError e_conv;
13401         e_conv.inner = (void*)(e & (~1));
13402         e_conv.is_owned = (e & 1) || (e == 0);
13403         e_conv = DecodeError_clone(&e_conv);
13404         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13405         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13406         return (uint64_t)ret_conv;
13407 }
13408
13409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13410         if ((_res & 1) != 0) return;
13411         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
13412         FREE((void*)_res);
13413         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13414 }
13415
13416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13417         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13418         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13419         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13420         return (uint64_t)ret_conv;
13421 }
13422
13423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13424         LDKInvoice o_conv;
13425         o_conv.inner = (void*)(o & (~1));
13426         o_conv.is_owned = (o & 1) || (o == 0);
13427         o_conv = Invoice_clone(&o_conv);
13428         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13429         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13430         return (uint64_t)ret_conv;
13431 }
13432
13433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13434         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
13435         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13436         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13437         return (uint64_t)ret_conv;
13438 }
13439
13440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13441         if ((_res & 1) != 0) return;
13442         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
13443         FREE((void*)_res);
13444         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13445 }
13446
13447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13448         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13449         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13450         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13451         return (uint64_t)ret_conv;
13452 }
13453
13454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13455         if ((this_ptr & 1) != 0) return;
13456         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
13457         FREE((void*)this_ptr);
13458         PaymentPurpose_free(this_ptr_conv);
13459 }
13460
13461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13462         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
13463         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13464         *ret_copy = PaymentPurpose_clone(orig_conv);
13465         uint64_t ret_ref = (uint64_t)ret_copy;
13466         return ret_ref;
13467 }
13468
13469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13470         if ((this_ptr & 1) != 0) return;
13471         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
13472         FREE((void*)this_ptr);
13473         Event_free(this_ptr_conv);
13474 }
13475
13476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13477         LDKEvent* orig_conv = (LDKEvent*)orig;
13478         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13479         *ret_copy = Event_clone(orig_conv);
13480         uint64_t ret_ref = (uint64_t)ret_copy;
13481         return ret_ref;
13482 }
13483
13484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
13485         LDKEvent* obj_conv = (LDKEvent*)obj;
13486         LDKCVec_u8Z ret_var = Event_write(obj_conv);
13487         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13488         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13489         CVec_u8Z_free(ret_var);
13490         return ret_arr;
13491 }
13492
13493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13494         if ((this_ptr & 1) != 0) return;
13495         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
13496         FREE((void*)this_ptr);
13497         MessageSendEvent_free(this_ptr_conv);
13498 }
13499
13500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13501         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
13502         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13503         *ret_copy = MessageSendEvent_clone(orig_conv);
13504         uint64_t ret_ref = (uint64_t)ret_copy;
13505         return ret_ref;
13506 }
13507
13508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13509         if ((this_ptr & 1) != 0) return;
13510         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
13511         FREE((void*)this_ptr);
13512         MessageSendEventsProvider_free(this_ptr_conv);
13513 }
13514
13515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13516         if ((this_ptr & 1) != 0) return;
13517         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
13518         FREE((void*)this_ptr);
13519         EventsProvider_free(this_ptr_conv);
13520 }
13521
13522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13523         if ((this_ptr & 1) != 0) return;
13524         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
13525         FREE((void*)this_ptr);
13526         EventHandler_free(this_ptr_conv);
13527 }
13528
13529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13530         if ((this_ptr & 1) != 0) return;
13531         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
13532         FREE((void*)this_ptr);
13533         APIError_free(this_ptr_conv);
13534 }
13535
13536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13537         LDKAPIError* orig_conv = (LDKAPIError*)orig;
13538         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13539         *ret_copy = APIError_clone(orig_conv);
13540         uint64_t ret_ref = (uint64_t)ret_copy;
13541         return ret_ref;
13542 }
13543
13544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
13545         LDKu8slice msg_ref;
13546         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13547         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13548         unsigned char sk_arr[32];
13549         CHECK((*env)->GetArrayLength(env, sk) == 32);
13550         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
13551         unsigned char (*sk_ref)[32] = &sk_arr;
13552         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13553         *ret_conv = sign(msg_ref, sk_ref);
13554         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13555         return (uint64_t)ret_conv;
13556 }
13557
13558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
13559         LDKu8slice msg_ref;
13560         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13561         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13562         LDKStr sig_conv = java_to_owned_str(env, sig);
13563         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13564         *ret_conv = recover_pk(msg_ref, sig_conv);
13565         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13566         return (uint64_t)ret_conv;
13567 }
13568
13569 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
13570         LDKu8slice msg_ref;
13571         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13572         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13573         LDKStr sig_conv = java_to_owned_str(env, sig);
13574         LDKPublicKey pk_ref;
13575         CHECK((*env)->GetArrayLength(env, pk) == 33);
13576         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
13577         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
13578         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13579         return ret_val;
13580 }
13581
13582 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13583         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
13584         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
13585         return ret_conv;
13586 }
13587
13588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
13589         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
13590         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
13591         jboolean ret_val = Level_eq(a_conv, b_conv);
13592         return ret_val;
13593 }
13594
13595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
13596         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13597         int64_t ret_val = Level_hash(o_conv);
13598         return ret_val;
13599 }
13600
13601 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13602         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13603         return ret_conv;
13604 }
13605
13606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13607         if ((this_ptr & 1) != 0) return;
13608         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13609         FREE((void*)this_ptr);
13610         Logger_free(this_ptr_conv);
13611 }
13612
13613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13614         LDKChannelHandshakeConfig this_obj_conv;
13615         this_obj_conv.inner = (void*)(this_obj & (~1));
13616         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13617         ChannelHandshakeConfig_free(this_obj_conv);
13618 }
13619
13620 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13621         LDKChannelHandshakeConfig this_ptr_conv;
13622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13623         this_ptr_conv.is_owned = false;
13624         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13625         return ret_val;
13626 }
13627
13628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13629         LDKChannelHandshakeConfig this_ptr_conv;
13630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13631         this_ptr_conv.is_owned = false;
13632         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13633 }
13634
13635 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13636         LDKChannelHandshakeConfig this_ptr_conv;
13637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13638         this_ptr_conv.is_owned = false;
13639         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13640         return ret_val;
13641 }
13642
13643 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) {
13644         LDKChannelHandshakeConfig this_ptr_conv;
13645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13646         this_ptr_conv.is_owned = false;
13647         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13648 }
13649
13650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13651         LDKChannelHandshakeConfig this_ptr_conv;
13652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13653         this_ptr_conv.is_owned = false;
13654         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13655         return ret_val;
13656 }
13657
13658 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) {
13659         LDKChannelHandshakeConfig this_ptr_conv;
13660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13661         this_ptr_conv.is_owned = false;
13662         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13663 }
13664
13665 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) {
13666         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13669         uint64_t ret_ref = (uint64_t)ret_var.inner;
13670         if (ret_var.is_owned) {
13671                 ret_ref |= 1;
13672         }
13673         return ret_ref;
13674 }
13675
13676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13677         LDKChannelHandshakeConfig orig_conv;
13678         orig_conv.inner = (void*)(orig & (~1));
13679         orig_conv.is_owned = false;
13680         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13683         uint64_t ret_ref = (uint64_t)ret_var.inner;
13684         if (ret_var.is_owned) {
13685                 ret_ref |= 1;
13686         }
13687         return ret_ref;
13688 }
13689
13690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13691         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13692         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13693         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13694         uint64_t ret_ref = (uint64_t)ret_var.inner;
13695         if (ret_var.is_owned) {
13696                 ret_ref |= 1;
13697         }
13698         return ret_ref;
13699 }
13700
13701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13702         LDKChannelHandshakeLimits this_obj_conv;
13703         this_obj_conv.inner = (void*)(this_obj & (~1));
13704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13705         ChannelHandshakeLimits_free(this_obj_conv);
13706 }
13707
13708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13709         LDKChannelHandshakeLimits this_ptr_conv;
13710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13711         this_ptr_conv.is_owned = false;
13712         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13713         return ret_val;
13714 }
13715
13716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13717         LDKChannelHandshakeLimits this_ptr_conv;
13718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13719         this_ptr_conv.is_owned = false;
13720         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13721 }
13722
13723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13724         LDKChannelHandshakeLimits this_ptr_conv;
13725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13726         this_ptr_conv.is_owned = false;
13727         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13728         return ret_val;
13729 }
13730
13731 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) {
13732         LDKChannelHandshakeLimits this_ptr_conv;
13733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13734         this_ptr_conv.is_owned = false;
13735         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13736 }
13737
13738 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) {
13739         LDKChannelHandshakeLimits this_ptr_conv;
13740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13741         this_ptr_conv.is_owned = false;
13742         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13743         return ret_val;
13744 }
13745
13746 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) {
13747         LDKChannelHandshakeLimits this_ptr_conv;
13748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13749         this_ptr_conv.is_owned = false;
13750         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13751 }
13752
13753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13754         LDKChannelHandshakeLimits this_ptr_conv;
13755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13756         this_ptr_conv.is_owned = false;
13757         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13758         return ret_val;
13759 }
13760
13761 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) {
13762         LDKChannelHandshakeLimits this_ptr_conv;
13763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13764         this_ptr_conv.is_owned = false;
13765         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13766 }
13767
13768 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13769         LDKChannelHandshakeLimits this_ptr_conv;
13770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13771         this_ptr_conv.is_owned = false;
13772         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13773         return ret_val;
13774 }
13775
13776 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) {
13777         LDKChannelHandshakeLimits this_ptr_conv;
13778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13779         this_ptr_conv.is_owned = false;
13780         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13781 }
13782
13783 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13784         LDKChannelHandshakeLimits this_ptr_conv;
13785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13786         this_ptr_conv.is_owned = false;
13787         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
13788         return ret_val;
13789 }
13790
13791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13792         LDKChannelHandshakeLimits this_ptr_conv;
13793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13794         this_ptr_conv.is_owned = false;
13795         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
13796 }
13797
13798 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
13799         LDKChannelHandshakeLimits this_ptr_conv;
13800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13801         this_ptr_conv.is_owned = false;
13802         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
13803         return ret_val;
13804 }
13805
13806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13807         LDKChannelHandshakeLimits this_ptr_conv;
13808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13809         this_ptr_conv.is_owned = false;
13810         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
13811 }
13812
13813 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13814         LDKChannelHandshakeLimits this_ptr_conv;
13815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13816         this_ptr_conv.is_owned = false;
13817         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
13818         return ret_val;
13819 }
13820
13821 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) {
13822         LDKChannelHandshakeLimits this_ptr_conv;
13823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13824         this_ptr_conv.is_owned = false;
13825         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
13826 }
13827
13828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_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 force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
13829         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_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, force_announced_channel_preference_arg, their_to_self_delay_arg);
13830         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13831         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13832         uint64_t ret_ref = (uint64_t)ret_var.inner;
13833         if (ret_var.is_owned) {
13834                 ret_ref |= 1;
13835         }
13836         return ret_ref;
13837 }
13838
13839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13840         LDKChannelHandshakeLimits orig_conv;
13841         orig_conv.inner = (void*)(orig & (~1));
13842         orig_conv.is_owned = false;
13843         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
13844         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13845         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13846         uint64_t ret_ref = (uint64_t)ret_var.inner;
13847         if (ret_var.is_owned) {
13848                 ret_ref |= 1;
13849         }
13850         return ret_ref;
13851 }
13852
13853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
13854         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
13855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13857         uint64_t ret_ref = (uint64_t)ret_var.inner;
13858         if (ret_var.is_owned) {
13859                 ret_ref |= 1;
13860         }
13861         return ret_ref;
13862 }
13863
13864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13865         LDKChannelConfig this_obj_conv;
13866         this_obj_conv.inner = (void*)(this_obj & (~1));
13867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13868         ChannelConfig_free(this_obj_conv);
13869 }
13870
13871 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
13872         LDKChannelConfig this_ptr_conv;
13873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13874         this_ptr_conv.is_owned = false;
13875         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
13876         return ret_val;
13877 }
13878
13879 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) {
13880         LDKChannelConfig this_ptr_conv;
13881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13882         this_ptr_conv.is_owned = false;
13883         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
13884 }
13885
13886 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13887         LDKChannelConfig this_ptr_conv;
13888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13889         this_ptr_conv.is_owned = false;
13890         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
13891         return ret_val;
13892 }
13893
13894 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) {
13895         LDKChannelConfig this_ptr_conv;
13896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13897         this_ptr_conv.is_owned = false;
13898         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
13899 }
13900
13901 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
13902         LDKChannelConfig this_ptr_conv;
13903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13904         this_ptr_conv.is_owned = false;
13905         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
13906         return ret_val;
13907 }
13908
13909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13910         LDKChannelConfig this_ptr_conv;
13911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13912         this_ptr_conv.is_owned = false;
13913         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
13914 }
13915
13916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
13917         LDKChannelConfig this_ptr_conv;
13918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13919         this_ptr_conv.is_owned = false;
13920         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
13921         return ret_val;
13922 }
13923
13924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13925         LDKChannelConfig this_ptr_conv;
13926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13927         this_ptr_conv.is_owned = false;
13928         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
13929 }
13930
13931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13932         LDKChannelConfig this_ptr_conv;
13933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13934         this_ptr_conv.is_owned = false;
13935         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
13936         return ret_val;
13937 }
13938
13939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13940         LDKChannelConfig this_ptr_conv;
13941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13942         this_ptr_conv.is_owned = false;
13943         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
13944 }
13945
13946 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, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
13947         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
13948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13950         uint64_t ret_ref = (uint64_t)ret_var.inner;
13951         if (ret_var.is_owned) {
13952                 ret_ref |= 1;
13953         }
13954         return ret_ref;
13955 }
13956
13957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13958         LDKChannelConfig orig_conv;
13959         orig_conv.inner = (void*)(orig & (~1));
13960         orig_conv.is_owned = false;
13961         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
13962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13964         uint64_t ret_ref = (uint64_t)ret_var.inner;
13965         if (ret_var.is_owned) {
13966                 ret_ref |= 1;
13967         }
13968         return ret_ref;
13969 }
13970
13971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
13972         LDKChannelConfig ret_var = ChannelConfig_default();
13973         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13974         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13975         uint64_t ret_ref = (uint64_t)ret_var.inner;
13976         if (ret_var.is_owned) {
13977                 ret_ref |= 1;
13978         }
13979         return ret_ref;
13980 }
13981
13982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
13983         LDKChannelConfig obj_conv;
13984         obj_conv.inner = (void*)(obj & (~1));
13985         obj_conv.is_owned = false;
13986         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13987         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13988         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13989         CVec_u8Z_free(ret_var);
13990         return ret_arr;
13991 }
13992
13993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13994         LDKu8slice ser_ref;
13995         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13996         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13997         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13998         *ret_conv = ChannelConfig_read(ser_ref);
13999         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14000         return (uint64_t)ret_conv;
14001 }
14002
14003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14004         LDKUserConfig this_obj_conv;
14005         this_obj_conv.inner = (void*)(this_obj & (~1));
14006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14007         UserConfig_free(this_obj_conv);
14008 }
14009
14010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
14011         LDKUserConfig this_ptr_conv;
14012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14013         this_ptr_conv.is_owned = false;
14014         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
14015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14017         uint64_t ret_ref = (uint64_t)ret_var.inner;
14018         if (ret_var.is_owned) {
14019                 ret_ref |= 1;
14020         }
14021         return ret_ref;
14022 }
14023
14024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14025         LDKUserConfig this_ptr_conv;
14026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14027         this_ptr_conv.is_owned = false;
14028         LDKChannelHandshakeConfig val_conv;
14029         val_conv.inner = (void*)(val & (~1));
14030         val_conv.is_owned = (val & 1) || (val == 0);
14031         val_conv = ChannelHandshakeConfig_clone(&val_conv);
14032         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
14033 }
14034
14035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
14036         LDKUserConfig this_ptr_conv;
14037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14038         this_ptr_conv.is_owned = false;
14039         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
14040         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14041         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14042         uint64_t ret_ref = (uint64_t)ret_var.inner;
14043         if (ret_var.is_owned) {
14044                 ret_ref |= 1;
14045         }
14046         return ret_ref;
14047 }
14048
14049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14050         LDKUserConfig this_ptr_conv;
14051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14052         this_ptr_conv.is_owned = false;
14053         LDKChannelHandshakeLimits val_conv;
14054         val_conv.inner = (void*)(val & (~1));
14055         val_conv.is_owned = (val & 1) || (val == 0);
14056         val_conv = ChannelHandshakeLimits_clone(&val_conv);
14057         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
14058 }
14059
14060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
14061         LDKUserConfig this_ptr_conv;
14062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14063         this_ptr_conv.is_owned = false;
14064         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
14065         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14066         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14067         uint64_t ret_ref = (uint64_t)ret_var.inner;
14068         if (ret_var.is_owned) {
14069                 ret_ref |= 1;
14070         }
14071         return ret_ref;
14072 }
14073
14074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14075         LDKUserConfig this_ptr_conv;
14076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14077         this_ptr_conv.is_owned = false;
14078         LDKChannelConfig val_conv;
14079         val_conv.inner = (void*)(val & (~1));
14080         val_conv.is_owned = (val & 1) || (val == 0);
14081         val_conv = ChannelConfig_clone(&val_conv);
14082         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
14083 }
14084
14085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
14086         LDKUserConfig this_ptr_conv;
14087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14088         this_ptr_conv.is_owned = false;
14089         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
14090         return ret_val;
14091 }
14092
14093 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) {
14094         LDKUserConfig this_ptr_conv;
14095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14096         this_ptr_conv.is_owned = false;
14097         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
14098 }
14099
14100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) {
14101         LDKChannelHandshakeConfig own_channel_config_arg_conv;
14102         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
14103         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
14104         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
14105         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
14106         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
14107         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
14108         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
14109         LDKChannelConfig channel_options_arg_conv;
14110         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
14111         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
14112         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
14113         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
14114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14116         uint64_t ret_ref = (uint64_t)ret_var.inner;
14117         if (ret_var.is_owned) {
14118                 ret_ref |= 1;
14119         }
14120         return ret_ref;
14121 }
14122
14123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14124         LDKUserConfig orig_conv;
14125         orig_conv.inner = (void*)(orig & (~1));
14126         orig_conv.is_owned = false;
14127         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
14128         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14129         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14130         uint64_t ret_ref = (uint64_t)ret_var.inner;
14131         if (ret_var.is_owned) {
14132                 ret_ref |= 1;
14133         }
14134         return ret_ref;
14135 }
14136
14137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
14138         LDKUserConfig ret_var = UserConfig_default();
14139         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14140         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14141         uint64_t ret_ref = (uint64_t)ret_var.inner;
14142         if (ret_var.is_owned) {
14143                 ret_ref |= 1;
14144         }
14145         return ret_ref;
14146 }
14147
14148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14149         LDKBestBlock this_obj_conv;
14150         this_obj_conv.inner = (void*)(this_obj & (~1));
14151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14152         BestBlock_free(this_obj_conv);
14153 }
14154
14155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14156         LDKBestBlock orig_conv;
14157         orig_conv.inner = (void*)(orig & (~1));
14158         orig_conv.is_owned = false;
14159         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
14160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14162         uint64_t ret_ref = (uint64_t)ret_var.inner;
14163         if (ret_var.is_owned) {
14164                 ret_ref |= 1;
14165         }
14166         return ret_ref;
14167 }
14168
14169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
14170         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
14171         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
14172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14174         uint64_t ret_ref = (uint64_t)ret_var.inner;
14175         if (ret_var.is_owned) {
14176                 ret_ref |= 1;
14177         }
14178         return ret_ref;
14179 }
14180
14181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
14182         LDKThirtyTwoBytes block_hash_ref;
14183         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
14184         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
14185         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
14186         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14187         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14188         uint64_t ret_ref = (uint64_t)ret_var.inner;
14189         if (ret_var.is_owned) {
14190                 ret_ref |= 1;
14191         }
14192         return ret_ref;
14193 }
14194
14195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14196         LDKBestBlock this_arg_conv;
14197         this_arg_conv.inner = (void*)(this_arg & (~1));
14198         this_arg_conv.is_owned = false;
14199         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
14201         return ret_arr;
14202 }
14203
14204 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
14205         LDKBestBlock this_arg_conv;
14206         this_arg_conv.inner = (void*)(this_arg & (~1));
14207         this_arg_conv.is_owned = false;
14208         int32_t ret_val = BestBlock_height(&this_arg_conv);
14209         return ret_val;
14210 }
14211
14212 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14213         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
14214         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
14215         return ret_conv;
14216 }
14217
14218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14219         if ((this_ptr & 1) != 0) return;
14220         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
14221         FREE((void*)this_ptr);
14222         Access_free(this_ptr_conv);
14223 }
14224
14225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14226         if ((this_ptr & 1) != 0) return;
14227         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
14228         FREE((void*)this_ptr);
14229         Listen_free(this_ptr_conv);
14230 }
14231
14232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14233         if ((this_ptr & 1) != 0) return;
14234         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
14235         FREE((void*)this_ptr);
14236         Confirm_free(this_ptr_conv);
14237 }
14238
14239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14240         if ((this_ptr & 1) != 0) return;
14241         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
14242         FREE((void*)this_ptr);
14243         Watch_free(this_ptr_conv);
14244 }
14245
14246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14247         if ((this_ptr & 1) != 0) return;
14248         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
14249         FREE((void*)this_ptr);
14250         Filter_free(this_ptr_conv);
14251 }
14252
14253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14254         LDKWatchedOutput this_obj_conv;
14255         this_obj_conv.inner = (void*)(this_obj & (~1));
14256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14257         WatchedOutput_free(this_obj_conv);
14258 }
14259
14260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14261         LDKWatchedOutput this_ptr_conv;
14262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14263         this_ptr_conv.is_owned = false;
14264         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14265         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
14266         return ret_arr;
14267 }
14268
14269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14270         LDKWatchedOutput this_ptr_conv;
14271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14272         this_ptr_conv.is_owned = false;
14273         LDKThirtyTwoBytes val_ref;
14274         CHECK((*env)->GetArrayLength(env, val) == 32);
14275         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14276         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
14277 }
14278
14279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14280         LDKWatchedOutput this_ptr_conv;
14281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14282         this_ptr_conv.is_owned = false;
14283         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
14284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14286         uint64_t ret_ref = (uint64_t)ret_var.inner;
14287         if (ret_var.is_owned) {
14288                 ret_ref |= 1;
14289         }
14290         return ret_ref;
14291 }
14292
14293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14294         LDKWatchedOutput this_ptr_conv;
14295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14296         this_ptr_conv.is_owned = false;
14297         LDKOutPoint val_conv;
14298         val_conv.inner = (void*)(val & (~1));
14299         val_conv.is_owned = (val & 1) || (val == 0);
14300         val_conv = OutPoint_clone(&val_conv);
14301         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
14302 }
14303
14304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14305         LDKWatchedOutput this_ptr_conv;
14306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14307         this_ptr_conv.is_owned = false;
14308         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
14309         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14310         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14311         return ret_arr;
14312 }
14313
14314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14315         LDKWatchedOutput this_ptr_conv;
14316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14317         this_ptr_conv.is_owned = false;
14318         LDKCVec_u8Z val_ref;
14319         val_ref.datalen = (*env)->GetArrayLength(env, val);
14320         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14321         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14322         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
14323 }
14324
14325 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) {
14326         LDKThirtyTwoBytes block_hash_arg_ref;
14327         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
14328         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
14329         LDKOutPoint outpoint_arg_conv;
14330         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14331         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14332         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14333         LDKCVec_u8Z script_pubkey_arg_ref;
14334         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
14335         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14336         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
14337         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
14338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14340         uint64_t ret_ref = (uint64_t)ret_var.inner;
14341         if (ret_var.is_owned) {
14342                 ret_ref |= 1;
14343         }
14344         return ret_ref;
14345 }
14346
14347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14348         LDKWatchedOutput orig_conv;
14349         orig_conv.inner = (void*)(orig & (~1));
14350         orig_conv.is_owned = false;
14351         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
14352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14354         uint64_t ret_ref = (uint64_t)ret_var.inner;
14355         if (ret_var.is_owned) {
14356                 ret_ref |= 1;
14357         }
14358         return ret_ref;
14359 }
14360
14361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
14362         LDKWatchedOutput o_conv;
14363         o_conv.inner = (void*)(o & (~1));
14364         o_conv.is_owned = false;
14365         int64_t ret_val = WatchedOutput_hash(&o_conv);
14366         return ret_val;
14367 }
14368
14369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14370         if ((this_ptr & 1) != 0) return;
14371         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
14372         FREE((void*)this_ptr);
14373         BroadcasterInterface_free(this_ptr_conv);
14374 }
14375
14376 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14377         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
14378         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
14379         return ret_conv;
14380 }
14381
14382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14383         if ((this_ptr & 1) != 0) return;
14384         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
14385         FREE((void*)this_ptr);
14386         FeeEstimator_free(this_ptr_conv);
14387 }
14388
14389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14390         LDKChainMonitor this_obj_conv;
14391         this_obj_conv.inner = (void*)(this_obj & (~1));
14392         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14393         ChainMonitor_free(this_obj_conv);
14394 }
14395
14396 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) {
14397         LDKFilter *chain_source_conv_ptr = NULL;
14398         if (chain_source != 0) {
14399                 LDKFilter chain_source_conv;
14400                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
14401                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
14402                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14403                         LDKFilter_JCalls_cloned(&chain_source_conv);
14404                 }
14405                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
14406                 *chain_source_conv_ptr = chain_source_conv;
14407         }
14408         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14409         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14410                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14411                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14412         }
14413         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14414         if (logger_conv.free == LDKLogger_JCalls_free) {
14415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14416                 LDKLogger_JCalls_cloned(&logger_conv);
14417         }
14418         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
14419         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
14420                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14421                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
14422         }
14423         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
14424         if (persister_conv.free == LDKPersist_JCalls_free) {
14425                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14426                 LDKPersist_JCalls_cloned(&persister_conv);
14427         }
14428         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
14429         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14430         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14431         uint64_t ret_ref = (uint64_t)ret_var.inner;
14432         if (ret_var.is_owned) {
14433                 ret_ref |= 1;
14434         }
14435         return ret_ref;
14436 }
14437
14438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
14439         LDKChainMonitor this_arg_conv;
14440         this_arg_conv.inner = (void*)(this_arg & (~1));
14441         this_arg_conv.is_owned = false;
14442         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
14443         *ret = ChainMonitor_as_Listen(&this_arg_conv);
14444         return (uint64_t)ret;
14445 }
14446
14447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
14448         LDKChainMonitor this_arg_conv;
14449         this_arg_conv.inner = (void*)(this_arg & (~1));
14450         this_arg_conv.is_owned = false;
14451         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
14452         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
14453         return (uint64_t)ret;
14454 }
14455
14456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14457         LDKChainMonitor this_arg_conv;
14458         this_arg_conv.inner = (void*)(this_arg & (~1));
14459         this_arg_conv.is_owned = false;
14460         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
14461         *ret = ChainMonitor_as_Watch(&this_arg_conv);
14462         return (uint64_t)ret;
14463 }
14464
14465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
14466         LDKChainMonitor this_arg_conv;
14467         this_arg_conv.inner = (void*)(this_arg & (~1));
14468         this_arg_conv.is_owned = false;
14469         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
14470         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
14471         return (uint64_t)ret;
14472 }
14473
14474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14475         LDKChannelMonitorUpdate this_obj_conv;
14476         this_obj_conv.inner = (void*)(this_obj & (~1));
14477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14478         ChannelMonitorUpdate_free(this_obj_conv);
14479 }
14480
14481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14482         LDKChannelMonitorUpdate this_ptr_conv;
14483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14484         this_ptr_conv.is_owned = false;
14485         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
14486         return ret_val;
14487 }
14488
14489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14490         LDKChannelMonitorUpdate this_ptr_conv;
14491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14492         this_ptr_conv.is_owned = false;
14493         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
14494 }
14495
14496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14497         LDKChannelMonitorUpdate orig_conv;
14498         orig_conv.inner = (void*)(orig & (~1));
14499         orig_conv.is_owned = false;
14500         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
14501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14503         uint64_t ret_ref = (uint64_t)ret_var.inner;
14504         if (ret_var.is_owned) {
14505                 ret_ref |= 1;
14506         }
14507         return ret_ref;
14508 }
14509
14510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14511         LDKChannelMonitorUpdate obj_conv;
14512         obj_conv.inner = (void*)(obj & (~1));
14513         obj_conv.is_owned = false;
14514         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
14515         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14516         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14517         CVec_u8Z_free(ret_var);
14518         return ret_arr;
14519 }
14520
14521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14522         LDKu8slice ser_ref;
14523         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14524         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14525         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14526         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
14527         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14528         return (uint64_t)ret_conv;
14529 }
14530
14531 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14532         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
14533         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
14534         return ret_conv;
14535 }
14536
14537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14538         LDKMonitorUpdateError this_obj_conv;
14539         this_obj_conv.inner = (void*)(this_obj & (~1));
14540         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14541         MonitorUpdateError_free(this_obj_conv);
14542 }
14543
14544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14545         LDKMonitorUpdateError orig_conv;
14546         orig_conv.inner = (void*)(orig & (~1));
14547         orig_conv.is_owned = false;
14548         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
14549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14551         uint64_t ret_ref = (uint64_t)ret_var.inner;
14552         if (ret_var.is_owned) {
14553                 ret_ref |= 1;
14554         }
14555         return ret_ref;
14556 }
14557
14558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14559         if ((this_ptr & 1) != 0) return;
14560         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
14561         FREE((void*)this_ptr);
14562         MonitorEvent_free(this_ptr_conv);
14563 }
14564
14565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14566         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
14567         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14568         *ret_copy = MonitorEvent_clone(orig_conv);
14569         uint64_t ret_ref = (uint64_t)ret_copy;
14570         return ret_ref;
14571 }
14572
14573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14574         LDKHTLCUpdate this_obj_conv;
14575         this_obj_conv.inner = (void*)(this_obj & (~1));
14576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14577         HTLCUpdate_free(this_obj_conv);
14578 }
14579
14580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14581         LDKHTLCUpdate orig_conv;
14582         orig_conv.inner = (void*)(orig & (~1));
14583         orig_conv.is_owned = false;
14584         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
14585         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14586         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14587         uint64_t ret_ref = (uint64_t)ret_var.inner;
14588         if (ret_var.is_owned) {
14589                 ret_ref |= 1;
14590         }
14591         return ret_ref;
14592 }
14593
14594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14595         LDKHTLCUpdate obj_conv;
14596         obj_conv.inner = (void*)(obj & (~1));
14597         obj_conv.is_owned = false;
14598         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
14599         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14600         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14601         CVec_u8Z_free(ret_var);
14602         return ret_arr;
14603 }
14604
14605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14606         LDKu8slice ser_ref;
14607         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14608         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14609         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14610         *ret_conv = HTLCUpdate_read(ser_ref);
14611         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14612         return (uint64_t)ret_conv;
14613 }
14614
14615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14616         LDKChannelMonitor this_obj_conv;
14617         this_obj_conv.inner = (void*)(this_obj & (~1));
14618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14619         ChannelMonitor_free(this_obj_conv);
14620 }
14621
14622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14623         LDKChannelMonitor orig_conv;
14624         orig_conv.inner = (void*)(orig & (~1));
14625         orig_conv.is_owned = false;
14626         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
14627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14629         uint64_t ret_ref = (uint64_t)ret_var.inner;
14630         if (ret_var.is_owned) {
14631                 ret_ref |= 1;
14632         }
14633         return ret_ref;
14634 }
14635
14636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14637         LDKChannelMonitor obj_conv;
14638         obj_conv.inner = (void*)(obj & (~1));
14639         obj_conv.is_owned = false;
14640         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
14641         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14642         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14643         CVec_u8Z_free(ret_var);
14644         return ret_arr;
14645 }
14646
14647 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) {
14648         LDKChannelMonitor this_arg_conv;
14649         this_arg_conv.inner = (void*)(this_arg & (~1));
14650         this_arg_conv.is_owned = false;
14651         LDKChannelMonitorUpdate updates_conv;
14652         updates_conv.inner = (void*)(updates & (~1));
14653         updates_conv.is_owned = false;
14654         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14655         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14656         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14657         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14658         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
14659         return (uint64_t)ret_conv;
14660 }
14661
14662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14663         LDKChannelMonitor this_arg_conv;
14664         this_arg_conv.inner = (void*)(this_arg & (~1));
14665         this_arg_conv.is_owned = false;
14666         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
14667         return ret_val;
14668 }
14669
14670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
14671         LDKChannelMonitor this_arg_conv;
14672         this_arg_conv.inner = (void*)(this_arg & (~1));
14673         this_arg_conv.is_owned = false;
14674         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14675         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
14676         return (uint64_t)ret_ref;
14677 }
14678
14679 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14680         LDKChannelMonitor this_arg_conv;
14681         this_arg_conv.inner = (void*)(this_arg & (~1));
14682         this_arg_conv.is_owned = false;
14683         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
14684         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14685         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14686         for (size_t v = 0; v < ret_var.datalen; v++) {
14687                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14688                 *ret_conv_47_ref = ret_var.data[v];
14689                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
14690         }
14691         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14692         FREE(ret_var.data);
14693         return ret_arr;
14694 }
14695
14696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14697         LDKChannelMonitor this_arg_conv;
14698         this_arg_conv.inner = (void*)(this_arg & (~1));
14699         this_arg_conv.is_owned = false;
14700         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14701         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14702 }
14703
14704 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14705         LDKChannelMonitor this_arg_conv;
14706         this_arg_conv.inner = (void*)(this_arg & (~1));
14707         this_arg_conv.is_owned = false;
14708         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14709         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14710         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14711         for (size_t o = 0; o < ret_var.datalen; o++) {
14712                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14713                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14714                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14715                 ret_arr_ptr[o] = ret_conv_14_ref;
14716         }
14717         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14718         FREE(ret_var.data);
14719         return ret_arr;
14720 }
14721
14722 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14723         LDKChannelMonitor this_arg_conv;
14724         this_arg_conv.inner = (void*)(this_arg & (~1));
14725         this_arg_conv.is_owned = false;
14726         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14727         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14728         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14729         for (size_t h = 0; h < ret_var.datalen; h++) {
14730                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14731                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
14732                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
14733                 ret_arr_ptr[h] = ret_conv_7_ref;
14734         }
14735         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14736         FREE(ret_var.data);
14737         return ret_arr;
14738 }
14739
14740 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) {
14741         LDKChannelMonitor this_arg_conv;
14742         this_arg_conv.inner = (void*)(this_arg & (~1));
14743         this_arg_conv.is_owned = false;
14744         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14745         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
14746         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14747         ;
14748         for (size_t i = 0; i < ret_var.datalen; i++) {
14749                 LDKTransaction ret_conv_8_var = ret_var.data[i];
14750                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
14751                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
14752                 Transaction_free(ret_conv_8_var);
14753                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14754         }
14755         FREE(ret_var.data);
14756         return ret_arr;
14757 }
14758
14759 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) {
14760         LDKChannelMonitor this_arg_conv;
14761         this_arg_conv.inner = (void*)(this_arg & (~1));
14762         this_arg_conv.is_owned = false;
14763         unsigned char header_arr[80];
14764         CHECK((*env)->GetArrayLength(env, header) == 80);
14765         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14766         unsigned char (*header_ref)[80] = &header_arr;
14767         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14768         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14769         if (txdata_constr.datalen > 0)
14770                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14771         else
14772                 txdata_constr.data = NULL;
14773         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14774         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14775                 int64_t txdata_conv_24 = txdata_vals[y];
14776                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14777                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14778                 txdata_constr.data[y] = txdata_conv_24_conv;
14779         }
14780         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14781         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14782         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14783                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14784                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14785         }
14786         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14787         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14788                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14789                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14790         }
14791         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14792         if (logger_conv.free == LDKLogger_JCalls_free) {
14793                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14794                 LDKLogger_JCalls_cloned(&logger_conv);
14795         }
14796         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);
14797         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14798         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14799         for (size_t u = 0; u < ret_var.datalen; u++) {
14800                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14801                 *ret_conv_46_ref = ret_var.data[u];
14802                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14803         }
14804         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14805         FREE(ret_var.data);
14806         return ret_arr;
14807 }
14808
14809 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) {
14810         LDKChannelMonitor this_arg_conv;
14811         this_arg_conv.inner = (void*)(this_arg & (~1));
14812         this_arg_conv.is_owned = false;
14813         unsigned char header_arr[80];
14814         CHECK((*env)->GetArrayLength(env, header) == 80);
14815         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14816         unsigned char (*header_ref)[80] = &header_arr;
14817         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14818         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14819                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14820                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14821         }
14822         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14823         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14824                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14825                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14826         }
14827         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14828         if (logger_conv.free == LDKLogger_JCalls_free) {
14829                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14830                 LDKLogger_JCalls_cloned(&logger_conv);
14831         }
14832         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14833 }
14834
14835 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) {
14836         LDKChannelMonitor this_arg_conv;
14837         this_arg_conv.inner = (void*)(this_arg & (~1));
14838         this_arg_conv.is_owned = false;
14839         unsigned char header_arr[80];
14840         CHECK((*env)->GetArrayLength(env, header) == 80);
14841         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14842         unsigned char (*header_ref)[80] = &header_arr;
14843         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14844         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14845         if (txdata_constr.datalen > 0)
14846                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14847         else
14848                 txdata_constr.data = NULL;
14849         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14850         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14851                 int64_t txdata_conv_24 = txdata_vals[y];
14852                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14853                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14854                 txdata_constr.data[y] = txdata_conv_24_conv;
14855         }
14856         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14857         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14858         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14859                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14860                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14861         }
14862         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14863         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14864                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14865                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14866         }
14867         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14868         if (logger_conv.free == LDKLogger_JCalls_free) {
14869                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14870                 LDKLogger_JCalls_cloned(&logger_conv);
14871         }
14872         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);
14873         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14874         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14875         for (size_t u = 0; u < ret_var.datalen; u++) {
14876                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14877                 *ret_conv_46_ref = ret_var.data[u];
14878                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14879         }
14880         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14881         FREE(ret_var.data);
14882         return ret_arr;
14883 }
14884
14885 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) {
14886         LDKChannelMonitor this_arg_conv;
14887         this_arg_conv.inner = (void*)(this_arg & (~1));
14888         this_arg_conv.is_owned = false;
14889         unsigned char txid_arr[32];
14890         CHECK((*env)->GetArrayLength(env, txid) == 32);
14891         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
14892         unsigned char (*txid_ref)[32] = &txid_arr;
14893         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14894         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14895                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14896                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14897         }
14898         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14899         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14900                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14901                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14902         }
14903         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14904         if (logger_conv.free == LDKLogger_JCalls_free) {
14905                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14906                 LDKLogger_JCalls_cloned(&logger_conv);
14907         }
14908         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
14909 }
14910
14911 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) {
14912         LDKChannelMonitor this_arg_conv;
14913         this_arg_conv.inner = (void*)(this_arg & (~1));
14914         this_arg_conv.is_owned = false;
14915         unsigned char header_arr[80];
14916         CHECK((*env)->GetArrayLength(env, header) == 80);
14917         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14918         unsigned char (*header_ref)[80] = &header_arr;
14919         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14920         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14921                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14922                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14923         }
14924         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14925         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14926                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14927                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14928         }
14929         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14930         if (logger_conv.free == LDKLogger_JCalls_free) {
14931                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14932                 LDKLogger_JCalls_cloned(&logger_conv);
14933         }
14934         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14935         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14936         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14937         for (size_t u = 0; u < ret_var.datalen; u++) {
14938                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14939                 *ret_conv_46_ref = ret_var.data[u];
14940                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14941         }
14942         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14943         FREE(ret_var.data);
14944         return ret_arr;
14945 }
14946
14947 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
14948         LDKChannelMonitor this_arg_conv;
14949         this_arg_conv.inner = (void*)(this_arg & (~1));
14950         this_arg_conv.is_owned = false;
14951         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14952         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14953         ;
14954         for (size_t i = 0; i < ret_var.datalen; i++) {
14955                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
14956                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
14957                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14958         }
14959         FREE(ret_var.data);
14960         return ret_arr;
14961 }
14962
14963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
14964         LDKChannelMonitor this_arg_conv;
14965         this_arg_conv.inner = (void*)(this_arg & (~1));
14966         this_arg_conv.is_owned = false;
14967         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
14968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14970         uint64_t ret_ref = (uint64_t)ret_var.inner;
14971         if (ret_var.is_owned) {
14972                 ret_ref |= 1;
14973         }
14974         return ret_ref;
14975 }
14976
14977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14978         if ((this_ptr & 1) != 0) return;
14979         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
14980         FREE((void*)this_ptr);
14981         Persist_free(this_ptr_conv);
14982 }
14983
14984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
14985         LDKu8slice ser_ref;
14986         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14987         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14988         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14989         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14990         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14991         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14992         return (uint64_t)ret_conv;
14993 }
14994
14995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14996         LDKOutPoint this_obj_conv;
14997         this_obj_conv.inner = (void*)(this_obj & (~1));
14998         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14999         OutPoint_free(this_obj_conv);
15000 }
15001
15002 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
15003         LDKOutPoint this_ptr_conv;
15004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15005         this_ptr_conv.is_owned = false;
15006         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15007         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
15008         return ret_arr;
15009 }
15010
15011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15012         LDKOutPoint this_ptr_conv;
15013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15014         this_ptr_conv.is_owned = false;
15015         LDKThirtyTwoBytes val_ref;
15016         CHECK((*env)->GetArrayLength(env, val) == 32);
15017         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15018         OutPoint_set_txid(&this_ptr_conv, val_ref);
15019 }
15020
15021 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
15022         LDKOutPoint this_ptr_conv;
15023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15024         this_ptr_conv.is_owned = false;
15025         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
15026         return ret_val;
15027 }
15028
15029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15030         LDKOutPoint this_ptr_conv;
15031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15032         this_ptr_conv.is_owned = false;
15033         OutPoint_set_index(&this_ptr_conv, val);
15034 }
15035
15036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
15037         LDKThirtyTwoBytes txid_arg_ref;
15038         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
15039         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
15040         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
15041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15043         uint64_t ret_ref = (uint64_t)ret_var.inner;
15044         if (ret_var.is_owned) {
15045                 ret_ref |= 1;
15046         }
15047         return ret_ref;
15048 }
15049
15050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15051         LDKOutPoint orig_conv;
15052         orig_conv.inner = (void*)(orig & (~1));
15053         orig_conv.is_owned = false;
15054         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
15055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15057         uint64_t ret_ref = (uint64_t)ret_var.inner;
15058         if (ret_var.is_owned) {
15059                 ret_ref |= 1;
15060         }
15061         return ret_ref;
15062 }
15063
15064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
15065         LDKOutPoint a_conv;
15066         a_conv.inner = (void*)(a & (~1));
15067         a_conv.is_owned = false;
15068         LDKOutPoint b_conv;
15069         b_conv.inner = (void*)(b & (~1));
15070         b_conv.is_owned = false;
15071         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
15072         return ret_val;
15073 }
15074
15075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
15076         LDKOutPoint o_conv;
15077         o_conv.inner = (void*)(o & (~1));
15078         o_conv.is_owned = false;
15079         int64_t ret_val = OutPoint_hash(&o_conv);
15080         return ret_val;
15081 }
15082
15083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15084         LDKOutPoint this_arg_conv;
15085         this_arg_conv.inner = (void*)(this_arg & (~1));
15086         this_arg_conv.is_owned = false;
15087         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15088         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
15089         return ret_arr;
15090 }
15091
15092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
15093         LDKOutPoint obj_conv;
15094         obj_conv.inner = (void*)(obj & (~1));
15095         obj_conv.is_owned = false;
15096         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
15097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15099         CVec_u8Z_free(ret_var);
15100         return ret_arr;
15101 }
15102
15103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15104         LDKu8slice ser_ref;
15105         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15106         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15107         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15108         *ret_conv = OutPoint_read(ser_ref);
15109         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15110         return (uint64_t)ret_conv;
15111 }
15112
15113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15114         LDKDelayedPaymentOutputDescriptor this_obj_conv;
15115         this_obj_conv.inner = (void*)(this_obj & (~1));
15116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15117         DelayedPaymentOutputDescriptor_free(this_obj_conv);
15118 }
15119
15120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15121         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15123         this_ptr_conv.is_owned = false;
15124         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15127         uint64_t ret_ref = (uint64_t)ret_var.inner;
15128         if (ret_var.is_owned) {
15129                 ret_ref |= 1;
15130         }
15131         return ret_ref;
15132 }
15133
15134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15135         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15137         this_ptr_conv.is_owned = false;
15138         LDKOutPoint val_conv;
15139         val_conv.inner = (void*)(val & (~1));
15140         val_conv.is_owned = (val & 1) || (val == 0);
15141         val_conv = OutPoint_clone(&val_conv);
15142         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15143 }
15144
15145 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15146         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15148         this_ptr_conv.is_owned = false;
15149         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
15151         return ret_arr;
15152 }
15153
15154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15155         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15157         this_ptr_conv.is_owned = false;
15158         LDKPublicKey val_ref;
15159         CHECK((*env)->GetArrayLength(env, val) == 33);
15160         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15161         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
15162 }
15163
15164 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
15165         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15167         this_ptr_conv.is_owned = false;
15168         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
15169         return ret_val;
15170 }
15171
15172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15173         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15175         this_ptr_conv.is_owned = false;
15176         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
15177 }
15178
15179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15180         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15182         this_ptr_conv.is_owned = false;
15183         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15184         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15185 }
15186
15187 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
15188         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15190         this_ptr_conv.is_owned = false;
15191         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15192         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
15193         return ret_arr;
15194 }
15195
15196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15197         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15199         this_ptr_conv.is_owned = false;
15200         LDKPublicKey val_ref;
15201         CHECK((*env)->GetArrayLength(env, val) == 33);
15202         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15203         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
15204 }
15205
15206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15207         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15209         this_ptr_conv.is_owned = false;
15210         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15212         return ret_arr;
15213 }
15214
15215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15216         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15218         this_ptr_conv.is_owned = false;
15219         LDKThirtyTwoBytes val_ref;
15220         CHECK((*env)->GetArrayLength(env, val) == 32);
15221         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15222         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15223 }
15224
15225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15226         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15228         this_ptr_conv.is_owned = false;
15229         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15230         return ret_val;
15231 }
15232
15233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15234         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15236         this_ptr_conv.is_owned = false;
15237         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15238 }
15239
15240 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) {
15241         LDKOutPoint outpoint_arg_conv;
15242         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15243         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15244         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15245         LDKPublicKey per_commitment_point_arg_ref;
15246         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
15247         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
15248         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15249         LDKPublicKey revocation_pubkey_arg_ref;
15250         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
15251         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
15252         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15253         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15254         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15255         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);
15256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15258         uint64_t ret_ref = (uint64_t)ret_var.inner;
15259         if (ret_var.is_owned) {
15260                 ret_ref |= 1;
15261         }
15262         return ret_ref;
15263 }
15264
15265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15266         LDKDelayedPaymentOutputDescriptor orig_conv;
15267         orig_conv.inner = (void*)(orig & (~1));
15268         orig_conv.is_owned = false;
15269         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
15270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15272         uint64_t ret_ref = (uint64_t)ret_var.inner;
15273         if (ret_var.is_owned) {
15274                 ret_ref |= 1;
15275         }
15276         return ret_ref;
15277 }
15278
15279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15280         LDKDelayedPaymentOutputDescriptor obj_conv;
15281         obj_conv.inner = (void*)(obj & (~1));
15282         obj_conv.is_owned = false;
15283         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
15284         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15285         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15286         CVec_u8Z_free(ret_var);
15287         return ret_arr;
15288 }
15289
15290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15291         LDKu8slice ser_ref;
15292         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15293         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15294         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15295         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
15296         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15297         return (uint64_t)ret_conv;
15298 }
15299
15300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15301         LDKStaticPaymentOutputDescriptor this_obj_conv;
15302         this_obj_conv.inner = (void*)(this_obj & (~1));
15303         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15304         StaticPaymentOutputDescriptor_free(this_obj_conv);
15305 }
15306
15307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15308         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15310         this_ptr_conv.is_owned = false;
15311         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15312         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15313         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15314         uint64_t ret_ref = (uint64_t)ret_var.inner;
15315         if (ret_var.is_owned) {
15316                 ret_ref |= 1;
15317         }
15318         return ret_ref;
15319 }
15320
15321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15322         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15324         this_ptr_conv.is_owned = false;
15325         LDKOutPoint val_conv;
15326         val_conv.inner = (void*)(val & (~1));
15327         val_conv.is_owned = (val & 1) || (val == 0);
15328         val_conv = OutPoint_clone(&val_conv);
15329         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15330 }
15331
15332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15333         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15335         this_ptr_conv.is_owned = false;
15336         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15337         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15338 }
15339
15340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15341         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15343         this_ptr_conv.is_owned = false;
15344         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15345         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15346         return ret_arr;
15347 }
15348
15349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15350         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15352         this_ptr_conv.is_owned = false;
15353         LDKThirtyTwoBytes val_ref;
15354         CHECK((*env)->GetArrayLength(env, val) == 32);
15355         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15356         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15357 }
15358
15359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15360         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15362         this_ptr_conv.is_owned = false;
15363         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15364         return ret_val;
15365 }
15366
15367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15368         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15370         this_ptr_conv.is_owned = false;
15371         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15372 }
15373
15374 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) {
15375         LDKOutPoint outpoint_arg_conv;
15376         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15377         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15378         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15379         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15380         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15381         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15382         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15383         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
15384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15386         uint64_t ret_ref = (uint64_t)ret_var.inner;
15387         if (ret_var.is_owned) {
15388                 ret_ref |= 1;
15389         }
15390         return ret_ref;
15391 }
15392
15393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15394         LDKStaticPaymentOutputDescriptor orig_conv;
15395         orig_conv.inner = (void*)(orig & (~1));
15396         orig_conv.is_owned = false;
15397         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
15398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15400         uint64_t ret_ref = (uint64_t)ret_var.inner;
15401         if (ret_var.is_owned) {
15402                 ret_ref |= 1;
15403         }
15404         return ret_ref;
15405 }
15406
15407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15408         LDKStaticPaymentOutputDescriptor obj_conv;
15409         obj_conv.inner = (void*)(obj & (~1));
15410         obj_conv.is_owned = false;
15411         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
15412         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15413         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15414         CVec_u8Z_free(ret_var);
15415         return ret_arr;
15416 }
15417
15418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15419         LDKu8slice ser_ref;
15420         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15421         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15422         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15423         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
15424         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15425         return (uint64_t)ret_conv;
15426 }
15427
15428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15429         if ((this_ptr & 1) != 0) return;
15430         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
15431         FREE((void*)this_ptr);
15432         SpendableOutputDescriptor_free(this_ptr_conv);
15433 }
15434
15435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15436         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
15437         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15438         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
15439         uint64_t ret_ref = (uint64_t)ret_copy;
15440         return ret_ref;
15441 }
15442
15443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15444         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
15445         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
15446         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15447         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15448         CVec_u8Z_free(ret_var);
15449         return ret_arr;
15450 }
15451
15452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15453         LDKu8slice ser_ref;
15454         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15455         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15456         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15457         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
15458         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15459         return (uint64_t)ret_conv;
15460 }
15461
15462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15463         if ((this_ptr & 1) != 0) return;
15464         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
15465         FREE((void*)this_ptr);
15466         BaseSign_free(this_ptr_conv);
15467 }
15468
15469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15470         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
15471         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15472         *ret = Sign_clone(orig_conv);
15473         return (uint64_t)ret;
15474 }
15475
15476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15477         if ((this_ptr & 1) != 0) return;
15478         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
15479         FREE((void*)this_ptr);
15480         Sign_free(this_ptr_conv);
15481 }
15482
15483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15484         if ((this_ptr & 1) != 0) return;
15485         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
15486         FREE((void*)this_ptr);
15487         KeysInterface_free(this_ptr_conv);
15488 }
15489
15490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15491         LDKInMemorySigner this_obj_conv;
15492         this_obj_conv.inner = (void*)(this_obj & (~1));
15493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15494         InMemorySigner_free(this_obj_conv);
15495 }
15496
15497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15498         LDKInMemorySigner this_ptr_conv;
15499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15500         this_ptr_conv.is_owned = false;
15501         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15502         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
15503         return ret_arr;
15504 }
15505
15506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15507         LDKInMemorySigner this_ptr_conv;
15508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15509         this_ptr_conv.is_owned = false;
15510         LDKSecretKey val_ref;
15511         CHECK((*env)->GetArrayLength(env, val) == 32);
15512         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15513         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
15514 }
15515
15516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15517         LDKInMemorySigner this_ptr_conv;
15518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15519         this_ptr_conv.is_owned = false;
15520         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15521         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
15522         return ret_arr;
15523 }
15524
15525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15526         LDKInMemorySigner this_ptr_conv;
15527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15528         this_ptr_conv.is_owned = false;
15529         LDKSecretKey val_ref;
15530         CHECK((*env)->GetArrayLength(env, val) == 32);
15531         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15532         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
15533 }
15534
15535 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15536         LDKInMemorySigner this_ptr_conv;
15537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15538         this_ptr_conv.is_owned = false;
15539         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15540         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
15541         return ret_arr;
15542 }
15543
15544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15545         LDKInMemorySigner this_ptr_conv;
15546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15547         this_ptr_conv.is_owned = false;
15548         LDKSecretKey val_ref;
15549         CHECK((*env)->GetArrayLength(env, val) == 32);
15550         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15551         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
15552 }
15553
15554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15555         LDKInMemorySigner this_ptr_conv;
15556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15557         this_ptr_conv.is_owned = false;
15558         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
15560         return ret_arr;
15561 }
15562
15563 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) {
15564         LDKInMemorySigner this_ptr_conv;
15565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15566         this_ptr_conv.is_owned = false;
15567         LDKSecretKey val_ref;
15568         CHECK((*env)->GetArrayLength(env, val) == 32);
15569         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15570         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
15571 }
15572
15573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15574         LDKInMemorySigner this_ptr_conv;
15575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15576         this_ptr_conv.is_owned = false;
15577         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
15579         return ret_arr;
15580 }
15581
15582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15583         LDKInMemorySigner this_ptr_conv;
15584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15585         this_ptr_conv.is_owned = false;
15586         LDKSecretKey val_ref;
15587         CHECK((*env)->GetArrayLength(env, val) == 32);
15588         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15589         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
15590 }
15591
15592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
15593         LDKInMemorySigner this_ptr_conv;
15594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15595         this_ptr_conv.is_owned = false;
15596         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15597         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
15598         return ret_arr;
15599 }
15600
15601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15602         LDKInMemorySigner this_ptr_conv;
15603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15604         this_ptr_conv.is_owned = false;
15605         LDKThirtyTwoBytes val_ref;
15606         CHECK((*env)->GetArrayLength(env, val) == 32);
15607         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15608         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
15609 }
15610
15611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15612         LDKInMemorySigner orig_conv;
15613         orig_conv.inner = (void*)(orig & (~1));
15614         orig_conv.is_owned = false;
15615         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
15616         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15617         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15618         uint64_t ret_ref = (uint64_t)ret_var.inner;
15619         if (ret_var.is_owned) {
15620                 ret_ref |= 1;
15621         }
15622         return ret_ref;
15623 }
15624
15625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, 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) {
15626         LDKSecretKey funding_key_ref;
15627         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
15628         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
15629         LDKSecretKey revocation_base_key_ref;
15630         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
15631         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
15632         LDKSecretKey payment_key_ref;
15633         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
15634         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
15635         LDKSecretKey delayed_payment_base_key_ref;
15636         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
15637         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
15638         LDKSecretKey htlc_base_key_ref;
15639         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
15640         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
15641         LDKThirtyTwoBytes commitment_seed_ref;
15642         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
15643         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
15644         LDKThirtyTwoBytes channel_keys_id_ref;
15645         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
15646         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
15647         LDKInMemorySigner ret_var = InMemorySigner_new(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);
15648         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15649         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15650         uint64_t ret_ref = (uint64_t)ret_var.inner;
15651         if (ret_var.is_owned) {
15652                 ret_ref |= 1;
15653         }
15654         return ret_ref;
15655 }
15656
15657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
15658         LDKInMemorySigner this_arg_conv;
15659         this_arg_conv.inner = (void*)(this_arg & (~1));
15660         this_arg_conv.is_owned = false;
15661         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
15662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15664         uint64_t ret_ref = (uint64_t)ret_var.inner;
15665         if (ret_var.is_owned) {
15666                 ret_ref |= 1;
15667         }
15668         return ret_ref;
15669 }
15670
15671 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15672         LDKInMemorySigner this_arg_conv;
15673         this_arg_conv.inner = (void*)(this_arg & (~1));
15674         this_arg_conv.is_owned = false;
15675         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
15676         return ret_val;
15677 }
15678
15679 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15680         LDKInMemorySigner this_arg_conv;
15681         this_arg_conv.inner = (void*)(this_arg & (~1));
15682         this_arg_conv.is_owned = false;
15683         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
15684         return ret_val;
15685 }
15686
15687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
15688         LDKInMemorySigner this_arg_conv;
15689         this_arg_conv.inner = (void*)(this_arg & (~1));
15690         this_arg_conv.is_owned = false;
15691         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
15692         return ret_val;
15693 }
15694
15695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
15696         LDKInMemorySigner this_arg_conv;
15697         this_arg_conv.inner = (void*)(this_arg & (~1));
15698         this_arg_conv.is_owned = false;
15699         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
15700         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15701         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15702         uint64_t ret_ref = (uint64_t)ret_var.inner;
15703         if (ret_var.is_owned) {
15704                 ret_ref |= 1;
15705         }
15706         return ret_ref;
15707 }
15708
15709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
15710         LDKInMemorySigner this_arg_conv;
15711         this_arg_conv.inner = (void*)(this_arg & (~1));
15712         this_arg_conv.is_owned = false;
15713         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
15714         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15715         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15716         uint64_t ret_ref = (uint64_t)ret_var.inner;
15717         if (ret_var.is_owned) {
15718                 ret_ref |= 1;
15719         }
15720         return ret_ref;
15721 }
15722
15723 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) {
15724         LDKInMemorySigner this_arg_conv;
15725         this_arg_conv.inner = (void*)(this_arg & (~1));
15726         this_arg_conv.is_owned = false;
15727         LDKTransaction spend_tx_ref;
15728         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15729         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15730         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15731         spend_tx_ref.data_is_owned = true;
15732         LDKStaticPaymentOutputDescriptor descriptor_conv;
15733         descriptor_conv.inner = (void*)(descriptor & (~1));
15734         descriptor_conv.is_owned = false;
15735         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15736         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15737         return (uint64_t)ret_conv;
15738 }
15739
15740 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) {
15741         LDKInMemorySigner this_arg_conv;
15742         this_arg_conv.inner = (void*)(this_arg & (~1));
15743         this_arg_conv.is_owned = false;
15744         LDKTransaction spend_tx_ref;
15745         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15746         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15747         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15748         spend_tx_ref.data_is_owned = true;
15749         LDKDelayedPaymentOutputDescriptor descriptor_conv;
15750         descriptor_conv.inner = (void*)(descriptor & (~1));
15751         descriptor_conv.is_owned = false;
15752         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15753         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15754         return (uint64_t)ret_conv;
15755 }
15756
15757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
15758         LDKInMemorySigner this_arg_conv;
15759         this_arg_conv.inner = (void*)(this_arg & (~1));
15760         this_arg_conv.is_owned = false;
15761         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
15762         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
15763         return (uint64_t)ret;
15764 }
15765
15766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
15767         LDKInMemorySigner this_arg_conv;
15768         this_arg_conv.inner = (void*)(this_arg & (~1));
15769         this_arg_conv.is_owned = false;
15770         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15771         *ret = InMemorySigner_as_Sign(&this_arg_conv);
15772         return (uint64_t)ret;
15773 }
15774
15775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
15776         LDKInMemorySigner obj_conv;
15777         obj_conv.inner = (void*)(obj & (~1));
15778         obj_conv.is_owned = false;
15779         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
15780         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15781         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15782         CVec_u8Z_free(ret_var);
15783         return ret_arr;
15784 }
15785
15786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15787         LDKu8slice ser_ref;
15788         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15789         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15790         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15791         *ret_conv = InMemorySigner_read(ser_ref);
15792         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15793         return (uint64_t)ret_conv;
15794 }
15795
15796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15797         LDKKeysManager this_obj_conv;
15798         this_obj_conv.inner = (void*)(this_obj & (~1));
15799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15800         KeysManager_free(this_obj_conv);
15801 }
15802
15803 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) {
15804         unsigned char seed_arr[32];
15805         CHECK((*env)->GetArrayLength(env, seed) == 32);
15806         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
15807         unsigned char (*seed_ref)[32] = &seed_arr;
15808         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
15809         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15810         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15811         uint64_t ret_ref = (uint64_t)ret_var.inner;
15812         if (ret_var.is_owned) {
15813                 ret_ref |= 1;
15814         }
15815         return ret_ref;
15816 }
15817
15818 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) {
15819         LDKKeysManager this_arg_conv;
15820         this_arg_conv.inner = (void*)(this_arg & (~1));
15821         this_arg_conv.is_owned = false;
15822         unsigned char params_arr[32];
15823         CHECK((*env)->GetArrayLength(env, params) == 32);
15824         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
15825         unsigned char (*params_ref)[32] = &params_arr;
15826         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
15827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15829         uint64_t ret_ref = (uint64_t)ret_var.inner;
15830         if (ret_var.is_owned) {
15831                 ret_ref |= 1;
15832         }
15833         return ret_ref;
15834 }
15835
15836 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) {
15837         LDKKeysManager this_arg_conv;
15838         this_arg_conv.inner = (void*)(this_arg & (~1));
15839         this_arg_conv.is_owned = false;
15840         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
15841         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
15842         if (descriptors_constr.datalen > 0)
15843                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15844         else
15845                 descriptors_constr.data = NULL;
15846         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
15847         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
15848                 int64_t descriptors_conv_27 = descriptors_vals[b];
15849                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
15850                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
15851                 descriptors_constr.data[b] = descriptors_conv_27_conv;
15852         }
15853         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
15854         LDKCVec_TxOutZ outputs_constr;
15855         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15856         if (outputs_constr.datalen > 0)
15857                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15858         else
15859                 outputs_constr.data = NULL;
15860         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15861         for (size_t h = 0; h < outputs_constr.datalen; h++) {
15862                 int64_t outputs_conv_7 = outputs_vals[h];
15863                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
15864                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
15865                 outputs_constr.data[h] = outputs_conv_7_conv;
15866         }
15867         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15868         LDKCVec_u8Z change_destination_script_ref;
15869         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
15870         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
15871         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
15872         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15873         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
15874         return (uint64_t)ret_conv;
15875 }
15876
15877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
15878         LDKKeysManager this_arg_conv;
15879         this_arg_conv.inner = (void*)(this_arg & (~1));
15880         this_arg_conv.is_owned = false;
15881         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15882         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
15883         return (uint64_t)ret;
15884 }
15885
15886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15887         LDKChannelManager this_obj_conv;
15888         this_obj_conv.inner = (void*)(this_obj & (~1));
15889         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15890         ChannelManager_free(this_obj_conv);
15891 }
15892
15893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15894         LDKChainParameters this_obj_conv;
15895         this_obj_conv.inner = (void*)(this_obj & (~1));
15896         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15897         ChainParameters_free(this_obj_conv);
15898 }
15899
15900 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
15901         LDKChainParameters this_ptr_conv;
15902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15903         this_ptr_conv.is_owned = false;
15904         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
15905         return ret_conv;
15906 }
15907
15908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
15909         LDKChainParameters this_ptr_conv;
15910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15911         this_ptr_conv.is_owned = false;
15912         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
15913         ChainParameters_set_network(&this_ptr_conv, val_conv);
15914 }
15915
15916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
15917         LDKChainParameters this_ptr_conv;
15918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15919         this_ptr_conv.is_owned = false;
15920         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15921         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15922         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15923         uint64_t ret_ref = (uint64_t)ret_var.inner;
15924         if (ret_var.is_owned) {
15925                 ret_ref |= 1;
15926         }
15927         return ret_ref;
15928 }
15929
15930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15931         LDKChainParameters this_ptr_conv;
15932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15933         this_ptr_conv.is_owned = false;
15934         LDKBestBlock val_conv;
15935         val_conv.inner = (void*)(val & (~1));
15936         val_conv.is_owned = (val & 1) || (val == 0);
15937         val_conv = BestBlock_clone(&val_conv);
15938         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15939 }
15940
15941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
15942         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
15943         LDKBestBlock best_block_arg_conv;
15944         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15945         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15946         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15947         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15950         uint64_t ret_ref = (uint64_t)ret_var.inner;
15951         if (ret_var.is_owned) {
15952                 ret_ref |= 1;
15953         }
15954         return ret_ref;
15955 }
15956
15957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15958         LDKChainParameters orig_conv;
15959         orig_conv.inner = (void*)(orig & (~1));
15960         orig_conv.is_owned = false;
15961         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15964         uint64_t ret_ref = (uint64_t)ret_var.inner;
15965         if (ret_var.is_owned) {
15966                 ret_ref |= 1;
15967         }
15968         return ret_ref;
15969 }
15970
15971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15972         LDKChannelCounterparty this_obj_conv;
15973         this_obj_conv.inner = (void*)(this_obj & (~1));
15974         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15975         ChannelCounterparty_free(this_obj_conv);
15976 }
15977
15978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15979         LDKChannelCounterparty this_ptr_conv;
15980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15981         this_ptr_conv.is_owned = false;
15982         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15983         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
15984         return ret_arr;
15985 }
15986
15987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15988         LDKChannelCounterparty this_ptr_conv;
15989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15990         this_ptr_conv.is_owned = false;
15991         LDKPublicKey val_ref;
15992         CHECK((*env)->GetArrayLength(env, val) == 33);
15993         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15994         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
15995 }
15996
15997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15998         LDKChannelCounterparty this_ptr_conv;
15999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16000         this_ptr_conv.is_owned = false;
16001         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
16002         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16003         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16004         uint64_t ret_ref = (uint64_t)ret_var.inner;
16005         if (ret_var.is_owned) {
16006                 ret_ref |= 1;
16007         }
16008         return ret_ref;
16009 }
16010
16011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16012         LDKChannelCounterparty this_ptr_conv;
16013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16014         this_ptr_conv.is_owned = false;
16015         LDKInitFeatures val_conv;
16016         val_conv.inner = (void*)(val & (~1));
16017         val_conv.is_owned = (val & 1) || (val == 0);
16018         val_conv = InitFeatures_clone(&val_conv);
16019         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
16020 }
16021
16022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16023         LDKChannelCounterparty this_ptr_conv;
16024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16025         this_ptr_conv.is_owned = false;
16026         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
16027         return ret_val;
16028 }
16029
16030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16031         LDKChannelCounterparty this_ptr_conv;
16032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16033         this_ptr_conv.is_owned = false;
16034         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
16035 }
16036
16037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16038         LDKChannelCounterparty orig_conv;
16039         orig_conv.inner = (void*)(orig & (~1));
16040         orig_conv.is_owned = false;
16041         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
16042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16044         uint64_t ret_ref = (uint64_t)ret_var.inner;
16045         if (ret_var.is_owned) {
16046                 ret_ref |= 1;
16047         }
16048         return ret_ref;
16049 }
16050
16051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16052         LDKChannelDetails this_obj_conv;
16053         this_obj_conv.inner = (void*)(this_obj & (~1));
16054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16055         ChannelDetails_free(this_obj_conv);
16056 }
16057
16058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16059         LDKChannelDetails this_ptr_conv;
16060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16061         this_ptr_conv.is_owned = false;
16062         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
16064         return ret_arr;
16065 }
16066
16067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16068         LDKChannelDetails this_ptr_conv;
16069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16070         this_ptr_conv.is_owned = false;
16071         LDKThirtyTwoBytes val_ref;
16072         CHECK((*env)->GetArrayLength(env, val) == 32);
16073         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16074         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
16075 }
16076
16077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
16078         LDKChannelDetails this_ptr_conv;
16079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16080         this_ptr_conv.is_owned = false;
16081         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
16082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16084         uint64_t ret_ref = (uint64_t)ret_var.inner;
16085         if (ret_var.is_owned) {
16086                 ret_ref |= 1;
16087         }
16088         return ret_ref;
16089 }
16090
16091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16092         LDKChannelDetails this_ptr_conv;
16093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16094         this_ptr_conv.is_owned = false;
16095         LDKChannelCounterparty val_conv;
16096         val_conv.inner = (void*)(val & (~1));
16097         val_conv.is_owned = (val & 1) || (val == 0);
16098         val_conv = ChannelCounterparty_clone(&val_conv);
16099         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
16100 }
16101
16102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
16103         LDKChannelDetails this_ptr_conv;
16104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16105         this_ptr_conv.is_owned = false;
16106         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
16107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16109         uint64_t ret_ref = (uint64_t)ret_var.inner;
16110         if (ret_var.is_owned) {
16111                 ret_ref |= 1;
16112         }
16113         return ret_ref;
16114 }
16115
16116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16117         LDKChannelDetails this_ptr_conv;
16118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16119         this_ptr_conv.is_owned = false;
16120         LDKOutPoint val_conv;
16121         val_conv.inner = (void*)(val & (~1));
16122         val_conv.is_owned = (val & 1) || (val == 0);
16123         val_conv = OutPoint_clone(&val_conv);
16124         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
16125 }
16126
16127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16128         LDKChannelDetails this_ptr_conv;
16129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16130         this_ptr_conv.is_owned = false;
16131         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16132         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
16133         uint64_t ret_ref = (uint64_t)ret_copy;
16134         return ret_ref;
16135 }
16136
16137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16138         LDKChannelDetails this_ptr_conv;
16139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16140         this_ptr_conv.is_owned = false;
16141         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16142         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
16143 }
16144
16145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16146         LDKChannelDetails this_ptr_conv;
16147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16148         this_ptr_conv.is_owned = false;
16149         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
16150         return ret_val;
16151 }
16152
16153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16154         LDKChannelDetails this_ptr_conv;
16155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16156         this_ptr_conv.is_owned = false;
16157         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
16158 }
16159
16160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16161         LDKChannelDetails this_ptr_conv;
16162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16163         this_ptr_conv.is_owned = false;
16164         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16165         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
16166         uint64_t ret_ref = (uint64_t)ret_copy;
16167         return ret_ref;
16168 }
16169
16170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16171         LDKChannelDetails this_ptr_conv;
16172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16173         this_ptr_conv.is_owned = false;
16174         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16175         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
16176 }
16177
16178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16179         LDKChannelDetails this_ptr_conv;
16180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16181         this_ptr_conv.is_owned = false;
16182         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
16183         return ret_val;
16184 }
16185
16186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16187         LDKChannelDetails this_ptr_conv;
16188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16189         this_ptr_conv.is_owned = false;
16190         ChannelDetails_set_user_id(&this_ptr_conv, val);
16191 }
16192
16193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16194         LDKChannelDetails this_ptr_conv;
16195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16196         this_ptr_conv.is_owned = false;
16197         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
16198         return ret_val;
16199 }
16200
16201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16202         LDKChannelDetails this_ptr_conv;
16203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16204         this_ptr_conv.is_owned = false;
16205         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
16206 }
16207
16208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16209         LDKChannelDetails this_ptr_conv;
16210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16211         this_ptr_conv.is_owned = false;
16212         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
16213         return ret_val;
16214 }
16215
16216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16217         LDKChannelDetails this_ptr_conv;
16218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16219         this_ptr_conv.is_owned = false;
16220         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16221 }
16222
16223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
16224         LDKChannelDetails this_ptr_conv;
16225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16226         this_ptr_conv.is_owned = false;
16227         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16228         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16229         uint64_t ret_ref = (uint64_t)ret_copy;
16230         return ret_ref;
16231 }
16232
16233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16234         LDKChannelDetails this_ptr_conv;
16235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16236         this_ptr_conv.is_owned = false;
16237         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16238         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16239 }
16240
16241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16242         LDKChannelDetails this_ptr_conv;
16243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16244         this_ptr_conv.is_owned = false;
16245         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16246         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16247         uint64_t ret_ref = (uint64_t)ret_copy;
16248         return ret_ref;
16249 }
16250
16251 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) {
16252         LDKChannelDetails this_ptr_conv;
16253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16254         this_ptr_conv.is_owned = false;
16255         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16256         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16257 }
16258
16259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
16260         LDKChannelDetails this_ptr_conv;
16261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16262         this_ptr_conv.is_owned = false;
16263         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16264         return ret_val;
16265 }
16266
16267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16268         LDKChannelDetails this_ptr_conv;
16269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16270         this_ptr_conv.is_owned = false;
16271         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16272 }
16273
16274 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
16275         LDKChannelDetails this_ptr_conv;
16276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16277         this_ptr_conv.is_owned = false;
16278         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16279         return ret_val;
16280 }
16281
16282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16283         LDKChannelDetails this_ptr_conv;
16284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16285         this_ptr_conv.is_owned = false;
16286         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16287 }
16288
16289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
16290         LDKChannelDetails this_ptr_conv;
16291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16292         this_ptr_conv.is_owned = false;
16293         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16294         return ret_val;
16295 }
16296
16297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16298         LDKChannelDetails this_ptr_conv;
16299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16300         this_ptr_conv.is_owned = false;
16301         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16302 }
16303
16304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
16305         LDKChannelDetails this_ptr_conv;
16306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16307         this_ptr_conv.is_owned = false;
16308         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16309         return ret_val;
16310 }
16311
16312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16313         LDKChannelDetails this_ptr_conv;
16314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16315         this_ptr_conv.is_owned = false;
16316         ChannelDetails_set_is_public(&this_ptr_conv, val);
16317 }
16318
16319 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 short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_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_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
16320         LDKThirtyTwoBytes channel_id_arg_ref;
16321         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16322         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16323         LDKChannelCounterparty counterparty_arg_conv;
16324         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16325         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16326         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16327         LDKOutPoint funding_txo_arg_conv;
16328         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16329         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16330         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16331         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16332         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16333         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16334         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16335         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
16336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16338         uint64_t ret_ref = (uint64_t)ret_var.inner;
16339         if (ret_var.is_owned) {
16340                 ret_ref |= 1;
16341         }
16342         return ret_ref;
16343 }
16344
16345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16346         LDKChannelDetails orig_conv;
16347         orig_conv.inner = (void*)(orig & (~1));
16348         orig_conv.is_owned = false;
16349         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
16350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16352         uint64_t ret_ref = (uint64_t)ret_var.inner;
16353         if (ret_var.is_owned) {
16354                 ret_ref |= 1;
16355         }
16356         return ret_ref;
16357 }
16358
16359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16360         if ((this_ptr & 1) != 0) return;
16361         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
16362         FREE((void*)this_ptr);
16363         PaymentSendFailure_free(this_ptr_conv);
16364 }
16365
16366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16367         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
16368         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16369         *ret_copy = PaymentSendFailure_clone(orig_conv);
16370         uint64_t ret_ref = (uint64_t)ret_copy;
16371         return ret_ref;
16372 }
16373
16374 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) {
16375         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
16376         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
16377                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16378                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
16379         }
16380         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16381         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16382                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16383                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
16384         }
16385         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16386         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16387                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16388                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
16389         }
16390         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16391         if (logger_conv.free == LDKLogger_JCalls_free) {
16392                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16393                 LDKLogger_JCalls_cloned(&logger_conv);
16394         }
16395         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16396         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16397                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16398                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
16399         }
16400         LDKUserConfig config_conv;
16401         config_conv.inner = (void*)(config & (~1));
16402         config_conv.is_owned = (config & 1) || (config == 0);
16403         config_conv = UserConfig_clone(&config_conv);
16404         LDKChainParameters params_conv;
16405         params_conv.inner = (void*)(params & (~1));
16406         params_conv.is_owned = (params & 1) || (params == 0);
16407         params_conv = ChainParameters_clone(&params_conv);
16408         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
16409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16411         uint64_t ret_ref = (uint64_t)ret_var.inner;
16412         if (ret_var.is_owned) {
16413                 ret_ref |= 1;
16414         }
16415         return ret_ref;
16416 }
16417
16418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
16419         LDKChannelManager this_arg_conv;
16420         this_arg_conv.inner = (void*)(this_arg & (~1));
16421         this_arg_conv.is_owned = false;
16422         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
16423         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16424         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16425         uint64_t ret_ref = (uint64_t)ret_var.inner;
16426         if (ret_var.is_owned) {
16427                 ret_ref |= 1;
16428         }
16429         return ret_ref;
16430 }
16431
16432 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_id, int64_t override_config) {
16433         LDKChannelManager this_arg_conv;
16434         this_arg_conv.inner = (void*)(this_arg & (~1));
16435         this_arg_conv.is_owned = false;
16436         LDKPublicKey their_network_key_ref;
16437         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
16438         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
16439         LDKUserConfig override_config_conv;
16440         override_config_conv.inner = (void*)(override_config & (~1));
16441         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
16442         override_config_conv = UserConfig_clone(&override_config_conv);
16443         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16444         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
16445         return (uint64_t)ret_conv;
16446 }
16447
16448 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16449         LDKChannelManager this_arg_conv;
16450         this_arg_conv.inner = (void*)(this_arg & (~1));
16451         this_arg_conv.is_owned = false;
16452         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
16453         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16454         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16455         for (size_t q = 0; q < ret_var.datalen; q++) {
16456                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16457                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16458                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16459                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16460                 if (ret_conv_16_var.is_owned) {
16461                         ret_conv_16_ref |= 1;
16462                 }
16463                 ret_arr_ptr[q] = ret_conv_16_ref;
16464         }
16465         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16466         FREE(ret_var.data);
16467         return ret_arr;
16468 }
16469
16470 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16471         LDKChannelManager this_arg_conv;
16472         this_arg_conv.inner = (void*)(this_arg & (~1));
16473         this_arg_conv.is_owned = false;
16474         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
16475         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16476         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16477         for (size_t q = 0; q < ret_var.datalen; q++) {
16478                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16479                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16480                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16481                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16482                 if (ret_conv_16_var.is_owned) {
16483                         ret_conv_16_ref |= 1;
16484                 }
16485                 ret_arr_ptr[q] = ret_conv_16_ref;
16486         }
16487         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16488         FREE(ret_var.data);
16489         return ret_arr;
16490 }
16491
16492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
16493         LDKChannelManager this_arg_conv;
16494         this_arg_conv.inner = (void*)(this_arg & (~1));
16495         this_arg_conv.is_owned = false;
16496         unsigned char channel_id_arr[32];
16497         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16498         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16499         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16500         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16501         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
16502         return (uint64_t)ret_conv;
16503 }
16504
16505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
16506         LDKChannelManager this_arg_conv;
16507         this_arg_conv.inner = (void*)(this_arg & (~1));
16508         this_arg_conv.is_owned = false;
16509         unsigned char channel_id_arr[32];
16510         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16511         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16512         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16513         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16514         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
16515         return (uint64_t)ret_conv;
16516 }
16517
16518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16519         LDKChannelManager this_arg_conv;
16520         this_arg_conv.inner = (void*)(this_arg & (~1));
16521         this_arg_conv.is_owned = false;
16522         ChannelManager_force_close_all_channels(&this_arg_conv);
16523 }
16524
16525 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) {
16526         LDKChannelManager this_arg_conv;
16527         this_arg_conv.inner = (void*)(this_arg & (~1));
16528         this_arg_conv.is_owned = false;
16529         LDKRoute route_conv;
16530         route_conv.inner = (void*)(route & (~1));
16531         route_conv.is_owned = false;
16532         LDKThirtyTwoBytes payment_hash_ref;
16533         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16534         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16535         LDKThirtyTwoBytes payment_secret_ref;
16536         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
16537         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
16538         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16539         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
16540         return (uint64_t)ret_conv;
16541 }
16542
16543 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) {
16544         LDKChannelManager this_arg_conv;
16545         this_arg_conv.inner = (void*)(this_arg & (~1));
16546         this_arg_conv.is_owned = false;
16547         LDKRoute route_conv;
16548         route_conv.inner = (void*)(route & (~1));
16549         route_conv.is_owned = false;
16550         LDKThirtyTwoBytes payment_preimage_ref;
16551         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
16552         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
16553         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
16554         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
16555         return (uint64_t)ret_conv;
16556 }
16557
16558 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 funding_transaction) {
16559         LDKChannelManager this_arg_conv;
16560         this_arg_conv.inner = (void*)(this_arg & (~1));
16561         this_arg_conv.is_owned = false;
16562         unsigned char temporary_channel_id_arr[32];
16563         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
16564         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
16565         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
16566         LDKTransaction funding_transaction_ref;
16567         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
16568         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
16569         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
16570         funding_transaction_ref.data_is_owned = true;
16571         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16572         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
16573         return (uint64_t)ret_conv;
16574 }
16575
16576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
16577         LDKChannelManager this_arg_conv;
16578         this_arg_conv.inner = (void*)(this_arg & (~1));
16579         this_arg_conv.is_owned = false;
16580         LDKThreeBytes rgb_ref;
16581         CHECK((*env)->GetArrayLength(env, rgb) == 3);
16582         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
16583         LDKThirtyTwoBytes alias_ref;
16584         CHECK((*env)->GetArrayLength(env, alias) == 32);
16585         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
16586         LDKCVec_NetAddressZ addresses_constr;
16587         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
16588         if (addresses_constr.datalen > 0)
16589                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16590         else
16591                 addresses_constr.data = NULL;
16592         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
16593         for (size_t m = 0; m < addresses_constr.datalen; m++) {
16594                 int64_t addresses_conv_12 = addresses_vals[m];
16595                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
16596                 addresses_constr.data[m] = addresses_conv_12_conv;
16597         }
16598         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
16599         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
16600 }
16601
16602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
16603         LDKChannelManager this_arg_conv;
16604         this_arg_conv.inner = (void*)(this_arg & (~1));
16605         this_arg_conv.is_owned = false;
16606         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
16607 }
16608
16609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
16610         LDKChannelManager this_arg_conv;
16611         this_arg_conv.inner = (void*)(this_arg & (~1));
16612         this_arg_conv.is_owned = false;
16613         ChannelManager_timer_tick_occurred(&this_arg_conv);
16614 }
16615
16616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
16617         LDKChannelManager this_arg_conv;
16618         this_arg_conv.inner = (void*)(this_arg & (~1));
16619         this_arg_conv.is_owned = false;
16620         unsigned char payment_hash_arr[32];
16621         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16622         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
16623         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
16624         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
16625         return ret_val;
16626 }
16627
16628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
16629         LDKChannelManager this_arg_conv;
16630         this_arg_conv.inner = (void*)(this_arg & (~1));
16631         this_arg_conv.is_owned = false;
16632         LDKThirtyTwoBytes payment_preimage_ref;
16633         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
16634         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
16635         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
16636         return ret_val;
16637 }
16638
16639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
16640         LDKChannelManager this_arg_conv;
16641         this_arg_conv.inner = (void*)(this_arg & (~1));
16642         this_arg_conv.is_owned = false;
16643         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
16645         return ret_arr;
16646 }
16647
16648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t highest_applied_update_id) {
16649         LDKChannelManager this_arg_conv;
16650         this_arg_conv.inner = (void*)(this_arg & (~1));
16651         this_arg_conv.is_owned = false;
16652         LDKOutPoint funding_txo_conv;
16653         funding_txo_conv.inner = (void*)(funding_txo & (~1));
16654         funding_txo_conv.is_owned = false;
16655         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
16656 }
16657
16658 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, int64_t user_payment_id) {
16659         LDKChannelManager this_arg_conv;
16660         this_arg_conv.inner = (void*)(this_arg & (~1));
16661         this_arg_conv.is_owned = false;
16662         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16663         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16664         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
16665         return (uint64_t)ret_ref;
16666 }
16667
16668 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, int64_t user_payment_id) {
16669         LDKChannelManager this_arg_conv;
16670         this_arg_conv.inner = (void*)(this_arg & (~1));
16671         this_arg_conv.is_owned = false;
16672         LDKThirtyTwoBytes payment_hash_ref;
16673         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16674         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16675         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16676         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16677         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
16678         return (uint64_t)ret_conv;
16679 }
16680
16681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16682         LDKChannelManager this_arg_conv;
16683         this_arg_conv.inner = (void*)(this_arg & (~1));
16684         this_arg_conv.is_owned = false;
16685         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16686         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
16687         return (uint64_t)ret;
16688 }
16689
16690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16691         LDKChannelManager this_arg_conv;
16692         this_arg_conv.inner = (void*)(this_arg & (~1));
16693         this_arg_conv.is_owned = false;
16694         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
16695         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
16696         return (uint64_t)ret;
16697 }
16698
16699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
16700         LDKChannelManager this_arg_conv;
16701         this_arg_conv.inner = (void*)(this_arg & (~1));
16702         this_arg_conv.is_owned = false;
16703         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
16704         *ret = ChannelManager_as_Listen(&this_arg_conv);
16705         return (uint64_t)ret;
16706 }
16707
16708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
16709         LDKChannelManager this_arg_conv;
16710         this_arg_conv.inner = (void*)(this_arg & (~1));
16711         this_arg_conv.is_owned = false;
16712         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
16713         *ret = ChannelManager_as_Confirm(&this_arg_conv);
16714         return (uint64_t)ret;
16715 }
16716
16717 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) {
16718         LDKChannelManager this_arg_conv;
16719         this_arg_conv.inner = (void*)(this_arg & (~1));
16720         this_arg_conv.is_owned = false;
16721         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
16722         return ret_val;
16723 }
16724
16725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
16726         LDKChannelManager this_arg_conv;
16727         this_arg_conv.inner = (void*)(this_arg & (~1));
16728         this_arg_conv.is_owned = false;
16729         ChannelManager_await_persistable_update(&this_arg_conv);
16730 }
16731
16732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
16733         LDKChannelManager this_arg_conv;
16734         this_arg_conv.inner = (void*)(this_arg & (~1));
16735         this_arg_conv.is_owned = false;
16736         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
16737         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16738         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16739         uint64_t ret_ref = (uint64_t)ret_var.inner;
16740         if (ret_var.is_owned) {
16741                 ret_ref |= 1;
16742         }
16743         return ret_ref;
16744 }
16745
16746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
16747         LDKChannelManager this_arg_conv;
16748         this_arg_conv.inner = (void*)(this_arg & (~1));
16749         this_arg_conv.is_owned = false;
16750         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16751         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
16752         return (uint64_t)ret;
16753 }
16754
16755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
16756         LDKChannelManager obj_conv;
16757         obj_conv.inner = (void*)(obj & (~1));
16758         obj_conv.is_owned = false;
16759         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
16760         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16761         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16762         CVec_u8Z_free(ret_var);
16763         return ret_arr;
16764 }
16765
16766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16767         LDKChannelManagerReadArgs this_obj_conv;
16768         this_obj_conv.inner = (void*)(this_obj & (~1));
16769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16770         ChannelManagerReadArgs_free(this_obj_conv);
16771 }
16772
16773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
16774         LDKChannelManagerReadArgs this_ptr_conv;
16775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16776         this_ptr_conv.is_owned = false;
16777         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
16778         return ret_ret;
16779 }
16780
16781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16782         LDKChannelManagerReadArgs this_ptr_conv;
16783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16784         this_ptr_conv.is_owned = false;
16785         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
16786         if (val_conv.free == LDKKeysInterface_JCalls_free) {
16787                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16788                 LDKKeysInterface_JCalls_cloned(&val_conv);
16789         }
16790         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
16791 }
16792
16793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
16794         LDKChannelManagerReadArgs this_ptr_conv;
16795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16796         this_ptr_conv.is_owned = false;
16797         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
16798         return ret_ret;
16799 }
16800
16801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16802         LDKChannelManagerReadArgs this_ptr_conv;
16803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16804         this_ptr_conv.is_owned = false;
16805         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
16806         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
16807                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16808                 LDKFeeEstimator_JCalls_cloned(&val_conv);
16809         }
16810         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16811 }
16812
16813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
16814         LDKChannelManagerReadArgs this_ptr_conv;
16815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16816         this_ptr_conv.is_owned = false;
16817         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16818         return ret_ret;
16819 }
16820
16821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16822         LDKChannelManagerReadArgs this_ptr_conv;
16823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16824         this_ptr_conv.is_owned = false;
16825         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16826         if (val_conv.free == LDKWatch_JCalls_free) {
16827                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16828                 LDKWatch_JCalls_cloned(&val_conv);
16829         }
16830         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16831 }
16832
16833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
16834         LDKChannelManagerReadArgs this_ptr_conv;
16835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16836         this_ptr_conv.is_owned = false;
16837         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16838         return ret_ret;
16839 }
16840
16841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16842         LDKChannelManagerReadArgs this_ptr_conv;
16843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16844         this_ptr_conv.is_owned = false;
16845         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16846         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
16847                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16848                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
16849         }
16850         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16851 }
16852
16853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
16854         LDKChannelManagerReadArgs this_ptr_conv;
16855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16856         this_ptr_conv.is_owned = false;
16857         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16858         return ret_ret;
16859 }
16860
16861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16862         LDKChannelManagerReadArgs this_ptr_conv;
16863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16864         this_ptr_conv.is_owned = false;
16865         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16866         if (val_conv.free == LDKLogger_JCalls_free) {
16867                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16868                 LDKLogger_JCalls_cloned(&val_conv);
16869         }
16870         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16871 }
16872
16873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16874         LDKChannelManagerReadArgs this_ptr_conv;
16875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16876         this_ptr_conv.is_owned = false;
16877         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
16878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16880         uint64_t ret_ref = (uint64_t)ret_var.inner;
16881         if (ret_var.is_owned) {
16882                 ret_ref |= 1;
16883         }
16884         return ret_ref;
16885 }
16886
16887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16888         LDKChannelManagerReadArgs this_ptr_conv;
16889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16890         this_ptr_conv.is_owned = false;
16891         LDKUserConfig val_conv;
16892         val_conv.inner = (void*)(val & (~1));
16893         val_conv.is_owned = (val & 1) || (val == 0);
16894         val_conv = UserConfig_clone(&val_conv);
16895         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16896 }
16897
16898 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) {
16899         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16900         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16901                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16902                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
16903         }
16904         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16905         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16906                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16907                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
16908         }
16909         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16910         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16911                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16912                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
16913         }
16914         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16915         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16916                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16917                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
16918         }
16919         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16920         if (logger_conv.free == LDKLogger_JCalls_free) {
16921                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16922                 LDKLogger_JCalls_cloned(&logger_conv);
16923         }
16924         LDKUserConfig default_config_conv;
16925         default_config_conv.inner = (void*)(default_config & (~1));
16926         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16927         default_config_conv = UserConfig_clone(&default_config_conv);
16928         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16929         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
16930         if (channel_monitors_constr.datalen > 0)
16931                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16932         else
16933                 channel_monitors_constr.data = NULL;
16934         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
16935         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16936                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
16937                 LDKChannelMonitor channel_monitors_conv_16_conv;
16938                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16939                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16940                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16941         }
16942         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
16943         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);
16944         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16945         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16946         uint64_t ret_ref = (uint64_t)ret_var.inner;
16947         if (ret_var.is_owned) {
16948                 ret_ref |= 1;
16949         }
16950         return ret_ref;
16951 }
16952
16953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
16954         LDKu8slice ser_ref;
16955         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16956         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16957         LDKChannelManagerReadArgs arg_conv;
16958         arg_conv.inner = (void*)(arg & (~1));
16959         arg_conv.is_owned = (arg & 1) || (arg == 0);
16960         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16961         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16962         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16963         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16964         return (uint64_t)ret_conv;
16965 }
16966
16967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16968         LDKDecodeError this_obj_conv;
16969         this_obj_conv.inner = (void*)(this_obj & (~1));
16970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16971         DecodeError_free(this_obj_conv);
16972 }
16973
16974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16975         LDKDecodeError orig_conv;
16976         orig_conv.inner = (void*)(orig & (~1));
16977         orig_conv.is_owned = false;
16978         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16981         uint64_t ret_ref = (uint64_t)ret_var.inner;
16982         if (ret_var.is_owned) {
16983                 ret_ref |= 1;
16984         }
16985         return ret_ref;
16986 }
16987
16988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16989         LDKInit this_obj_conv;
16990         this_obj_conv.inner = (void*)(this_obj & (~1));
16991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16992         Init_free(this_obj_conv);
16993 }
16994
16995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16996         LDKInit this_ptr_conv;
16997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16998         this_ptr_conv.is_owned = false;
16999         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
17000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17002         uint64_t ret_ref = (uint64_t)ret_var.inner;
17003         if (ret_var.is_owned) {
17004                 ret_ref |= 1;
17005         }
17006         return ret_ref;
17007 }
17008
17009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17010         LDKInit this_ptr_conv;
17011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17012         this_ptr_conv.is_owned = false;
17013         LDKInitFeatures val_conv;
17014         val_conv.inner = (void*)(val & (~1));
17015         val_conv.is_owned = (val & 1) || (val == 0);
17016         val_conv = InitFeatures_clone(&val_conv);
17017         Init_set_features(&this_ptr_conv, val_conv);
17018 }
17019
17020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
17021         LDKInitFeatures features_arg_conv;
17022         features_arg_conv.inner = (void*)(features_arg & (~1));
17023         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
17024         features_arg_conv = InitFeatures_clone(&features_arg_conv);
17025         LDKInit ret_var = Init_new(features_arg_conv);
17026         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17027         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17028         uint64_t ret_ref = (uint64_t)ret_var.inner;
17029         if (ret_var.is_owned) {
17030                 ret_ref |= 1;
17031         }
17032         return ret_ref;
17033 }
17034
17035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17036         LDKInit orig_conv;
17037         orig_conv.inner = (void*)(orig & (~1));
17038         orig_conv.is_owned = false;
17039         LDKInit ret_var = Init_clone(&orig_conv);
17040         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17041         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17042         uint64_t ret_ref = (uint64_t)ret_var.inner;
17043         if (ret_var.is_owned) {
17044                 ret_ref |= 1;
17045         }
17046         return ret_ref;
17047 }
17048
17049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17050         LDKErrorMessage this_obj_conv;
17051         this_obj_conv.inner = (void*)(this_obj & (~1));
17052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17053         ErrorMessage_free(this_obj_conv);
17054 }
17055
17056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17057         LDKErrorMessage this_ptr_conv;
17058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17059         this_ptr_conv.is_owned = false;
17060         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17061         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
17062         return ret_arr;
17063 }
17064
17065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17066         LDKErrorMessage this_ptr_conv;
17067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17068         this_ptr_conv.is_owned = false;
17069         LDKThirtyTwoBytes val_ref;
17070         CHECK((*env)->GetArrayLength(env, val) == 32);
17071         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17072         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
17073 }
17074
17075 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
17076         LDKErrorMessage this_ptr_conv;
17077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17078         this_ptr_conv.is_owned = false;
17079         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
17080         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
17081         Str_free(ret_str);
17082         return ret_conv;
17083 }
17084
17085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
17086         LDKErrorMessage this_ptr_conv;
17087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17088         this_ptr_conv.is_owned = false;
17089         LDKStr val_conv = java_to_owned_str(env, val);
17090         ErrorMessage_set_data(&this_ptr_conv, val_conv);
17091 }
17092
17093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
17094         LDKThirtyTwoBytes channel_id_arg_ref;
17095         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17096         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17097         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
17098         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
17099         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17100         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17101         uint64_t ret_ref = (uint64_t)ret_var.inner;
17102         if (ret_var.is_owned) {
17103                 ret_ref |= 1;
17104         }
17105         return ret_ref;
17106 }
17107
17108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17109         LDKErrorMessage orig_conv;
17110         orig_conv.inner = (void*)(orig & (~1));
17111         orig_conv.is_owned = false;
17112         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
17113         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17114         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17115         uint64_t ret_ref = (uint64_t)ret_var.inner;
17116         if (ret_var.is_owned) {
17117                 ret_ref |= 1;
17118         }
17119         return ret_ref;
17120 }
17121
17122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17123         LDKPing this_obj_conv;
17124         this_obj_conv.inner = (void*)(this_obj & (~1));
17125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17126         Ping_free(this_obj_conv);
17127 }
17128
17129 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17130         LDKPing this_ptr_conv;
17131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17132         this_ptr_conv.is_owned = false;
17133         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
17134         return ret_val;
17135 }
17136
17137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17138         LDKPing this_ptr_conv;
17139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17140         this_ptr_conv.is_owned = false;
17141         Ping_set_ponglen(&this_ptr_conv, val);
17142 }
17143
17144 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17145         LDKPing this_ptr_conv;
17146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17147         this_ptr_conv.is_owned = false;
17148         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
17149         return ret_val;
17150 }
17151
17152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17153         LDKPing this_ptr_conv;
17154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17155         this_ptr_conv.is_owned = false;
17156         Ping_set_byteslen(&this_ptr_conv, val);
17157 }
17158
17159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
17160         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
17161         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17162         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17163         uint64_t ret_ref = (uint64_t)ret_var.inner;
17164         if (ret_var.is_owned) {
17165                 ret_ref |= 1;
17166         }
17167         return ret_ref;
17168 }
17169
17170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17171         LDKPing orig_conv;
17172         orig_conv.inner = (void*)(orig & (~1));
17173         orig_conv.is_owned = false;
17174         LDKPing ret_var = Ping_clone(&orig_conv);
17175         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17176         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17177         uint64_t ret_ref = (uint64_t)ret_var.inner;
17178         if (ret_var.is_owned) {
17179                 ret_ref |= 1;
17180         }
17181         return ret_ref;
17182 }
17183
17184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17185         LDKPong this_obj_conv;
17186         this_obj_conv.inner = (void*)(this_obj & (~1));
17187         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17188         Pong_free(this_obj_conv);
17189 }
17190
17191 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17192         LDKPong this_ptr_conv;
17193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17194         this_ptr_conv.is_owned = false;
17195         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
17196         return ret_val;
17197 }
17198
17199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17200         LDKPong this_ptr_conv;
17201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17202         this_ptr_conv.is_owned = false;
17203         Pong_set_byteslen(&this_ptr_conv, val);
17204 }
17205
17206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
17207         LDKPong ret_var = Pong_new(byteslen_arg);
17208         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17209         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17210         uint64_t ret_ref = (uint64_t)ret_var.inner;
17211         if (ret_var.is_owned) {
17212                 ret_ref |= 1;
17213         }
17214         return ret_ref;
17215 }
17216
17217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17218         LDKPong orig_conv;
17219         orig_conv.inner = (void*)(orig & (~1));
17220         orig_conv.is_owned = false;
17221         LDKPong ret_var = Pong_clone(&orig_conv);
17222         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17223         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17224         uint64_t ret_ref = (uint64_t)ret_var.inner;
17225         if (ret_var.is_owned) {
17226                 ret_ref |= 1;
17227         }
17228         return ret_ref;
17229 }
17230
17231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17232         LDKOpenChannel this_obj_conv;
17233         this_obj_conv.inner = (void*)(this_obj & (~1));
17234         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17235         OpenChannel_free(this_obj_conv);
17236 }
17237
17238 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17239         LDKOpenChannel this_ptr_conv;
17240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17241         this_ptr_conv.is_owned = false;
17242         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17243         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
17244         return ret_arr;
17245 }
17246
17247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17248         LDKOpenChannel this_ptr_conv;
17249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17250         this_ptr_conv.is_owned = false;
17251         LDKThirtyTwoBytes val_ref;
17252         CHECK((*env)->GetArrayLength(env, val) == 32);
17253         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17254         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
17255 }
17256
17257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17258         LDKOpenChannel this_ptr_conv;
17259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17260         this_ptr_conv.is_owned = false;
17261         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
17263         return ret_arr;
17264 }
17265
17266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17267         LDKOpenChannel this_ptr_conv;
17268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17269         this_ptr_conv.is_owned = false;
17270         LDKThirtyTwoBytes val_ref;
17271         CHECK((*env)->GetArrayLength(env, val) == 32);
17272         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17273         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17274 }
17275
17276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17277         LDKOpenChannel this_ptr_conv;
17278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17279         this_ptr_conv.is_owned = false;
17280         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
17281         return ret_val;
17282 }
17283
17284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17285         LDKOpenChannel this_ptr_conv;
17286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17287         this_ptr_conv.is_owned = false;
17288         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
17289 }
17290
17291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17292         LDKOpenChannel this_ptr_conv;
17293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17294         this_ptr_conv.is_owned = false;
17295         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
17296         return ret_val;
17297 }
17298
17299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17300         LDKOpenChannel this_ptr_conv;
17301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17302         this_ptr_conv.is_owned = false;
17303         OpenChannel_set_push_msat(&this_ptr_conv, val);
17304 }
17305
17306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17307         LDKOpenChannel this_ptr_conv;
17308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17309         this_ptr_conv.is_owned = false;
17310         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
17311         return ret_val;
17312 }
17313
17314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17315         LDKOpenChannel this_ptr_conv;
17316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17317         this_ptr_conv.is_owned = false;
17318         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17319 }
17320
17321 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) {
17322         LDKOpenChannel this_ptr_conv;
17323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17324         this_ptr_conv.is_owned = false;
17325         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17326         return ret_val;
17327 }
17328
17329 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) {
17330         LDKOpenChannel this_ptr_conv;
17331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17332         this_ptr_conv.is_owned = false;
17333         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17334 }
17335
17336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17337         LDKOpenChannel this_ptr_conv;
17338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17339         this_ptr_conv.is_owned = false;
17340         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17341         return ret_val;
17342 }
17343
17344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17345         LDKOpenChannel this_ptr_conv;
17346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17347         this_ptr_conv.is_owned = false;
17348         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17349 }
17350
17351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17352         LDKOpenChannel this_ptr_conv;
17353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17354         this_ptr_conv.is_owned = false;
17355         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
17356         return ret_val;
17357 }
17358
17359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17360         LDKOpenChannel this_ptr_conv;
17361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17362         this_ptr_conv.is_owned = false;
17363         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17364 }
17365
17366 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17367         LDKOpenChannel this_ptr_conv;
17368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17369         this_ptr_conv.is_owned = false;
17370         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
17371         return ret_val;
17372 }
17373
17374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17375         LDKOpenChannel this_ptr_conv;
17376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17377         this_ptr_conv.is_owned = false;
17378         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
17379 }
17380
17381 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17382         LDKOpenChannel this_ptr_conv;
17383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17384         this_ptr_conv.is_owned = false;
17385         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
17386         return ret_val;
17387 }
17388
17389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17390         LDKOpenChannel this_ptr_conv;
17391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17392         this_ptr_conv.is_owned = false;
17393         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
17394 }
17395
17396 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17397         LDKOpenChannel this_ptr_conv;
17398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17399         this_ptr_conv.is_owned = false;
17400         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
17401         return ret_val;
17402 }
17403
17404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17405         LDKOpenChannel this_ptr_conv;
17406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17407         this_ptr_conv.is_owned = false;
17408         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17409 }
17410
17411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17412         LDKOpenChannel this_ptr_conv;
17413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17414         this_ptr_conv.is_owned = false;
17415         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17416         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17417         return ret_arr;
17418 }
17419
17420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17421         LDKOpenChannel this_ptr_conv;
17422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17423         this_ptr_conv.is_owned = false;
17424         LDKPublicKey val_ref;
17425         CHECK((*env)->GetArrayLength(env, val) == 33);
17426         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17427         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17428 }
17429
17430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17431         LDKOpenChannel this_ptr_conv;
17432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17433         this_ptr_conv.is_owned = false;
17434         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17436         return ret_arr;
17437 }
17438
17439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17440         LDKOpenChannel this_ptr_conv;
17441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17442         this_ptr_conv.is_owned = false;
17443         LDKPublicKey val_ref;
17444         CHECK((*env)->GetArrayLength(env, val) == 33);
17445         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17446         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17447 }
17448
17449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17450         LDKOpenChannel this_ptr_conv;
17451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17452         this_ptr_conv.is_owned = false;
17453         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
17455         return ret_arr;
17456 }
17457
17458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17459         LDKOpenChannel this_ptr_conv;
17460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17461         this_ptr_conv.is_owned = false;
17462         LDKPublicKey val_ref;
17463         CHECK((*env)->GetArrayLength(env, val) == 33);
17464         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17465         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
17466 }
17467
17468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17469         LDKOpenChannel this_ptr_conv;
17470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17471         this_ptr_conv.is_owned = false;
17472         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17474         return ret_arr;
17475 }
17476
17477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17478         LDKOpenChannel this_ptr_conv;
17479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17480         this_ptr_conv.is_owned = false;
17481         LDKPublicKey val_ref;
17482         CHECK((*env)->GetArrayLength(env, val) == 33);
17483         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17484         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17485 }
17486
17487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17488         LDKOpenChannel this_ptr_conv;
17489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17490         this_ptr_conv.is_owned = false;
17491         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17493         return ret_arr;
17494 }
17495
17496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17497         LDKOpenChannel this_ptr_conv;
17498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17499         this_ptr_conv.is_owned = false;
17500         LDKPublicKey val_ref;
17501         CHECK((*env)->GetArrayLength(env, val) == 33);
17502         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17503         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17504 }
17505
17506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17507         LDKOpenChannel this_ptr_conv;
17508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17509         this_ptr_conv.is_owned = false;
17510         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17512         return ret_arr;
17513 }
17514
17515 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) {
17516         LDKOpenChannel this_ptr_conv;
17517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17518         this_ptr_conv.is_owned = false;
17519         LDKPublicKey val_ref;
17520         CHECK((*env)->GetArrayLength(env, val) == 33);
17521         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17522         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17523 }
17524
17525 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
17526         LDKOpenChannel this_ptr_conv;
17527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17528         this_ptr_conv.is_owned = false;
17529         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
17530         return ret_val;
17531 }
17532
17533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
17534         LDKOpenChannel this_ptr_conv;
17535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17536         this_ptr_conv.is_owned = false;
17537         OpenChannel_set_channel_flags(&this_ptr_conv, val);
17538 }
17539
17540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17541         LDKOpenChannel orig_conv;
17542         orig_conv.inner = (void*)(orig & (~1));
17543         orig_conv.is_owned = false;
17544         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
17545         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17546         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17547         uint64_t ret_ref = (uint64_t)ret_var.inner;
17548         if (ret_var.is_owned) {
17549                 ret_ref |= 1;
17550         }
17551         return ret_ref;
17552 }
17553
17554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17555         LDKAcceptChannel this_obj_conv;
17556         this_obj_conv.inner = (void*)(this_obj & (~1));
17557         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17558         AcceptChannel_free(this_obj_conv);
17559 }
17560
17561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17562         LDKAcceptChannel this_ptr_conv;
17563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17564         this_ptr_conv.is_owned = false;
17565         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17566         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
17567         return ret_arr;
17568 }
17569
17570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17571         LDKAcceptChannel this_ptr_conv;
17572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17573         this_ptr_conv.is_owned = false;
17574         LDKThirtyTwoBytes val_ref;
17575         CHECK((*env)->GetArrayLength(env, val) == 32);
17576         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17577         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17578 }
17579
17580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17581         LDKAcceptChannel this_ptr_conv;
17582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17583         this_ptr_conv.is_owned = false;
17584         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
17585         return ret_val;
17586 }
17587
17588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17589         LDKAcceptChannel this_ptr_conv;
17590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17591         this_ptr_conv.is_owned = false;
17592         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17593 }
17594
17595 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) {
17596         LDKAcceptChannel this_ptr_conv;
17597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17598         this_ptr_conv.is_owned = false;
17599         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17600         return ret_val;
17601 }
17602
17603 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) {
17604         LDKAcceptChannel this_ptr_conv;
17605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17606         this_ptr_conv.is_owned = false;
17607         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17608 }
17609
17610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17611         LDKAcceptChannel this_ptr_conv;
17612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17613         this_ptr_conv.is_owned = false;
17614         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17615         return ret_val;
17616 }
17617
17618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17619         LDKAcceptChannel this_ptr_conv;
17620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17621         this_ptr_conv.is_owned = false;
17622         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17623 }
17624
17625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17626         LDKAcceptChannel this_ptr_conv;
17627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17628         this_ptr_conv.is_owned = false;
17629         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
17630         return ret_val;
17631 }
17632
17633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17634         LDKAcceptChannel this_ptr_conv;
17635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17636         this_ptr_conv.is_owned = false;
17637         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17638 }
17639
17640 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
17641         LDKAcceptChannel this_ptr_conv;
17642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17643         this_ptr_conv.is_owned = false;
17644         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
17645         return ret_val;
17646 }
17647
17648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17649         LDKAcceptChannel this_ptr_conv;
17650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17651         this_ptr_conv.is_owned = false;
17652         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
17653 }
17654
17655 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17656         LDKAcceptChannel this_ptr_conv;
17657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17658         this_ptr_conv.is_owned = false;
17659         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
17660         return ret_val;
17661 }
17662
17663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17664         LDKAcceptChannel this_ptr_conv;
17665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17666         this_ptr_conv.is_owned = false;
17667         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
17668 }
17669
17670 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17671         LDKAcceptChannel this_ptr_conv;
17672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17673         this_ptr_conv.is_owned = false;
17674         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
17675         return ret_val;
17676 }
17677
17678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17679         LDKAcceptChannel this_ptr_conv;
17680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17681         this_ptr_conv.is_owned = false;
17682         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17683 }
17684
17685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17686         LDKAcceptChannel this_ptr_conv;
17687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17688         this_ptr_conv.is_owned = false;
17689         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17690         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17691         return ret_arr;
17692 }
17693
17694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17695         LDKAcceptChannel this_ptr_conv;
17696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17697         this_ptr_conv.is_owned = false;
17698         LDKPublicKey val_ref;
17699         CHECK((*env)->GetArrayLength(env, val) == 33);
17700         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17701         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17702 }
17703
17704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17705         LDKAcceptChannel this_ptr_conv;
17706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17707         this_ptr_conv.is_owned = false;
17708         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17710         return ret_arr;
17711 }
17712
17713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17714         LDKAcceptChannel this_ptr_conv;
17715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17716         this_ptr_conv.is_owned = false;
17717         LDKPublicKey val_ref;
17718         CHECK((*env)->GetArrayLength(env, val) == 33);
17719         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17720         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17721 }
17722
17723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17724         LDKAcceptChannel this_ptr_conv;
17725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17726         this_ptr_conv.is_owned = false;
17727         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17728         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
17729         return ret_arr;
17730 }
17731
17732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17733         LDKAcceptChannel this_ptr_conv;
17734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17735         this_ptr_conv.is_owned = false;
17736         LDKPublicKey val_ref;
17737         CHECK((*env)->GetArrayLength(env, val) == 33);
17738         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17739         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
17740 }
17741
17742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17743         LDKAcceptChannel this_ptr_conv;
17744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17745         this_ptr_conv.is_owned = false;
17746         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17747         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17748         return ret_arr;
17749 }
17750
17751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17752         LDKAcceptChannel this_ptr_conv;
17753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17754         this_ptr_conv.is_owned = false;
17755         LDKPublicKey val_ref;
17756         CHECK((*env)->GetArrayLength(env, val) == 33);
17757         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17758         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17759 }
17760
17761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17762         LDKAcceptChannel this_ptr_conv;
17763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17764         this_ptr_conv.is_owned = false;
17765         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17766         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17767         return ret_arr;
17768 }
17769
17770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17771         LDKAcceptChannel this_ptr_conv;
17772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17773         this_ptr_conv.is_owned = false;
17774         LDKPublicKey val_ref;
17775         CHECK((*env)->GetArrayLength(env, val) == 33);
17776         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17777         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17778 }
17779
17780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17781         LDKAcceptChannel this_ptr_conv;
17782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17783         this_ptr_conv.is_owned = false;
17784         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17786         return ret_arr;
17787 }
17788
17789 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) {
17790         LDKAcceptChannel this_ptr_conv;
17791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17792         this_ptr_conv.is_owned = false;
17793         LDKPublicKey val_ref;
17794         CHECK((*env)->GetArrayLength(env, val) == 33);
17795         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17796         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17797 }
17798
17799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17800         LDKAcceptChannel orig_conv;
17801         orig_conv.inner = (void*)(orig & (~1));
17802         orig_conv.is_owned = false;
17803         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
17804         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17805         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17806         uint64_t ret_ref = (uint64_t)ret_var.inner;
17807         if (ret_var.is_owned) {
17808                 ret_ref |= 1;
17809         }
17810         return ret_ref;
17811 }
17812
17813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17814         LDKFundingCreated this_obj_conv;
17815         this_obj_conv.inner = (void*)(this_obj & (~1));
17816         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17817         FundingCreated_free(this_obj_conv);
17818 }
17819
17820 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17821         LDKFundingCreated this_ptr_conv;
17822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17823         this_ptr_conv.is_owned = false;
17824         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17825         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
17826         return ret_arr;
17827 }
17828
17829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17830         LDKFundingCreated this_ptr_conv;
17831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17832         this_ptr_conv.is_owned = false;
17833         LDKThirtyTwoBytes val_ref;
17834         CHECK((*env)->GetArrayLength(env, val) == 32);
17835         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17836         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17837 }
17838
17839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17840         LDKFundingCreated this_ptr_conv;
17841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17842         this_ptr_conv.is_owned = false;
17843         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17844         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
17845         return ret_arr;
17846 }
17847
17848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17849         LDKFundingCreated this_ptr_conv;
17850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17851         this_ptr_conv.is_owned = false;
17852         LDKThirtyTwoBytes val_ref;
17853         CHECK((*env)->GetArrayLength(env, val) == 32);
17854         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17855         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17856 }
17857
17858 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17859         LDKFundingCreated this_ptr_conv;
17860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17861         this_ptr_conv.is_owned = false;
17862         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17863         return ret_val;
17864 }
17865
17866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17867         LDKFundingCreated this_ptr_conv;
17868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17869         this_ptr_conv.is_owned = false;
17870         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17871 }
17872
17873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17874         LDKFundingCreated this_ptr_conv;
17875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17876         this_ptr_conv.is_owned = false;
17877         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17878         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
17879         return ret_arr;
17880 }
17881
17882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17883         LDKFundingCreated this_ptr_conv;
17884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17885         this_ptr_conv.is_owned = false;
17886         LDKSignature val_ref;
17887         CHECK((*env)->GetArrayLength(env, val) == 64);
17888         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17889         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17890 }
17891
17892 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) {
17893         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17894         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
17895         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
17896         LDKThirtyTwoBytes funding_txid_arg_ref;
17897         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
17898         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
17899         LDKSignature signature_arg_ref;
17900         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17901         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17902         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17905         uint64_t ret_ref = (uint64_t)ret_var.inner;
17906         if (ret_var.is_owned) {
17907                 ret_ref |= 1;
17908         }
17909         return ret_ref;
17910 }
17911
17912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17913         LDKFundingCreated orig_conv;
17914         orig_conv.inner = (void*)(orig & (~1));
17915         orig_conv.is_owned = false;
17916         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17919         uint64_t ret_ref = (uint64_t)ret_var.inner;
17920         if (ret_var.is_owned) {
17921                 ret_ref |= 1;
17922         }
17923         return ret_ref;
17924 }
17925
17926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17927         LDKFundingSigned this_obj_conv;
17928         this_obj_conv.inner = (void*)(this_obj & (~1));
17929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17930         FundingSigned_free(this_obj_conv);
17931 }
17932
17933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17934         LDKFundingSigned this_ptr_conv;
17935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17936         this_ptr_conv.is_owned = false;
17937         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17938         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
17939         return ret_arr;
17940 }
17941
17942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17943         LDKFundingSigned this_ptr_conv;
17944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17945         this_ptr_conv.is_owned = false;
17946         LDKThirtyTwoBytes val_ref;
17947         CHECK((*env)->GetArrayLength(env, val) == 32);
17948         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17949         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17950 }
17951
17952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17953         LDKFundingSigned this_ptr_conv;
17954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17955         this_ptr_conv.is_owned = false;
17956         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
17958         return ret_arr;
17959 }
17960
17961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17962         LDKFundingSigned this_ptr_conv;
17963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17964         this_ptr_conv.is_owned = false;
17965         LDKSignature val_ref;
17966         CHECK((*env)->GetArrayLength(env, val) == 64);
17967         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17968         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17969 }
17970
17971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
17972         LDKThirtyTwoBytes channel_id_arg_ref;
17973         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17974         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17975         LDKSignature signature_arg_ref;
17976         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17977         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17978         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17981         uint64_t ret_ref = (uint64_t)ret_var.inner;
17982         if (ret_var.is_owned) {
17983                 ret_ref |= 1;
17984         }
17985         return ret_ref;
17986 }
17987
17988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17989         LDKFundingSigned orig_conv;
17990         orig_conv.inner = (void*)(orig & (~1));
17991         orig_conv.is_owned = false;
17992         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17993         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17994         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17995         uint64_t ret_ref = (uint64_t)ret_var.inner;
17996         if (ret_var.is_owned) {
17997                 ret_ref |= 1;
17998         }
17999         return ret_ref;
18000 }
18001
18002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18003         LDKFundingLocked this_obj_conv;
18004         this_obj_conv.inner = (void*)(this_obj & (~1));
18005         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18006         FundingLocked_free(this_obj_conv);
18007 }
18008
18009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18010         LDKFundingLocked this_ptr_conv;
18011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18012         this_ptr_conv.is_owned = false;
18013         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18014         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
18015         return ret_arr;
18016 }
18017
18018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18019         LDKFundingLocked this_ptr_conv;
18020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18021         this_ptr_conv.is_owned = false;
18022         LDKThirtyTwoBytes val_ref;
18023         CHECK((*env)->GetArrayLength(env, val) == 32);
18024         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18025         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
18026 }
18027
18028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18029         LDKFundingLocked this_ptr_conv;
18030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18031         this_ptr_conv.is_owned = false;
18032         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18034         return ret_arr;
18035 }
18036
18037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18038         LDKFundingLocked this_ptr_conv;
18039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18040         this_ptr_conv.is_owned = false;
18041         LDKPublicKey val_ref;
18042         CHECK((*env)->GetArrayLength(env, val) == 33);
18043         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18044         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18045 }
18046
18047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
18048         LDKThirtyTwoBytes channel_id_arg_ref;
18049         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18050         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18051         LDKPublicKey next_per_commitment_point_arg_ref;
18052         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18053         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18054         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
18055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18057         uint64_t ret_ref = (uint64_t)ret_var.inner;
18058         if (ret_var.is_owned) {
18059                 ret_ref |= 1;
18060         }
18061         return ret_ref;
18062 }
18063
18064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18065         LDKFundingLocked orig_conv;
18066         orig_conv.inner = (void*)(orig & (~1));
18067         orig_conv.is_owned = false;
18068         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
18069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18071         uint64_t ret_ref = (uint64_t)ret_var.inner;
18072         if (ret_var.is_owned) {
18073                 ret_ref |= 1;
18074         }
18075         return ret_ref;
18076 }
18077
18078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18079         LDKShutdown this_obj_conv;
18080         this_obj_conv.inner = (void*)(this_obj & (~1));
18081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18082         Shutdown_free(this_obj_conv);
18083 }
18084
18085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18086         LDKShutdown this_ptr_conv;
18087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18088         this_ptr_conv.is_owned = false;
18089         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
18091         return ret_arr;
18092 }
18093
18094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18095         LDKShutdown this_ptr_conv;
18096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18097         this_ptr_conv.is_owned = false;
18098         LDKThirtyTwoBytes val_ref;
18099         CHECK((*env)->GetArrayLength(env, val) == 32);
18100         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18101         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
18102 }
18103
18104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18105         LDKShutdown this_ptr_conv;
18106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18107         this_ptr_conv.is_owned = false;
18108         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
18109         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18110         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18111         return ret_arr;
18112 }
18113
18114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18115         LDKShutdown this_ptr_conv;
18116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18117         this_ptr_conv.is_owned = false;
18118         LDKCVec_u8Z val_ref;
18119         val_ref.datalen = (*env)->GetArrayLength(env, val);
18120         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18121         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18122         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
18123 }
18124
18125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
18126         LDKThirtyTwoBytes channel_id_arg_ref;
18127         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18128         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18129         LDKCVec_u8Z scriptpubkey_arg_ref;
18130         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
18131         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18132         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
18133         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
18134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18136         uint64_t ret_ref = (uint64_t)ret_var.inner;
18137         if (ret_var.is_owned) {
18138                 ret_ref |= 1;
18139         }
18140         return ret_ref;
18141 }
18142
18143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18144         LDKShutdown orig_conv;
18145         orig_conv.inner = (void*)(orig & (~1));
18146         orig_conv.is_owned = false;
18147         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
18148         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18149         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18150         uint64_t ret_ref = (uint64_t)ret_var.inner;
18151         if (ret_var.is_owned) {
18152                 ret_ref |= 1;
18153         }
18154         return ret_ref;
18155 }
18156
18157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18158         LDKClosingSigned this_obj_conv;
18159         this_obj_conv.inner = (void*)(this_obj & (~1));
18160         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18161         ClosingSigned_free(this_obj_conv);
18162 }
18163
18164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18165         LDKClosingSigned this_ptr_conv;
18166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18167         this_ptr_conv.is_owned = false;
18168         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18169         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
18170         return ret_arr;
18171 }
18172
18173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18174         LDKClosingSigned this_ptr_conv;
18175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18176         this_ptr_conv.is_owned = false;
18177         LDKThirtyTwoBytes val_ref;
18178         CHECK((*env)->GetArrayLength(env, val) == 32);
18179         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18180         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
18181 }
18182
18183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18184         LDKClosingSigned this_ptr_conv;
18185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18186         this_ptr_conv.is_owned = false;
18187         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
18188         return ret_val;
18189 }
18190
18191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18192         LDKClosingSigned this_ptr_conv;
18193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18194         this_ptr_conv.is_owned = false;
18195         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
18196 }
18197
18198 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18199         LDKClosingSigned this_ptr_conv;
18200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18201         this_ptr_conv.is_owned = false;
18202         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
18204         return ret_arr;
18205 }
18206
18207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18208         LDKClosingSigned this_ptr_conv;
18209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18210         this_ptr_conv.is_owned = false;
18211         LDKSignature val_ref;
18212         CHECK((*env)->GetArrayLength(env, val) == 64);
18213         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18214         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
18215 }
18216
18217 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) {
18218         LDKThirtyTwoBytes channel_id_arg_ref;
18219         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18220         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18221         LDKSignature signature_arg_ref;
18222         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18223         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18224         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
18225         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18226         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18227         uint64_t ret_ref = (uint64_t)ret_var.inner;
18228         if (ret_var.is_owned) {
18229                 ret_ref |= 1;
18230         }
18231         return ret_ref;
18232 }
18233
18234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18235         LDKClosingSigned orig_conv;
18236         orig_conv.inner = (void*)(orig & (~1));
18237         orig_conv.is_owned = false;
18238         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
18239         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18240         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18241         uint64_t ret_ref = (uint64_t)ret_var.inner;
18242         if (ret_var.is_owned) {
18243                 ret_ref |= 1;
18244         }
18245         return ret_ref;
18246 }
18247
18248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18249         LDKUpdateAddHTLC this_obj_conv;
18250         this_obj_conv.inner = (void*)(this_obj & (~1));
18251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18252         UpdateAddHTLC_free(this_obj_conv);
18253 }
18254
18255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18256         LDKUpdateAddHTLC this_ptr_conv;
18257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18258         this_ptr_conv.is_owned = false;
18259         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
18261         return ret_arr;
18262 }
18263
18264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18265         LDKUpdateAddHTLC this_ptr_conv;
18266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18267         this_ptr_conv.is_owned = false;
18268         LDKThirtyTwoBytes val_ref;
18269         CHECK((*env)->GetArrayLength(env, val) == 32);
18270         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18271         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
18272 }
18273
18274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18275         LDKUpdateAddHTLC this_ptr_conv;
18276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18277         this_ptr_conv.is_owned = false;
18278         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
18279         return ret_val;
18280 }
18281
18282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18283         LDKUpdateAddHTLC this_ptr_conv;
18284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18285         this_ptr_conv.is_owned = false;
18286         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
18287 }
18288
18289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18290         LDKUpdateAddHTLC this_ptr_conv;
18291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18292         this_ptr_conv.is_owned = false;
18293         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
18294         return ret_val;
18295 }
18296
18297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18298         LDKUpdateAddHTLC this_ptr_conv;
18299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18300         this_ptr_conv.is_owned = false;
18301         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
18302 }
18303
18304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18305         LDKUpdateAddHTLC this_ptr_conv;
18306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18307         this_ptr_conv.is_owned = false;
18308         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18309         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
18310         return ret_arr;
18311 }
18312
18313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18314         LDKUpdateAddHTLC this_ptr_conv;
18315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18316         this_ptr_conv.is_owned = false;
18317         LDKThirtyTwoBytes val_ref;
18318         CHECK((*env)->GetArrayLength(env, val) == 32);
18319         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18320         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
18321 }
18322
18323 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18324         LDKUpdateAddHTLC this_ptr_conv;
18325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18326         this_ptr_conv.is_owned = false;
18327         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
18328         return ret_val;
18329 }
18330
18331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18332         LDKUpdateAddHTLC this_ptr_conv;
18333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18334         this_ptr_conv.is_owned = false;
18335         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
18336 }
18337
18338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18339         LDKUpdateAddHTLC orig_conv;
18340         orig_conv.inner = (void*)(orig & (~1));
18341         orig_conv.is_owned = false;
18342         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
18343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18345         uint64_t ret_ref = (uint64_t)ret_var.inner;
18346         if (ret_var.is_owned) {
18347                 ret_ref |= 1;
18348         }
18349         return ret_ref;
18350 }
18351
18352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18353         LDKUpdateFulfillHTLC this_obj_conv;
18354         this_obj_conv.inner = (void*)(this_obj & (~1));
18355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18356         UpdateFulfillHTLC_free(this_obj_conv);
18357 }
18358
18359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18360         LDKUpdateFulfillHTLC this_ptr_conv;
18361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18362         this_ptr_conv.is_owned = false;
18363         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18364         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
18365         return ret_arr;
18366 }
18367
18368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18369         LDKUpdateFulfillHTLC this_ptr_conv;
18370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18371         this_ptr_conv.is_owned = false;
18372         LDKThirtyTwoBytes val_ref;
18373         CHECK((*env)->GetArrayLength(env, val) == 32);
18374         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18375         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
18376 }
18377
18378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18379         LDKUpdateFulfillHTLC this_ptr_conv;
18380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18381         this_ptr_conv.is_owned = false;
18382         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
18383         return ret_val;
18384 }
18385
18386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18387         LDKUpdateFulfillHTLC this_ptr_conv;
18388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18389         this_ptr_conv.is_owned = false;
18390         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
18391 }
18392
18393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
18394         LDKUpdateFulfillHTLC this_ptr_conv;
18395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18396         this_ptr_conv.is_owned = false;
18397         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18398         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
18399         return ret_arr;
18400 }
18401
18402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18403         LDKUpdateFulfillHTLC this_ptr_conv;
18404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18405         this_ptr_conv.is_owned = false;
18406         LDKThirtyTwoBytes val_ref;
18407         CHECK((*env)->GetArrayLength(env, val) == 32);
18408         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18409         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
18410 }
18411
18412 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) {
18413         LDKThirtyTwoBytes channel_id_arg_ref;
18414         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18415         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18416         LDKThirtyTwoBytes payment_preimage_arg_ref;
18417         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
18418         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
18419         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
18420         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18421         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18422         uint64_t ret_ref = (uint64_t)ret_var.inner;
18423         if (ret_var.is_owned) {
18424                 ret_ref |= 1;
18425         }
18426         return ret_ref;
18427 }
18428
18429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18430         LDKUpdateFulfillHTLC orig_conv;
18431         orig_conv.inner = (void*)(orig & (~1));
18432         orig_conv.is_owned = false;
18433         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
18434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18436         uint64_t ret_ref = (uint64_t)ret_var.inner;
18437         if (ret_var.is_owned) {
18438                 ret_ref |= 1;
18439         }
18440         return ret_ref;
18441 }
18442
18443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18444         LDKUpdateFailHTLC this_obj_conv;
18445         this_obj_conv.inner = (void*)(this_obj & (~1));
18446         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18447         UpdateFailHTLC_free(this_obj_conv);
18448 }
18449
18450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18451         LDKUpdateFailHTLC this_ptr_conv;
18452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18453         this_ptr_conv.is_owned = false;
18454         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18455         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
18456         return ret_arr;
18457 }
18458
18459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18460         LDKUpdateFailHTLC this_ptr_conv;
18461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18462         this_ptr_conv.is_owned = false;
18463         LDKThirtyTwoBytes val_ref;
18464         CHECK((*env)->GetArrayLength(env, val) == 32);
18465         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18466         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
18467 }
18468
18469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18470         LDKUpdateFailHTLC this_ptr_conv;
18471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18472         this_ptr_conv.is_owned = false;
18473         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
18474         return ret_val;
18475 }
18476
18477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18478         LDKUpdateFailHTLC this_ptr_conv;
18479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18480         this_ptr_conv.is_owned = false;
18481         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
18482 }
18483
18484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18485         LDKUpdateFailHTLC orig_conv;
18486         orig_conv.inner = (void*)(orig & (~1));
18487         orig_conv.is_owned = false;
18488         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
18489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18491         uint64_t ret_ref = (uint64_t)ret_var.inner;
18492         if (ret_var.is_owned) {
18493                 ret_ref |= 1;
18494         }
18495         return ret_ref;
18496 }
18497
18498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18499         LDKUpdateFailMalformedHTLC this_obj_conv;
18500         this_obj_conv.inner = (void*)(this_obj & (~1));
18501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18502         UpdateFailMalformedHTLC_free(this_obj_conv);
18503 }
18504
18505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18506         LDKUpdateFailMalformedHTLC this_ptr_conv;
18507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18508         this_ptr_conv.is_owned = false;
18509         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18510         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
18511         return ret_arr;
18512 }
18513
18514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18515         LDKUpdateFailMalformedHTLC this_ptr_conv;
18516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18517         this_ptr_conv.is_owned = false;
18518         LDKThirtyTwoBytes val_ref;
18519         CHECK((*env)->GetArrayLength(env, val) == 32);
18520         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18521         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
18522 }
18523
18524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18525         LDKUpdateFailMalformedHTLC this_ptr_conv;
18526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18527         this_ptr_conv.is_owned = false;
18528         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
18529         return ret_val;
18530 }
18531
18532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18533         LDKUpdateFailMalformedHTLC this_ptr_conv;
18534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18535         this_ptr_conv.is_owned = false;
18536         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
18537 }
18538
18539 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
18540         LDKUpdateFailMalformedHTLC this_ptr_conv;
18541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18542         this_ptr_conv.is_owned = false;
18543         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
18544         return ret_val;
18545 }
18546
18547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18548         LDKUpdateFailMalformedHTLC this_ptr_conv;
18549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18550         this_ptr_conv.is_owned = false;
18551         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
18552 }
18553
18554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18555         LDKUpdateFailMalformedHTLC orig_conv;
18556         orig_conv.inner = (void*)(orig & (~1));
18557         orig_conv.is_owned = false;
18558         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
18559         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18560         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18561         uint64_t ret_ref = (uint64_t)ret_var.inner;
18562         if (ret_var.is_owned) {
18563                 ret_ref |= 1;
18564         }
18565         return ret_ref;
18566 }
18567
18568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18569         LDKCommitmentSigned this_obj_conv;
18570         this_obj_conv.inner = (void*)(this_obj & (~1));
18571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18572         CommitmentSigned_free(this_obj_conv);
18573 }
18574
18575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18576         LDKCommitmentSigned this_ptr_conv;
18577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18578         this_ptr_conv.is_owned = false;
18579         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18580         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
18581         return ret_arr;
18582 }
18583
18584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18585         LDKCommitmentSigned this_ptr_conv;
18586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18587         this_ptr_conv.is_owned = false;
18588         LDKThirtyTwoBytes val_ref;
18589         CHECK((*env)->GetArrayLength(env, val) == 32);
18590         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18591         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
18592 }
18593
18594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18595         LDKCommitmentSigned this_ptr_conv;
18596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18597         this_ptr_conv.is_owned = false;
18598         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18599         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
18600         return ret_arr;
18601 }
18602
18603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18604         LDKCommitmentSigned this_ptr_conv;
18605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18606         this_ptr_conv.is_owned = false;
18607         LDKSignature val_ref;
18608         CHECK((*env)->GetArrayLength(env, val) == 64);
18609         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18610         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
18611 }
18612
18613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18614         LDKCommitmentSigned this_ptr_conv;
18615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18616         this_ptr_conv.is_owned = false;
18617         LDKCVec_SignatureZ val_constr;
18618         val_constr.datalen = (*env)->GetArrayLength(env, val);
18619         if (val_constr.datalen > 0)
18620                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18621         else
18622                 val_constr.data = NULL;
18623         for (size_t i = 0; i < val_constr.datalen; i++) {
18624                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18625                 LDKSignature val_conv_8_ref;
18626                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18627                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18628                 val_constr.data[i] = val_conv_8_ref;
18629         }
18630         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
18631 }
18632
18633 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) {
18634         LDKThirtyTwoBytes channel_id_arg_ref;
18635         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18636         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18637         LDKSignature signature_arg_ref;
18638         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18639         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18640         LDKCVec_SignatureZ htlc_signatures_arg_constr;
18641         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
18642         if (htlc_signatures_arg_constr.datalen > 0)
18643                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18644         else
18645                 htlc_signatures_arg_constr.data = NULL;
18646         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
18647                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
18648                 LDKSignature htlc_signatures_arg_conv_8_ref;
18649                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
18650                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
18651                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
18652         }
18653         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
18654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18656         uint64_t ret_ref = (uint64_t)ret_var.inner;
18657         if (ret_var.is_owned) {
18658                 ret_ref |= 1;
18659         }
18660         return ret_ref;
18661 }
18662
18663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18664         LDKCommitmentSigned orig_conv;
18665         orig_conv.inner = (void*)(orig & (~1));
18666         orig_conv.is_owned = false;
18667         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
18668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18670         uint64_t ret_ref = (uint64_t)ret_var.inner;
18671         if (ret_var.is_owned) {
18672                 ret_ref |= 1;
18673         }
18674         return ret_ref;
18675 }
18676
18677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18678         LDKRevokeAndACK this_obj_conv;
18679         this_obj_conv.inner = (void*)(this_obj & (~1));
18680         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18681         RevokeAndACK_free(this_obj_conv);
18682 }
18683
18684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18685         LDKRevokeAndACK this_ptr_conv;
18686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18687         this_ptr_conv.is_owned = false;
18688         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
18690         return ret_arr;
18691 }
18692
18693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18694         LDKRevokeAndACK this_ptr_conv;
18695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18696         this_ptr_conv.is_owned = false;
18697         LDKThirtyTwoBytes val_ref;
18698         CHECK((*env)->GetArrayLength(env, val) == 32);
18699         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18700         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
18701 }
18702
18703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18704         LDKRevokeAndACK this_ptr_conv;
18705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18706         this_ptr_conv.is_owned = false;
18707         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
18709         return ret_arr;
18710 }
18711
18712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18713         LDKRevokeAndACK this_ptr_conv;
18714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18715         this_ptr_conv.is_owned = false;
18716         LDKThirtyTwoBytes val_ref;
18717         CHECK((*env)->GetArrayLength(env, val) == 32);
18718         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18719         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
18720 }
18721
18722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18723         LDKRevokeAndACK this_ptr_conv;
18724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18725         this_ptr_conv.is_owned = false;
18726         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18727         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18728         return ret_arr;
18729 }
18730
18731 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) {
18732         LDKRevokeAndACK this_ptr_conv;
18733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18734         this_ptr_conv.is_owned = false;
18735         LDKPublicKey val_ref;
18736         CHECK((*env)->GetArrayLength(env, val) == 33);
18737         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18738         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18739 }
18740
18741 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) {
18742         LDKThirtyTwoBytes channel_id_arg_ref;
18743         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18744         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18745         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
18746         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
18747         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
18748         LDKPublicKey next_per_commitment_point_arg_ref;
18749         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18750         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18751         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
18752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18754         uint64_t ret_ref = (uint64_t)ret_var.inner;
18755         if (ret_var.is_owned) {
18756                 ret_ref |= 1;
18757         }
18758         return ret_ref;
18759 }
18760
18761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18762         LDKRevokeAndACK orig_conv;
18763         orig_conv.inner = (void*)(orig & (~1));
18764         orig_conv.is_owned = false;
18765         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
18766         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18767         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18768         uint64_t ret_ref = (uint64_t)ret_var.inner;
18769         if (ret_var.is_owned) {
18770                 ret_ref |= 1;
18771         }
18772         return ret_ref;
18773 }
18774
18775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18776         LDKUpdateFee this_obj_conv;
18777         this_obj_conv.inner = (void*)(this_obj & (~1));
18778         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18779         UpdateFee_free(this_obj_conv);
18780 }
18781
18782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18783         LDKUpdateFee this_ptr_conv;
18784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18785         this_ptr_conv.is_owned = false;
18786         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18787         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
18788         return ret_arr;
18789 }
18790
18791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18792         LDKUpdateFee this_ptr_conv;
18793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18794         this_ptr_conv.is_owned = false;
18795         LDKThirtyTwoBytes val_ref;
18796         CHECK((*env)->GetArrayLength(env, val) == 32);
18797         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18798         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
18799 }
18800
18801 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
18802         LDKUpdateFee this_ptr_conv;
18803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18804         this_ptr_conv.is_owned = false;
18805         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
18806         return ret_val;
18807 }
18808
18809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18810         LDKUpdateFee this_ptr_conv;
18811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18812         this_ptr_conv.is_owned = false;
18813         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18814 }
18815
18816 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) {
18817         LDKThirtyTwoBytes channel_id_arg_ref;
18818         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18819         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18820         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18821         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18822         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18823         uint64_t ret_ref = (uint64_t)ret_var.inner;
18824         if (ret_var.is_owned) {
18825                 ret_ref |= 1;
18826         }
18827         return ret_ref;
18828 }
18829
18830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18831         LDKUpdateFee orig_conv;
18832         orig_conv.inner = (void*)(orig & (~1));
18833         orig_conv.is_owned = false;
18834         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18835         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18836         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18837         uint64_t ret_ref = (uint64_t)ret_var.inner;
18838         if (ret_var.is_owned) {
18839                 ret_ref |= 1;
18840         }
18841         return ret_ref;
18842 }
18843
18844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18845         LDKDataLossProtect this_obj_conv;
18846         this_obj_conv.inner = (void*)(this_obj & (~1));
18847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18848         DataLossProtect_free(this_obj_conv);
18849 }
18850
18851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18852         LDKDataLossProtect this_ptr_conv;
18853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18854         this_ptr_conv.is_owned = false;
18855         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
18857         return ret_arr;
18858 }
18859
18860 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) {
18861         LDKDataLossProtect this_ptr_conv;
18862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18863         this_ptr_conv.is_owned = false;
18864         LDKThirtyTwoBytes val_ref;
18865         CHECK((*env)->GetArrayLength(env, val) == 32);
18866         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18867         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18868 }
18869
18870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18871         LDKDataLossProtect this_ptr_conv;
18872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18873         this_ptr_conv.is_owned = false;
18874         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
18876         return ret_arr;
18877 }
18878
18879 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) {
18880         LDKDataLossProtect this_ptr_conv;
18881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18882         this_ptr_conv.is_owned = false;
18883         LDKPublicKey val_ref;
18884         CHECK((*env)->GetArrayLength(env, val) == 33);
18885         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18886         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18887 }
18888
18889 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) {
18890         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18891         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
18892         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
18893         LDKPublicKey my_current_per_commitment_point_arg_ref;
18894         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
18895         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
18896         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18899         uint64_t ret_ref = (uint64_t)ret_var.inner;
18900         if (ret_var.is_owned) {
18901                 ret_ref |= 1;
18902         }
18903         return ret_ref;
18904 }
18905
18906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18907         LDKDataLossProtect orig_conv;
18908         orig_conv.inner = (void*)(orig & (~1));
18909         orig_conv.is_owned = false;
18910         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18913         uint64_t ret_ref = (uint64_t)ret_var.inner;
18914         if (ret_var.is_owned) {
18915                 ret_ref |= 1;
18916         }
18917         return ret_ref;
18918 }
18919
18920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18921         LDKChannelReestablish this_obj_conv;
18922         this_obj_conv.inner = (void*)(this_obj & (~1));
18923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18924         ChannelReestablish_free(this_obj_conv);
18925 }
18926
18927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18928         LDKChannelReestablish this_ptr_conv;
18929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18930         this_ptr_conv.is_owned = false;
18931         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
18933         return ret_arr;
18934 }
18935
18936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18937         LDKChannelReestablish this_ptr_conv;
18938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18939         this_ptr_conv.is_owned = false;
18940         LDKThirtyTwoBytes val_ref;
18941         CHECK((*env)->GetArrayLength(env, val) == 32);
18942         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18943         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18944 }
18945
18946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18947         LDKChannelReestablish this_ptr_conv;
18948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18949         this_ptr_conv.is_owned = false;
18950         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18951         return ret_val;
18952 }
18953
18954 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) {
18955         LDKChannelReestablish this_ptr_conv;
18956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18957         this_ptr_conv.is_owned = false;
18958         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18959 }
18960
18961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18962         LDKChannelReestablish this_ptr_conv;
18963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18964         this_ptr_conv.is_owned = false;
18965         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18966         return ret_val;
18967 }
18968
18969 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) {
18970         LDKChannelReestablish this_ptr_conv;
18971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18972         this_ptr_conv.is_owned = false;
18973         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18974 }
18975
18976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18977         LDKChannelReestablish orig_conv;
18978         orig_conv.inner = (void*)(orig & (~1));
18979         orig_conv.is_owned = false;
18980         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18983         uint64_t ret_ref = (uint64_t)ret_var.inner;
18984         if (ret_var.is_owned) {
18985                 ret_ref |= 1;
18986         }
18987         return ret_ref;
18988 }
18989
18990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18991         LDKAnnouncementSignatures this_obj_conv;
18992         this_obj_conv.inner = (void*)(this_obj & (~1));
18993         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18994         AnnouncementSignatures_free(this_obj_conv);
18995 }
18996
18997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18998         LDKAnnouncementSignatures this_ptr_conv;
18999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19000         this_ptr_conv.is_owned = false;
19001         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19002         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
19003         return ret_arr;
19004 }
19005
19006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19007         LDKAnnouncementSignatures this_ptr_conv;
19008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19009         this_ptr_conv.is_owned = false;
19010         LDKThirtyTwoBytes val_ref;
19011         CHECK((*env)->GetArrayLength(env, val) == 32);
19012         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19013         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
19014 }
19015
19016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19017         LDKAnnouncementSignatures this_ptr_conv;
19018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19019         this_ptr_conv.is_owned = false;
19020         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
19021         return ret_val;
19022 }
19023
19024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19025         LDKAnnouncementSignatures this_ptr_conv;
19026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19027         this_ptr_conv.is_owned = false;
19028         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
19029 }
19030
19031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19032         LDKAnnouncementSignatures this_ptr_conv;
19033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19034         this_ptr_conv.is_owned = false;
19035         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
19037         return ret_arr;
19038 }
19039
19040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19041         LDKAnnouncementSignatures this_ptr_conv;
19042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19043         this_ptr_conv.is_owned = false;
19044         LDKSignature val_ref;
19045         CHECK((*env)->GetArrayLength(env, val) == 64);
19046         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19047         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
19048 }
19049
19050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19051         LDKAnnouncementSignatures this_ptr_conv;
19052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19053         this_ptr_conv.is_owned = false;
19054         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19055         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
19056         return ret_arr;
19057 }
19058
19059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19060         LDKAnnouncementSignatures this_ptr_conv;
19061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19062         this_ptr_conv.is_owned = false;
19063         LDKSignature val_ref;
19064         CHECK((*env)->GetArrayLength(env, val) == 64);
19065         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19066         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
19067 }
19068
19069 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) {
19070         LDKThirtyTwoBytes channel_id_arg_ref;
19071         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19072         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19073         LDKSignature node_signature_arg_ref;
19074         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
19075         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
19076         LDKSignature bitcoin_signature_arg_ref;
19077         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
19078         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
19079         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
19080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19082         uint64_t ret_ref = (uint64_t)ret_var.inner;
19083         if (ret_var.is_owned) {
19084                 ret_ref |= 1;
19085         }
19086         return ret_ref;
19087 }
19088
19089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19090         LDKAnnouncementSignatures orig_conv;
19091         orig_conv.inner = (void*)(orig & (~1));
19092         orig_conv.is_owned = false;
19093         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
19094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19096         uint64_t ret_ref = (uint64_t)ret_var.inner;
19097         if (ret_var.is_owned) {
19098                 ret_ref |= 1;
19099         }
19100         return ret_ref;
19101 }
19102
19103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19104         if ((this_ptr & 1) != 0) return;
19105         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
19106         FREE((void*)this_ptr);
19107         NetAddress_free(this_ptr_conv);
19108 }
19109
19110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19111         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
19112         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19113         *ret_copy = NetAddress_clone(orig_conv);
19114         uint64_t ret_ref = (uint64_t)ret_copy;
19115         return ret_ref;
19116 }
19117
19118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
19119         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
19120         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
19121         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19122         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19123         CVec_u8Z_free(ret_var);
19124         return ret_arr;
19125 }
19126
19127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19128         LDKu8slice ser_ref;
19129         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19130         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19131         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
19132         *ret_conv = Result_read(ser_ref);
19133         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19134         return (uint64_t)ret_conv;
19135 }
19136
19137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19138         LDKu8slice ser_ref;
19139         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19140         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19141         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19142         *ret_conv = NetAddress_read(ser_ref);
19143         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19144         return (uint64_t)ret_conv;
19145 }
19146
19147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19148         LDKUnsignedNodeAnnouncement this_obj_conv;
19149         this_obj_conv.inner = (void*)(this_obj & (~1));
19150         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19151         UnsignedNodeAnnouncement_free(this_obj_conv);
19152 }
19153
19154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19155         LDKUnsignedNodeAnnouncement this_ptr_conv;
19156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19157         this_ptr_conv.is_owned = false;
19158         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
19159         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19160         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19161         uint64_t ret_ref = (uint64_t)ret_var.inner;
19162         if (ret_var.is_owned) {
19163                 ret_ref |= 1;
19164         }
19165         return ret_ref;
19166 }
19167
19168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19169         LDKUnsignedNodeAnnouncement this_ptr_conv;
19170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19171         this_ptr_conv.is_owned = false;
19172         LDKNodeFeatures val_conv;
19173         val_conv.inner = (void*)(val & (~1));
19174         val_conv.is_owned = (val & 1) || (val == 0);
19175         val_conv = NodeFeatures_clone(&val_conv);
19176         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
19177 }
19178
19179 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19180         LDKUnsignedNodeAnnouncement this_ptr_conv;
19181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19182         this_ptr_conv.is_owned = false;
19183         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
19184         return ret_val;
19185 }
19186
19187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19188         LDKUnsignedNodeAnnouncement this_ptr_conv;
19189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19190         this_ptr_conv.is_owned = false;
19191         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
19192 }
19193
19194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19195         LDKUnsignedNodeAnnouncement this_ptr_conv;
19196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19197         this_ptr_conv.is_owned = false;
19198         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
19200         return ret_arr;
19201 }
19202
19203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19204         LDKUnsignedNodeAnnouncement this_ptr_conv;
19205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19206         this_ptr_conv.is_owned = false;
19207         LDKPublicKey val_ref;
19208         CHECK((*env)->GetArrayLength(env, val) == 33);
19209         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19210         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
19211 }
19212
19213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
19214         LDKUnsignedNodeAnnouncement this_ptr_conv;
19215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19216         this_ptr_conv.is_owned = false;
19217         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
19218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
19219         return ret_arr;
19220 }
19221
19222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19223         LDKUnsignedNodeAnnouncement this_ptr_conv;
19224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19225         this_ptr_conv.is_owned = false;
19226         LDKThreeBytes val_ref;
19227         CHECK((*env)->GetArrayLength(env, val) == 3);
19228         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
19229         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
19230 }
19231
19232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
19233         LDKUnsignedNodeAnnouncement this_ptr_conv;
19234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19235         this_ptr_conv.is_owned = false;
19236         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19237         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
19238         return ret_arr;
19239 }
19240
19241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19242         LDKUnsignedNodeAnnouncement this_ptr_conv;
19243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19244         this_ptr_conv.is_owned = false;
19245         LDKThirtyTwoBytes val_ref;
19246         CHECK((*env)->GetArrayLength(env, val) == 32);
19247         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19248         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
19249 }
19250
19251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19252         LDKUnsignedNodeAnnouncement this_ptr_conv;
19253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19254         this_ptr_conv.is_owned = false;
19255         LDKCVec_NetAddressZ val_constr;
19256         val_constr.datalen = (*env)->GetArrayLength(env, val);
19257         if (val_constr.datalen > 0)
19258                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19259         else
19260                 val_constr.data = NULL;
19261         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19262         for (size_t m = 0; m < val_constr.datalen; m++) {
19263                 int64_t val_conv_12 = val_vals[m];
19264                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19265                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19266                 val_constr.data[m] = val_conv_12_conv;
19267         }
19268         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19269         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
19270 }
19271
19272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19273         LDKUnsignedNodeAnnouncement orig_conv;
19274         orig_conv.inner = (void*)(orig & (~1));
19275         orig_conv.is_owned = false;
19276         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
19277         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19278         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19279         uint64_t ret_ref = (uint64_t)ret_var.inner;
19280         if (ret_var.is_owned) {
19281                 ret_ref |= 1;
19282         }
19283         return ret_ref;
19284 }
19285
19286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19287         LDKNodeAnnouncement this_obj_conv;
19288         this_obj_conv.inner = (void*)(this_obj & (~1));
19289         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19290         NodeAnnouncement_free(this_obj_conv);
19291 }
19292
19293 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19294         LDKNodeAnnouncement this_ptr_conv;
19295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19296         this_ptr_conv.is_owned = false;
19297         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19298         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
19299         return ret_arr;
19300 }
19301
19302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19303         LDKNodeAnnouncement this_ptr_conv;
19304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19305         this_ptr_conv.is_owned = false;
19306         LDKSignature val_ref;
19307         CHECK((*env)->GetArrayLength(env, val) == 64);
19308         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19309         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
19310 }
19311
19312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19313         LDKNodeAnnouncement this_ptr_conv;
19314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19315         this_ptr_conv.is_owned = false;
19316         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
19317         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19318         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19319         uint64_t ret_ref = (uint64_t)ret_var.inner;
19320         if (ret_var.is_owned) {
19321                 ret_ref |= 1;
19322         }
19323         return ret_ref;
19324 }
19325
19326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19327         LDKNodeAnnouncement this_ptr_conv;
19328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19329         this_ptr_conv.is_owned = false;
19330         LDKUnsignedNodeAnnouncement val_conv;
19331         val_conv.inner = (void*)(val & (~1));
19332         val_conv.is_owned = (val & 1) || (val == 0);
19333         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
19334         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
19335 }
19336
19337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19338         LDKSignature signature_arg_ref;
19339         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19340         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19341         LDKUnsignedNodeAnnouncement contents_arg_conv;
19342         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19343         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19344         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
19345         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
19346         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19347         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19348         uint64_t ret_ref = (uint64_t)ret_var.inner;
19349         if (ret_var.is_owned) {
19350                 ret_ref |= 1;
19351         }
19352         return ret_ref;
19353 }
19354
19355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19356         LDKNodeAnnouncement orig_conv;
19357         orig_conv.inner = (void*)(orig & (~1));
19358         orig_conv.is_owned = false;
19359         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
19360         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19361         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19362         uint64_t ret_ref = (uint64_t)ret_var.inner;
19363         if (ret_var.is_owned) {
19364                 ret_ref |= 1;
19365         }
19366         return ret_ref;
19367 }
19368
19369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19370         LDKUnsignedChannelAnnouncement this_obj_conv;
19371         this_obj_conv.inner = (void*)(this_obj & (~1));
19372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19373         UnsignedChannelAnnouncement_free(this_obj_conv);
19374 }
19375
19376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19377         LDKUnsignedChannelAnnouncement this_ptr_conv;
19378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19379         this_ptr_conv.is_owned = false;
19380         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
19381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19383         uint64_t ret_ref = (uint64_t)ret_var.inner;
19384         if (ret_var.is_owned) {
19385                 ret_ref |= 1;
19386         }
19387         return ret_ref;
19388 }
19389
19390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19391         LDKUnsignedChannelAnnouncement this_ptr_conv;
19392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19393         this_ptr_conv.is_owned = false;
19394         LDKChannelFeatures val_conv;
19395         val_conv.inner = (void*)(val & (~1));
19396         val_conv.is_owned = (val & 1) || (val == 0);
19397         val_conv = ChannelFeatures_clone(&val_conv);
19398         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
19399 }
19400
19401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19402         LDKUnsignedChannelAnnouncement this_ptr_conv;
19403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19404         this_ptr_conv.is_owned = false;
19405         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19406         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
19407         return ret_arr;
19408 }
19409
19410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19411         LDKUnsignedChannelAnnouncement this_ptr_conv;
19412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19413         this_ptr_conv.is_owned = false;
19414         LDKThirtyTwoBytes val_ref;
19415         CHECK((*env)->GetArrayLength(env, val) == 32);
19416         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19417         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
19418 }
19419
19420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19421         LDKUnsignedChannelAnnouncement this_ptr_conv;
19422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19423         this_ptr_conv.is_owned = false;
19424         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
19425         return ret_val;
19426 }
19427
19428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19429         LDKUnsignedChannelAnnouncement this_ptr_conv;
19430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19431         this_ptr_conv.is_owned = false;
19432         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
19433 }
19434
19435 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19436         LDKUnsignedChannelAnnouncement this_ptr_conv;
19437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19438         this_ptr_conv.is_owned = false;
19439         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19440         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
19441         return ret_arr;
19442 }
19443
19444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19445         LDKUnsignedChannelAnnouncement this_ptr_conv;
19446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19447         this_ptr_conv.is_owned = false;
19448         LDKPublicKey val_ref;
19449         CHECK((*env)->GetArrayLength(env, val) == 33);
19450         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19451         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
19452 }
19453
19454 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19455         LDKUnsignedChannelAnnouncement this_ptr_conv;
19456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19457         this_ptr_conv.is_owned = false;
19458         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19459         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
19460         return ret_arr;
19461 }
19462
19463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19464         LDKUnsignedChannelAnnouncement this_ptr_conv;
19465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19466         this_ptr_conv.is_owned = false;
19467         LDKPublicKey val_ref;
19468         CHECK((*env)->GetArrayLength(env, val) == 33);
19469         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19470         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
19471 }
19472
19473 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19474         LDKUnsignedChannelAnnouncement this_ptr_conv;
19475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19476         this_ptr_conv.is_owned = false;
19477         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19478         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
19479         return ret_arr;
19480 }
19481
19482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19483         LDKUnsignedChannelAnnouncement this_ptr_conv;
19484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19485         this_ptr_conv.is_owned = false;
19486         LDKPublicKey val_ref;
19487         CHECK((*env)->GetArrayLength(env, val) == 33);
19488         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19489         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
19490 }
19491
19492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19493         LDKUnsignedChannelAnnouncement this_ptr_conv;
19494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19495         this_ptr_conv.is_owned = false;
19496         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19497         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
19498         return ret_arr;
19499 }
19500
19501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19502         LDKUnsignedChannelAnnouncement this_ptr_conv;
19503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19504         this_ptr_conv.is_owned = false;
19505         LDKPublicKey val_ref;
19506         CHECK((*env)->GetArrayLength(env, val) == 33);
19507         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19508         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
19509 }
19510
19511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19512         LDKUnsignedChannelAnnouncement orig_conv;
19513         orig_conv.inner = (void*)(orig & (~1));
19514         orig_conv.is_owned = false;
19515         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
19516         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19517         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19518         uint64_t ret_ref = (uint64_t)ret_var.inner;
19519         if (ret_var.is_owned) {
19520                 ret_ref |= 1;
19521         }
19522         return ret_ref;
19523 }
19524
19525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19526         LDKChannelAnnouncement this_obj_conv;
19527         this_obj_conv.inner = (void*)(this_obj & (~1));
19528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19529         ChannelAnnouncement_free(this_obj_conv);
19530 }
19531
19532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19533         LDKChannelAnnouncement this_ptr_conv;
19534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19535         this_ptr_conv.is_owned = false;
19536         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19537         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
19538         return ret_arr;
19539 }
19540
19541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19542         LDKChannelAnnouncement this_ptr_conv;
19543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19544         this_ptr_conv.is_owned = false;
19545         LDKSignature val_ref;
19546         CHECK((*env)->GetArrayLength(env, val) == 64);
19547         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19548         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
19549 }
19550
19551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19552         LDKChannelAnnouncement this_ptr_conv;
19553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19554         this_ptr_conv.is_owned = false;
19555         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
19557         return ret_arr;
19558 }
19559
19560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19561         LDKChannelAnnouncement this_ptr_conv;
19562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19563         this_ptr_conv.is_owned = false;
19564         LDKSignature val_ref;
19565         CHECK((*env)->GetArrayLength(env, val) == 64);
19566         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19567         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
19568 }
19569
19570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19571         LDKChannelAnnouncement this_ptr_conv;
19572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19573         this_ptr_conv.is_owned = false;
19574         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19575         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
19576         return ret_arr;
19577 }
19578
19579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19580         LDKChannelAnnouncement this_ptr_conv;
19581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19582         this_ptr_conv.is_owned = false;
19583         LDKSignature val_ref;
19584         CHECK((*env)->GetArrayLength(env, val) == 64);
19585         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19586         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
19587 }
19588
19589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19590         LDKChannelAnnouncement this_ptr_conv;
19591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19592         this_ptr_conv.is_owned = false;
19593         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
19595         return ret_arr;
19596 }
19597
19598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19599         LDKChannelAnnouncement this_ptr_conv;
19600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19601         this_ptr_conv.is_owned = false;
19602         LDKSignature val_ref;
19603         CHECK((*env)->GetArrayLength(env, val) == 64);
19604         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19605         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
19606 }
19607
19608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19609         LDKChannelAnnouncement this_ptr_conv;
19610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19611         this_ptr_conv.is_owned = false;
19612         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
19613         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19614         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19615         uint64_t ret_ref = (uint64_t)ret_var.inner;
19616         if (ret_var.is_owned) {
19617                 ret_ref |= 1;
19618         }
19619         return ret_ref;
19620 }
19621
19622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19623         LDKChannelAnnouncement this_ptr_conv;
19624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19625         this_ptr_conv.is_owned = false;
19626         LDKUnsignedChannelAnnouncement val_conv;
19627         val_conv.inner = (void*)(val & (~1));
19628         val_conv.is_owned = (val & 1) || (val == 0);
19629         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
19630         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
19631 }
19632
19633 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) {
19634         LDKSignature node_signature_1_arg_ref;
19635         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
19636         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
19637         LDKSignature node_signature_2_arg_ref;
19638         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
19639         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
19640         LDKSignature bitcoin_signature_1_arg_ref;
19641         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
19642         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
19643         LDKSignature bitcoin_signature_2_arg_ref;
19644         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
19645         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
19646         LDKUnsignedChannelAnnouncement contents_arg_conv;
19647         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19648         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19649         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
19650         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);
19651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19653         uint64_t ret_ref = (uint64_t)ret_var.inner;
19654         if (ret_var.is_owned) {
19655                 ret_ref |= 1;
19656         }
19657         return ret_ref;
19658 }
19659
19660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19661         LDKChannelAnnouncement orig_conv;
19662         orig_conv.inner = (void*)(orig & (~1));
19663         orig_conv.is_owned = false;
19664         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
19665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19667         uint64_t ret_ref = (uint64_t)ret_var.inner;
19668         if (ret_var.is_owned) {
19669                 ret_ref |= 1;
19670         }
19671         return ret_ref;
19672 }
19673
19674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19675         LDKUnsignedChannelUpdate this_obj_conv;
19676         this_obj_conv.inner = (void*)(this_obj & (~1));
19677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19678         UnsignedChannelUpdate_free(this_obj_conv);
19679 }
19680
19681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19682         LDKUnsignedChannelUpdate this_ptr_conv;
19683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19684         this_ptr_conv.is_owned = false;
19685         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19686         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
19687         return ret_arr;
19688 }
19689
19690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19691         LDKUnsignedChannelUpdate this_ptr_conv;
19692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19693         this_ptr_conv.is_owned = false;
19694         LDKThirtyTwoBytes val_ref;
19695         CHECK((*env)->GetArrayLength(env, val) == 32);
19696         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19697         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
19698 }
19699
19700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19701         LDKUnsignedChannelUpdate this_ptr_conv;
19702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19703         this_ptr_conv.is_owned = false;
19704         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
19705         return ret_val;
19706 }
19707
19708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19709         LDKUnsignedChannelUpdate this_ptr_conv;
19710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19711         this_ptr_conv.is_owned = false;
19712         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
19713 }
19714
19715 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19716         LDKUnsignedChannelUpdate this_ptr_conv;
19717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19718         this_ptr_conv.is_owned = false;
19719         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
19720         return ret_val;
19721 }
19722
19723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19724         LDKUnsignedChannelUpdate this_ptr_conv;
19725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19726         this_ptr_conv.is_owned = false;
19727         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
19728 }
19729
19730 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
19731         LDKUnsignedChannelUpdate this_ptr_conv;
19732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19733         this_ptr_conv.is_owned = false;
19734         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
19735         return ret_val;
19736 }
19737
19738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
19739         LDKUnsignedChannelUpdate this_ptr_conv;
19740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19741         this_ptr_conv.is_owned = false;
19742         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
19743 }
19744
19745 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19746         LDKUnsignedChannelUpdate this_ptr_conv;
19747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19748         this_ptr_conv.is_owned = false;
19749         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
19750         return ret_val;
19751 }
19752
19753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19754         LDKUnsignedChannelUpdate this_ptr_conv;
19755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19756         this_ptr_conv.is_owned = false;
19757         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
19758 }
19759
19760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19761         LDKUnsignedChannelUpdate this_ptr_conv;
19762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19763         this_ptr_conv.is_owned = false;
19764         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
19765         return ret_val;
19766 }
19767
19768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19769         LDKUnsignedChannelUpdate this_ptr_conv;
19770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19771         this_ptr_conv.is_owned = false;
19772         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
19773 }
19774
19775 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19776         LDKUnsignedChannelUpdate this_ptr_conv;
19777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19778         this_ptr_conv.is_owned = false;
19779         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
19780         return ret_val;
19781 }
19782
19783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19784         LDKUnsignedChannelUpdate this_ptr_conv;
19785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19786         this_ptr_conv.is_owned = false;
19787         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
19788 }
19789
19790 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
19791         LDKUnsignedChannelUpdate this_ptr_conv;
19792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19793         this_ptr_conv.is_owned = false;
19794         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
19795         return ret_val;
19796 }
19797
19798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19799         LDKUnsignedChannelUpdate this_ptr_conv;
19800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19801         this_ptr_conv.is_owned = false;
19802         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
19803 }
19804
19805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19806         LDKUnsignedChannelUpdate orig_conv;
19807         orig_conv.inner = (void*)(orig & (~1));
19808         orig_conv.is_owned = false;
19809         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19812         uint64_t ret_ref = (uint64_t)ret_var.inner;
19813         if (ret_var.is_owned) {
19814                 ret_ref |= 1;
19815         }
19816         return ret_ref;
19817 }
19818
19819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19820         LDKChannelUpdate this_obj_conv;
19821         this_obj_conv.inner = (void*)(this_obj & (~1));
19822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19823         ChannelUpdate_free(this_obj_conv);
19824 }
19825
19826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19827         LDKChannelUpdate this_ptr_conv;
19828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19829         this_ptr_conv.is_owned = false;
19830         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
19832         return ret_arr;
19833 }
19834
19835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19836         LDKChannelUpdate this_ptr_conv;
19837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19838         this_ptr_conv.is_owned = false;
19839         LDKSignature val_ref;
19840         CHECK((*env)->GetArrayLength(env, val) == 64);
19841         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19842         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19843 }
19844
19845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19846         LDKChannelUpdate this_ptr_conv;
19847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19848         this_ptr_conv.is_owned = false;
19849         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19850         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19851         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19852         uint64_t ret_ref = (uint64_t)ret_var.inner;
19853         if (ret_var.is_owned) {
19854                 ret_ref |= 1;
19855         }
19856         return ret_ref;
19857 }
19858
19859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19860         LDKChannelUpdate this_ptr_conv;
19861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19862         this_ptr_conv.is_owned = false;
19863         LDKUnsignedChannelUpdate val_conv;
19864         val_conv.inner = (void*)(val & (~1));
19865         val_conv.is_owned = (val & 1) || (val == 0);
19866         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19867         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19868 }
19869
19870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19871         LDKSignature signature_arg_ref;
19872         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19873         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19874         LDKUnsignedChannelUpdate contents_arg_conv;
19875         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19876         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19877         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19878         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19879         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19880         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19881         uint64_t ret_ref = (uint64_t)ret_var.inner;
19882         if (ret_var.is_owned) {
19883                 ret_ref |= 1;
19884         }
19885         return ret_ref;
19886 }
19887
19888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19889         LDKChannelUpdate orig_conv;
19890         orig_conv.inner = (void*)(orig & (~1));
19891         orig_conv.is_owned = false;
19892         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19893         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19894         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19895         uint64_t ret_ref = (uint64_t)ret_var.inner;
19896         if (ret_var.is_owned) {
19897                 ret_ref |= 1;
19898         }
19899         return ret_ref;
19900 }
19901
19902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19903         LDKQueryChannelRange this_obj_conv;
19904         this_obj_conv.inner = (void*)(this_obj & (~1));
19905         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19906         QueryChannelRange_free(this_obj_conv);
19907 }
19908
19909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19910         LDKQueryChannelRange this_ptr_conv;
19911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19912         this_ptr_conv.is_owned = false;
19913         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
19915         return ret_arr;
19916 }
19917
19918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19919         LDKQueryChannelRange this_ptr_conv;
19920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19921         this_ptr_conv.is_owned = false;
19922         LDKThirtyTwoBytes val_ref;
19923         CHECK((*env)->GetArrayLength(env, val) == 32);
19924         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19925         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19926 }
19927
19928 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19929         LDKQueryChannelRange this_ptr_conv;
19930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19931         this_ptr_conv.is_owned = false;
19932         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19933         return ret_val;
19934 }
19935
19936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19937         LDKQueryChannelRange this_ptr_conv;
19938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19939         this_ptr_conv.is_owned = false;
19940         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19941 }
19942
19943 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19944         LDKQueryChannelRange this_ptr_conv;
19945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19946         this_ptr_conv.is_owned = false;
19947         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19948         return ret_val;
19949 }
19950
19951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19952         LDKQueryChannelRange this_ptr_conv;
19953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19954         this_ptr_conv.is_owned = false;
19955         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19956 }
19957
19958 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) {
19959         LDKThirtyTwoBytes chain_hash_arg_ref;
19960         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19961         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19962         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19963         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19964         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19965         uint64_t ret_ref = (uint64_t)ret_var.inner;
19966         if (ret_var.is_owned) {
19967                 ret_ref |= 1;
19968         }
19969         return ret_ref;
19970 }
19971
19972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19973         LDKQueryChannelRange orig_conv;
19974         orig_conv.inner = (void*)(orig & (~1));
19975         orig_conv.is_owned = false;
19976         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19979         uint64_t ret_ref = (uint64_t)ret_var.inner;
19980         if (ret_var.is_owned) {
19981                 ret_ref |= 1;
19982         }
19983         return ret_ref;
19984 }
19985
19986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19987         LDKReplyChannelRange this_obj_conv;
19988         this_obj_conv.inner = (void*)(this_obj & (~1));
19989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19990         ReplyChannelRange_free(this_obj_conv);
19991 }
19992
19993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19994         LDKReplyChannelRange this_ptr_conv;
19995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19996         this_ptr_conv.is_owned = false;
19997         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19998         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
19999         return ret_arr;
20000 }
20001
20002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20003         LDKReplyChannelRange this_ptr_conv;
20004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20005         this_ptr_conv.is_owned = false;
20006         LDKThirtyTwoBytes val_ref;
20007         CHECK((*env)->GetArrayLength(env, val) == 32);
20008         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20009         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20010 }
20011
20012 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20013         LDKReplyChannelRange this_ptr_conv;
20014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20015         this_ptr_conv.is_owned = false;
20016         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
20017         return ret_val;
20018 }
20019
20020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20021         LDKReplyChannelRange this_ptr_conv;
20022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20023         this_ptr_conv.is_owned = false;
20024         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
20025 }
20026
20027 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20028         LDKReplyChannelRange this_ptr_conv;
20029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20030         this_ptr_conv.is_owned = false;
20031         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
20032         return ret_val;
20033 }
20034
20035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20036         LDKReplyChannelRange this_ptr_conv;
20037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20038         this_ptr_conv.is_owned = false;
20039         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20040 }
20041
20042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
20043         LDKReplyChannelRange this_ptr_conv;
20044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20045         this_ptr_conv.is_owned = false;
20046         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
20047         return ret_val;
20048 }
20049
20050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20051         LDKReplyChannelRange this_ptr_conv;
20052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20053         this_ptr_conv.is_owned = false;
20054         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
20055 }
20056
20057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20058         LDKReplyChannelRange this_ptr_conv;
20059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20060         this_ptr_conv.is_owned = false;
20061         LDKCVec_u64Z val_constr;
20062         val_constr.datalen = (*env)->GetArrayLength(env, val);
20063         if (val_constr.datalen > 0)
20064                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20065         else
20066                 val_constr.data = NULL;
20067         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20068         for (size_t g = 0; g < val_constr.datalen; g++) {
20069                 int64_t val_conv_6 = val_vals[g];
20070                 val_constr.data[g] = val_conv_6;
20071         }
20072         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20073         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
20074 }
20075
20076 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) {
20077         LDKThirtyTwoBytes chain_hash_arg_ref;
20078         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20079         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20080         LDKCVec_u64Z short_channel_ids_arg_constr;
20081         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20082         if (short_channel_ids_arg_constr.datalen > 0)
20083                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20084         else
20085                 short_channel_ids_arg_constr.data = NULL;
20086         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20087         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20088                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20089                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20090         }
20091         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20092         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
20093         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20094         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20095         uint64_t ret_ref = (uint64_t)ret_var.inner;
20096         if (ret_var.is_owned) {
20097                 ret_ref |= 1;
20098         }
20099         return ret_ref;
20100 }
20101
20102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20103         LDKReplyChannelRange orig_conv;
20104         orig_conv.inner = (void*)(orig & (~1));
20105         orig_conv.is_owned = false;
20106         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
20107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20109         uint64_t ret_ref = (uint64_t)ret_var.inner;
20110         if (ret_var.is_owned) {
20111                 ret_ref |= 1;
20112         }
20113         return ret_ref;
20114 }
20115
20116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20117         LDKQueryShortChannelIds this_obj_conv;
20118         this_obj_conv.inner = (void*)(this_obj & (~1));
20119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20120         QueryShortChannelIds_free(this_obj_conv);
20121 }
20122
20123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20124         LDKQueryShortChannelIds this_ptr_conv;
20125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20126         this_ptr_conv.is_owned = false;
20127         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20128         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
20129         return ret_arr;
20130 }
20131
20132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20133         LDKQueryShortChannelIds this_ptr_conv;
20134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20135         this_ptr_conv.is_owned = false;
20136         LDKThirtyTwoBytes val_ref;
20137         CHECK((*env)->GetArrayLength(env, val) == 32);
20138         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20139         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
20140 }
20141
20142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20143         LDKQueryShortChannelIds this_ptr_conv;
20144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20145         this_ptr_conv.is_owned = false;
20146         LDKCVec_u64Z val_constr;
20147         val_constr.datalen = (*env)->GetArrayLength(env, val);
20148         if (val_constr.datalen > 0)
20149                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20150         else
20151                 val_constr.data = NULL;
20152         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20153         for (size_t g = 0; g < val_constr.datalen; g++) {
20154                 int64_t val_conv_6 = val_vals[g];
20155                 val_constr.data[g] = val_conv_6;
20156         }
20157         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20158         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
20159 }
20160
20161 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) {
20162         LDKThirtyTwoBytes chain_hash_arg_ref;
20163         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20164         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20165         LDKCVec_u64Z short_channel_ids_arg_constr;
20166         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20167         if (short_channel_ids_arg_constr.datalen > 0)
20168                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20169         else
20170                 short_channel_ids_arg_constr.data = NULL;
20171         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20172         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20173                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20174                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20175         }
20176         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20177         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
20178         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20179         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20180         uint64_t ret_ref = (uint64_t)ret_var.inner;
20181         if (ret_var.is_owned) {
20182                 ret_ref |= 1;
20183         }
20184         return ret_ref;
20185 }
20186
20187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20188         LDKQueryShortChannelIds orig_conv;
20189         orig_conv.inner = (void*)(orig & (~1));
20190         orig_conv.is_owned = false;
20191         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
20192         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20193         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20194         uint64_t ret_ref = (uint64_t)ret_var.inner;
20195         if (ret_var.is_owned) {
20196                 ret_ref |= 1;
20197         }
20198         return ret_ref;
20199 }
20200
20201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20202         LDKReplyShortChannelIdsEnd this_obj_conv;
20203         this_obj_conv.inner = (void*)(this_obj & (~1));
20204         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20205         ReplyShortChannelIdsEnd_free(this_obj_conv);
20206 }
20207
20208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20209         LDKReplyShortChannelIdsEnd this_ptr_conv;
20210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20211         this_ptr_conv.is_owned = false;
20212         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20213         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
20214         return ret_arr;
20215 }
20216
20217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20218         LDKReplyShortChannelIdsEnd this_ptr_conv;
20219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20220         this_ptr_conv.is_owned = false;
20221         LDKThirtyTwoBytes val_ref;
20222         CHECK((*env)->GetArrayLength(env, val) == 32);
20223         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20224         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
20225 }
20226
20227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
20228         LDKReplyShortChannelIdsEnd this_ptr_conv;
20229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20230         this_ptr_conv.is_owned = false;
20231         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
20232         return ret_val;
20233 }
20234
20235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20236         LDKReplyShortChannelIdsEnd this_ptr_conv;
20237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20238         this_ptr_conv.is_owned = false;
20239         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
20240 }
20241
20242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
20243         LDKThirtyTwoBytes chain_hash_arg_ref;
20244         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20245         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20246         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
20247         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20248         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20249         uint64_t ret_ref = (uint64_t)ret_var.inner;
20250         if (ret_var.is_owned) {
20251                 ret_ref |= 1;
20252         }
20253         return ret_ref;
20254 }
20255
20256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20257         LDKReplyShortChannelIdsEnd orig_conv;
20258         orig_conv.inner = (void*)(orig & (~1));
20259         orig_conv.is_owned = false;
20260         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
20261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20263         uint64_t ret_ref = (uint64_t)ret_var.inner;
20264         if (ret_var.is_owned) {
20265                 ret_ref |= 1;
20266         }
20267         return ret_ref;
20268 }
20269
20270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20271         LDKGossipTimestampFilter this_obj_conv;
20272         this_obj_conv.inner = (void*)(this_obj & (~1));
20273         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20274         GossipTimestampFilter_free(this_obj_conv);
20275 }
20276
20277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20278         LDKGossipTimestampFilter this_ptr_conv;
20279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20280         this_ptr_conv.is_owned = false;
20281         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20282         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
20283         return ret_arr;
20284 }
20285
20286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20287         LDKGossipTimestampFilter this_ptr_conv;
20288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20289         this_ptr_conv.is_owned = false;
20290         LDKThirtyTwoBytes val_ref;
20291         CHECK((*env)->GetArrayLength(env, val) == 32);
20292         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20293         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
20294 }
20295
20296 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20297         LDKGossipTimestampFilter this_ptr_conv;
20298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20299         this_ptr_conv.is_owned = false;
20300         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
20301         return ret_val;
20302 }
20303
20304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20305         LDKGossipTimestampFilter this_ptr_conv;
20306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20307         this_ptr_conv.is_owned = false;
20308         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
20309 }
20310
20311 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
20312         LDKGossipTimestampFilter this_ptr_conv;
20313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20314         this_ptr_conv.is_owned = false;
20315         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
20316         return ret_val;
20317 }
20318
20319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20320         LDKGossipTimestampFilter this_ptr_conv;
20321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20322         this_ptr_conv.is_owned = false;
20323         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
20324 }
20325
20326 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) {
20327         LDKThirtyTwoBytes chain_hash_arg_ref;
20328         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20329         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20330         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
20331         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20332         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20333         uint64_t ret_ref = (uint64_t)ret_var.inner;
20334         if (ret_var.is_owned) {
20335                 ret_ref |= 1;
20336         }
20337         return ret_ref;
20338 }
20339
20340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20341         LDKGossipTimestampFilter orig_conv;
20342         orig_conv.inner = (void*)(orig & (~1));
20343         orig_conv.is_owned = false;
20344         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
20345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20347         uint64_t ret_ref = (uint64_t)ret_var.inner;
20348         if (ret_var.is_owned) {
20349                 ret_ref |= 1;
20350         }
20351         return ret_ref;
20352 }
20353
20354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20355         if ((this_ptr & 1) != 0) return;
20356         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
20357         FREE((void*)this_ptr);
20358         ErrorAction_free(this_ptr_conv);
20359 }
20360
20361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20362         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
20363         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20364         *ret_copy = ErrorAction_clone(orig_conv);
20365         uint64_t ret_ref = (uint64_t)ret_copy;
20366         return ret_ref;
20367 }
20368
20369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20370         LDKLightningError this_obj_conv;
20371         this_obj_conv.inner = (void*)(this_obj & (~1));
20372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20373         LightningError_free(this_obj_conv);
20374 }
20375
20376 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
20377         LDKLightningError this_ptr_conv;
20378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20379         this_ptr_conv.is_owned = false;
20380         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
20381         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20382         Str_free(ret_str);
20383         return ret_conv;
20384 }
20385
20386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20387         LDKLightningError this_ptr_conv;
20388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20389         this_ptr_conv.is_owned = false;
20390         LDKStr val_conv = java_to_owned_str(env, val);
20391         LightningError_set_err(&this_ptr_conv, val_conv);
20392 }
20393
20394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
20395         LDKLightningError this_ptr_conv;
20396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20397         this_ptr_conv.is_owned = false;
20398         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20399         *ret_copy = LightningError_get_action(&this_ptr_conv);
20400         uint64_t ret_ref = (uint64_t)ret_copy;
20401         return ret_ref;
20402 }
20403
20404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20405         LDKLightningError this_ptr_conv;
20406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20407         this_ptr_conv.is_owned = false;
20408         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
20409         LightningError_set_action(&this_ptr_conv, val_conv);
20410 }
20411
20412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
20413         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
20414         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
20415         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
20416         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20417         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20418         uint64_t ret_ref = (uint64_t)ret_var.inner;
20419         if (ret_var.is_owned) {
20420                 ret_ref |= 1;
20421         }
20422         return ret_ref;
20423 }
20424
20425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20426         LDKLightningError orig_conv;
20427         orig_conv.inner = (void*)(orig & (~1));
20428         orig_conv.is_owned = false;
20429         LDKLightningError ret_var = LightningError_clone(&orig_conv);
20430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20432         uint64_t ret_ref = (uint64_t)ret_var.inner;
20433         if (ret_var.is_owned) {
20434                 ret_ref |= 1;
20435         }
20436         return ret_ref;
20437 }
20438
20439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20440         LDKCommitmentUpdate this_obj_conv;
20441         this_obj_conv.inner = (void*)(this_obj & (~1));
20442         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20443         CommitmentUpdate_free(this_obj_conv);
20444 }
20445
20446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20447         LDKCommitmentUpdate this_ptr_conv;
20448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20449         this_ptr_conv.is_owned = false;
20450         LDKCVec_UpdateAddHTLCZ val_constr;
20451         val_constr.datalen = (*env)->GetArrayLength(env, val);
20452         if (val_constr.datalen > 0)
20453                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20454         else
20455                 val_constr.data = NULL;
20456         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20457         for (size_t p = 0; p < val_constr.datalen; p++) {
20458                 int64_t val_conv_15 = val_vals[p];
20459                 LDKUpdateAddHTLC val_conv_15_conv;
20460                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
20461                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
20462                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
20463                 val_constr.data[p] = val_conv_15_conv;
20464         }
20465         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20466         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
20467 }
20468
20469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20470         LDKCommitmentUpdate this_ptr_conv;
20471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20472         this_ptr_conv.is_owned = false;
20473         LDKCVec_UpdateFulfillHTLCZ val_constr;
20474         val_constr.datalen = (*env)->GetArrayLength(env, val);
20475         if (val_constr.datalen > 0)
20476                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20477         else
20478                 val_constr.data = NULL;
20479         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20480         for (size_t t = 0; t < val_constr.datalen; t++) {
20481                 int64_t val_conv_19 = val_vals[t];
20482                 LDKUpdateFulfillHTLC val_conv_19_conv;
20483                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
20484                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
20485                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
20486                 val_constr.data[t] = val_conv_19_conv;
20487         }
20488         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20489         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
20490 }
20491
20492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20493         LDKCommitmentUpdate this_ptr_conv;
20494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20495         this_ptr_conv.is_owned = false;
20496         LDKCVec_UpdateFailHTLCZ val_constr;
20497         val_constr.datalen = (*env)->GetArrayLength(env, val);
20498         if (val_constr.datalen > 0)
20499                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20500         else
20501                 val_constr.data = NULL;
20502         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20503         for (size_t q = 0; q < val_constr.datalen; q++) {
20504                 int64_t val_conv_16 = val_vals[q];
20505                 LDKUpdateFailHTLC val_conv_16_conv;
20506                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
20507                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
20508                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
20509                 val_constr.data[q] = val_conv_16_conv;
20510         }
20511         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20512         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
20513 }
20514
20515 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) {
20516         LDKCommitmentUpdate this_ptr_conv;
20517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20518         this_ptr_conv.is_owned = false;
20519         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
20520         val_constr.datalen = (*env)->GetArrayLength(env, val);
20521         if (val_constr.datalen > 0)
20522                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20523         else
20524                 val_constr.data = NULL;
20525         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20526         for (size_t z = 0; z < val_constr.datalen; z++) {
20527                 int64_t val_conv_25 = val_vals[z];
20528                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
20529                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
20530                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
20531                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
20532                 val_constr.data[z] = val_conv_25_conv;
20533         }
20534         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20535         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
20536 }
20537
20538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
20539         LDKCommitmentUpdate this_ptr_conv;
20540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20541         this_ptr_conv.is_owned = false;
20542         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
20543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20545         uint64_t ret_ref = (uint64_t)ret_var.inner;
20546         if (ret_var.is_owned) {
20547                 ret_ref |= 1;
20548         }
20549         return ret_ref;
20550 }
20551
20552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20553         LDKCommitmentUpdate this_ptr_conv;
20554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20555         this_ptr_conv.is_owned = false;
20556         LDKUpdateFee val_conv;
20557         val_conv.inner = (void*)(val & (~1));
20558         val_conv.is_owned = (val & 1) || (val == 0);
20559         val_conv = UpdateFee_clone(&val_conv);
20560         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
20561 }
20562
20563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
20564         LDKCommitmentUpdate this_ptr_conv;
20565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20566         this_ptr_conv.is_owned = false;
20567         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
20568         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20569         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20570         uint64_t ret_ref = (uint64_t)ret_var.inner;
20571         if (ret_var.is_owned) {
20572                 ret_ref |= 1;
20573         }
20574         return ret_ref;
20575 }
20576
20577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20578         LDKCommitmentUpdate this_ptr_conv;
20579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20580         this_ptr_conv.is_owned = false;
20581         LDKCommitmentSigned val_conv;
20582         val_conv.inner = (void*)(val & (~1));
20583         val_conv.is_owned = (val & 1) || (val == 0);
20584         val_conv = CommitmentSigned_clone(&val_conv);
20585         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
20586 }
20587
20588 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) {
20589         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
20590         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
20591         if (update_add_htlcs_arg_constr.datalen > 0)
20592                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20593         else
20594                 update_add_htlcs_arg_constr.data = NULL;
20595         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
20596         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
20597                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
20598                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
20599                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
20600                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
20601                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
20602                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
20603         }
20604         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
20605         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
20606         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
20607         if (update_fulfill_htlcs_arg_constr.datalen > 0)
20608                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20609         else
20610                 update_fulfill_htlcs_arg_constr.data = NULL;
20611         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
20612         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
20613                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
20614                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
20615                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
20616                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
20617                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
20618                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
20619         }
20620         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
20621         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
20622         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
20623         if (update_fail_htlcs_arg_constr.datalen > 0)
20624                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20625         else
20626                 update_fail_htlcs_arg_constr.data = NULL;
20627         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
20628         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
20629                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
20630                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
20631                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
20632                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
20633                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
20634                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
20635         }
20636         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
20637         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
20638         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
20639         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
20640                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20641         else
20642                 update_fail_malformed_htlcs_arg_constr.data = NULL;
20643         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
20644         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
20645                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
20646                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
20647                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
20648                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = (update_fail_malformed_htlcs_arg_conv_25 & 1) || (update_fail_malformed_htlcs_arg_conv_25 == 0);
20649                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
20650                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
20651         }
20652         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
20653         LDKUpdateFee update_fee_arg_conv;
20654         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
20655         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
20656         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
20657         LDKCommitmentSigned commitment_signed_arg_conv;
20658         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
20659         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
20660         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
20661         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);
20662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20664         uint64_t ret_ref = (uint64_t)ret_var.inner;
20665         if (ret_var.is_owned) {
20666                 ret_ref |= 1;
20667         }
20668         return ret_ref;
20669 }
20670
20671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20672         LDKCommitmentUpdate orig_conv;
20673         orig_conv.inner = (void*)(orig & (~1));
20674         orig_conv.is_owned = false;
20675         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
20676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20678         uint64_t ret_ref = (uint64_t)ret_var.inner;
20679         if (ret_var.is_owned) {
20680                 ret_ref |= 1;
20681         }
20682         return ret_ref;
20683 }
20684
20685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20686         if ((this_ptr & 1) != 0) return;
20687         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
20688         FREE((void*)this_ptr);
20689         HTLCFailChannelUpdate_free(this_ptr_conv);
20690 }
20691
20692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20693         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
20694         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
20695         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
20696         uint64_t ret_ref = (uint64_t)ret_copy;
20697         return ret_ref;
20698 }
20699
20700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20701         if ((this_ptr & 1) != 0) return;
20702         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
20703         FREE((void*)this_ptr);
20704         ChannelMessageHandler_free(this_ptr_conv);
20705 }
20706
20707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20708         if ((this_ptr & 1) != 0) return;
20709         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
20710         FREE((void*)this_ptr);
20711         RoutingMessageHandler_free(this_ptr_conv);
20712 }
20713
20714 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20715         LDKAcceptChannel obj_conv;
20716         obj_conv.inner = (void*)(obj & (~1));
20717         obj_conv.is_owned = false;
20718         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
20719         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20720         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20721         CVec_u8Z_free(ret_var);
20722         return ret_arr;
20723 }
20724
20725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20726         LDKu8slice ser_ref;
20727         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20728         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20729         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20730         *ret_conv = AcceptChannel_read(ser_ref);
20731         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20732         return (uint64_t)ret_conv;
20733 }
20734
20735 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
20736         LDKAnnouncementSignatures obj_conv;
20737         obj_conv.inner = (void*)(obj & (~1));
20738         obj_conv.is_owned = false;
20739         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
20740         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20741         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20742         CVec_u8Z_free(ret_var);
20743         return ret_arr;
20744 }
20745
20746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20747         LDKu8slice ser_ref;
20748         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20749         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20750         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20751         *ret_conv = AnnouncementSignatures_read(ser_ref);
20752         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20753         return (uint64_t)ret_conv;
20754 }
20755
20756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
20757         LDKChannelReestablish obj_conv;
20758         obj_conv.inner = (void*)(obj & (~1));
20759         obj_conv.is_owned = false;
20760         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
20761         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20762         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20763         CVec_u8Z_free(ret_var);
20764         return ret_arr;
20765 }
20766
20767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20768         LDKu8slice ser_ref;
20769         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20770         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20771         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20772         *ret_conv = ChannelReestablish_read(ser_ref);
20773         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20774         return (uint64_t)ret_conv;
20775 }
20776
20777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20778         LDKClosingSigned obj_conv;
20779         obj_conv.inner = (void*)(obj & (~1));
20780         obj_conv.is_owned = false;
20781         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
20782         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20783         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20784         CVec_u8Z_free(ret_var);
20785         return ret_arr;
20786 }
20787
20788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20789         LDKu8slice ser_ref;
20790         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20791         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20792         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20793         *ret_conv = ClosingSigned_read(ser_ref);
20794         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20795         return (uint64_t)ret_conv;
20796 }
20797
20798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20799         LDKCommitmentSigned obj_conv;
20800         obj_conv.inner = (void*)(obj & (~1));
20801         obj_conv.is_owned = false;
20802         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
20803         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20804         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20805         CVec_u8Z_free(ret_var);
20806         return ret_arr;
20807 }
20808
20809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20810         LDKu8slice ser_ref;
20811         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20812         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20813         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20814         *ret_conv = CommitmentSigned_read(ser_ref);
20815         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20816         return (uint64_t)ret_conv;
20817 }
20818
20819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
20820         LDKFundingCreated obj_conv;
20821         obj_conv.inner = (void*)(obj & (~1));
20822         obj_conv.is_owned = false;
20823         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20824         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20825         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20826         CVec_u8Z_free(ret_var);
20827         return ret_arr;
20828 }
20829
20830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20831         LDKu8slice ser_ref;
20832         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20833         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20834         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20835         *ret_conv = FundingCreated_read(ser_ref);
20836         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20837         return (uint64_t)ret_conv;
20838 }
20839
20840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20841         LDKFundingSigned obj_conv;
20842         obj_conv.inner = (void*)(obj & (~1));
20843         obj_conv.is_owned = false;
20844         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20845         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20846         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20847         CVec_u8Z_free(ret_var);
20848         return ret_arr;
20849 }
20850
20851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20852         LDKu8slice ser_ref;
20853         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20854         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20855         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20856         *ret_conv = FundingSigned_read(ser_ref);
20857         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20858         return (uint64_t)ret_conv;
20859 }
20860
20861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
20862         LDKFundingLocked obj_conv;
20863         obj_conv.inner = (void*)(obj & (~1));
20864         obj_conv.is_owned = false;
20865         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20866         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20867         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20868         CVec_u8Z_free(ret_var);
20869         return ret_arr;
20870 }
20871
20872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20873         LDKu8slice ser_ref;
20874         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20875         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20876         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20877         *ret_conv = FundingLocked_read(ser_ref);
20878         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20879         return (uint64_t)ret_conv;
20880 }
20881
20882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
20883         LDKInit obj_conv;
20884         obj_conv.inner = (void*)(obj & (~1));
20885         obj_conv.is_owned = false;
20886         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20887         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20888         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20889         CVec_u8Z_free(ret_var);
20890         return ret_arr;
20891 }
20892
20893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20894         LDKu8slice ser_ref;
20895         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20896         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20897         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20898         *ret_conv = Init_read(ser_ref);
20899         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20900         return (uint64_t)ret_conv;
20901 }
20902
20903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20904         LDKOpenChannel obj_conv;
20905         obj_conv.inner = (void*)(obj & (~1));
20906         obj_conv.is_owned = false;
20907         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20908         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20909         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20910         CVec_u8Z_free(ret_var);
20911         return ret_arr;
20912 }
20913
20914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20915         LDKu8slice ser_ref;
20916         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20917         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20918         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20919         *ret_conv = OpenChannel_read(ser_ref);
20920         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20921         return (uint64_t)ret_conv;
20922 }
20923
20924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
20925         LDKRevokeAndACK obj_conv;
20926         obj_conv.inner = (void*)(obj & (~1));
20927         obj_conv.is_owned = false;
20928         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20929         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20930         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20931         CVec_u8Z_free(ret_var);
20932         return ret_arr;
20933 }
20934
20935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20936         LDKu8slice ser_ref;
20937         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20938         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20939         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20940         *ret_conv = RevokeAndACK_read(ser_ref);
20941         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20942         return (uint64_t)ret_conv;
20943 }
20944
20945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
20946         LDKShutdown obj_conv;
20947         obj_conv.inner = (void*)(obj & (~1));
20948         obj_conv.is_owned = false;
20949         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20950         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20951         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20952         CVec_u8Z_free(ret_var);
20953         return ret_arr;
20954 }
20955
20956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20957         LDKu8slice ser_ref;
20958         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20959         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20960         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20961         *ret_conv = Shutdown_read(ser_ref);
20962         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20963         return (uint64_t)ret_conv;
20964 }
20965
20966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20967         LDKUpdateFailHTLC obj_conv;
20968         obj_conv.inner = (void*)(obj & (~1));
20969         obj_conv.is_owned = false;
20970         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20971         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20972         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20973         CVec_u8Z_free(ret_var);
20974         return ret_arr;
20975 }
20976
20977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20978         LDKu8slice ser_ref;
20979         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20980         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20981         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20982         *ret_conv = UpdateFailHTLC_read(ser_ref);
20983         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20984         return (uint64_t)ret_conv;
20985 }
20986
20987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20988         LDKUpdateFailMalformedHTLC obj_conv;
20989         obj_conv.inner = (void*)(obj & (~1));
20990         obj_conv.is_owned = false;
20991         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20992         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20993         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20994         CVec_u8Z_free(ret_var);
20995         return ret_arr;
20996 }
20997
20998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20999         LDKu8slice ser_ref;
21000         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21001         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21002         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21003         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
21004         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21005         return (uint64_t)ret_conv;
21006 }
21007
21008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
21009         LDKUpdateFee obj_conv;
21010         obj_conv.inner = (void*)(obj & (~1));
21011         obj_conv.is_owned = false;
21012         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
21013         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21014         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21015         CVec_u8Z_free(ret_var);
21016         return ret_arr;
21017 }
21018
21019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21020         LDKu8slice ser_ref;
21021         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21022         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21023         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21024         *ret_conv = UpdateFee_read(ser_ref);
21025         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21026         return (uint64_t)ret_conv;
21027 }
21028
21029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21030         LDKUpdateFulfillHTLC obj_conv;
21031         obj_conv.inner = (void*)(obj & (~1));
21032         obj_conv.is_owned = false;
21033         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
21034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21036         CVec_u8Z_free(ret_var);
21037         return ret_arr;
21038 }
21039
21040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21041         LDKu8slice ser_ref;
21042         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21043         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21044         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21045         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
21046         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21047         return (uint64_t)ret_conv;
21048 }
21049
21050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21051         LDKUpdateAddHTLC obj_conv;
21052         obj_conv.inner = (void*)(obj & (~1));
21053         obj_conv.is_owned = false;
21054         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
21055         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21056         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21057         CVec_u8Z_free(ret_var);
21058         return ret_arr;
21059 }
21060
21061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21062         LDKu8slice ser_ref;
21063         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21064         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21065         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21066         *ret_conv = UpdateAddHTLC_read(ser_ref);
21067         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21068         return (uint64_t)ret_conv;
21069 }
21070
21071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
21072         LDKPing obj_conv;
21073         obj_conv.inner = (void*)(obj & (~1));
21074         obj_conv.is_owned = false;
21075         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
21076         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21077         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21078         CVec_u8Z_free(ret_var);
21079         return ret_arr;
21080 }
21081
21082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21083         LDKu8slice ser_ref;
21084         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21085         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21086         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21087         *ret_conv = Ping_read(ser_ref);
21088         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21089         return (uint64_t)ret_conv;
21090 }
21091
21092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
21093         LDKPong obj_conv;
21094         obj_conv.inner = (void*)(obj & (~1));
21095         obj_conv.is_owned = false;
21096         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
21097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21099         CVec_u8Z_free(ret_var);
21100         return ret_arr;
21101 }
21102
21103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21104         LDKu8slice ser_ref;
21105         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21106         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21107         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21108         *ret_conv = Pong_read(ser_ref);
21109         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21110         return (uint64_t)ret_conv;
21111 }
21112
21113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21114         LDKUnsignedChannelAnnouncement obj_conv;
21115         obj_conv.inner = (void*)(obj & (~1));
21116         obj_conv.is_owned = false;
21117         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
21118         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21119         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21120         CVec_u8Z_free(ret_var);
21121         return ret_arr;
21122 }
21123
21124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21125         LDKu8slice ser_ref;
21126         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21127         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21128         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21129         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
21130         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21131         return (uint64_t)ret_conv;
21132 }
21133
21134 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21135         LDKChannelAnnouncement obj_conv;
21136         obj_conv.inner = (void*)(obj & (~1));
21137         obj_conv.is_owned = false;
21138         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
21139         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21140         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21141         CVec_u8Z_free(ret_var);
21142         return ret_arr;
21143 }
21144
21145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21146         LDKu8slice ser_ref;
21147         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21148         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21149         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21150         *ret_conv = ChannelAnnouncement_read(ser_ref);
21151         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21152         return (uint64_t)ret_conv;
21153 }
21154
21155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21156         LDKUnsignedChannelUpdate obj_conv;
21157         obj_conv.inner = (void*)(obj & (~1));
21158         obj_conv.is_owned = false;
21159         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
21160         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21161         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21162         CVec_u8Z_free(ret_var);
21163         return ret_arr;
21164 }
21165
21166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21167         LDKu8slice ser_ref;
21168         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21169         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21170         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21171         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
21172         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21173         return (uint64_t)ret_conv;
21174 }
21175
21176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21177         LDKChannelUpdate obj_conv;
21178         obj_conv.inner = (void*)(obj & (~1));
21179         obj_conv.is_owned = false;
21180         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
21181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21183         CVec_u8Z_free(ret_var);
21184         return ret_arr;
21185 }
21186
21187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21188         LDKu8slice ser_ref;
21189         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21190         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21191         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21192         *ret_conv = ChannelUpdate_read(ser_ref);
21193         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21194         return (uint64_t)ret_conv;
21195 }
21196
21197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
21198         LDKErrorMessage obj_conv;
21199         obj_conv.inner = (void*)(obj & (~1));
21200         obj_conv.is_owned = false;
21201         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
21202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21204         CVec_u8Z_free(ret_var);
21205         return ret_arr;
21206 }
21207
21208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21209         LDKu8slice ser_ref;
21210         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21211         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21212         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21213         *ret_conv = ErrorMessage_read(ser_ref);
21214         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21215         return (uint64_t)ret_conv;
21216 }
21217
21218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21219         LDKUnsignedNodeAnnouncement obj_conv;
21220         obj_conv.inner = (void*)(obj & (~1));
21221         obj_conv.is_owned = false;
21222         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
21223         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21224         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21225         CVec_u8Z_free(ret_var);
21226         return ret_arr;
21227 }
21228
21229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21230         LDKu8slice ser_ref;
21231         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21232         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21233         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
21234         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
21235         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21236         return (uint64_t)ret_conv;
21237 }
21238
21239 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21240         LDKNodeAnnouncement obj_conv;
21241         obj_conv.inner = (void*)(obj & (~1));
21242         obj_conv.is_owned = false;
21243         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
21244         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21245         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21246         CVec_u8Z_free(ret_var);
21247         return ret_arr;
21248 }
21249
21250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21251         LDKu8slice ser_ref;
21252         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21253         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21254         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
21255         *ret_conv = NodeAnnouncement_read(ser_ref);
21256         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21257         return (uint64_t)ret_conv;
21258 }
21259
21260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21261         LDKu8slice ser_ref;
21262         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21263         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21264         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21265         *ret_conv = QueryShortChannelIds_read(ser_ref);
21266         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21267         return (uint64_t)ret_conv;
21268 }
21269
21270 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
21271         LDKQueryShortChannelIds obj_conv;
21272         obj_conv.inner = (void*)(obj & (~1));
21273         obj_conv.is_owned = false;
21274         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
21275         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21276         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21277         CVec_u8Z_free(ret_var);
21278         return ret_arr;
21279 }
21280
21281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21282         LDKu8slice ser_ref;
21283         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21284         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21285         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21286         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
21287         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21288         return (uint64_t)ret_conv;
21289 }
21290
21291 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
21292         LDKReplyShortChannelIdsEnd obj_conv;
21293         obj_conv.inner = (void*)(obj & (~1));
21294         obj_conv.is_owned = false;
21295         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
21296         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21297         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21298         CVec_u8Z_free(ret_var);
21299         return ret_arr;
21300 }
21301
21302 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
21303         LDKQueryChannelRange this_arg_conv;
21304         this_arg_conv.inner = (void*)(this_arg & (~1));
21305         this_arg_conv.is_owned = false;
21306         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
21307         return ret_val;
21308 }
21309
21310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21311         LDKu8slice ser_ref;
21312         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21313         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21314         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21315         *ret_conv = QueryChannelRange_read(ser_ref);
21316         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21317         return (uint64_t)ret_conv;
21318 }
21319
21320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21321         LDKQueryChannelRange obj_conv;
21322         obj_conv.inner = (void*)(obj & (~1));
21323         obj_conv.is_owned = false;
21324         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
21325         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21326         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21327         CVec_u8Z_free(ret_var);
21328         return ret_arr;
21329 }
21330
21331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21332         LDKu8slice ser_ref;
21333         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21334         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21335         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21336         *ret_conv = ReplyChannelRange_read(ser_ref);
21337         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21338         return (uint64_t)ret_conv;
21339 }
21340
21341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21342         LDKReplyChannelRange obj_conv;
21343         obj_conv.inner = (void*)(obj & (~1));
21344         obj_conv.is_owned = false;
21345         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
21346         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21347         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21348         CVec_u8Z_free(ret_var);
21349         return ret_arr;
21350 }
21351
21352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21353         LDKu8slice ser_ref;
21354         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21355         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21356         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21357         *ret_conv = GossipTimestampFilter_read(ser_ref);
21358         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21359         return (uint64_t)ret_conv;
21360 }
21361
21362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
21363         LDKGossipTimestampFilter obj_conv;
21364         obj_conv.inner = (void*)(obj & (~1));
21365         obj_conv.is_owned = false;
21366         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
21367         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21368         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21369         CVec_u8Z_free(ret_var);
21370         return ret_arr;
21371 }
21372
21373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21374         LDKIgnoringMessageHandler this_obj_conv;
21375         this_obj_conv.inner = (void*)(this_obj & (~1));
21376         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21377         IgnoringMessageHandler_free(this_obj_conv);
21378 }
21379
21380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
21381         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
21382         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21383         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21384         uint64_t ret_ref = (uint64_t)ret_var.inner;
21385         if (ret_var.is_owned) {
21386                 ret_ref |= 1;
21387         }
21388         return ret_ref;
21389 }
21390
21391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21392         LDKIgnoringMessageHandler this_arg_conv;
21393         this_arg_conv.inner = (void*)(this_arg & (~1));
21394         this_arg_conv.is_owned = false;
21395         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21396         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21397         return (uint64_t)ret;
21398 }
21399
21400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21401         LDKIgnoringMessageHandler this_arg_conv;
21402         this_arg_conv.inner = (void*)(this_arg & (~1));
21403         this_arg_conv.is_owned = false;
21404         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21405         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
21406         return (uint64_t)ret;
21407 }
21408
21409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21410         LDKErroringMessageHandler this_obj_conv;
21411         this_obj_conv.inner = (void*)(this_obj & (~1));
21412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21413         ErroringMessageHandler_free(this_obj_conv);
21414 }
21415
21416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
21417         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
21418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21420         uint64_t ret_ref = (uint64_t)ret_var.inner;
21421         if (ret_var.is_owned) {
21422                 ret_ref |= 1;
21423         }
21424         return ret_ref;
21425 }
21426
21427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21428         LDKErroringMessageHandler this_arg_conv;
21429         this_arg_conv.inner = (void*)(this_arg & (~1));
21430         this_arg_conv.is_owned = false;
21431         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21432         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21433         return (uint64_t)ret;
21434 }
21435
21436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21437         LDKErroringMessageHandler this_arg_conv;
21438         this_arg_conv.inner = (void*)(this_arg & (~1));
21439         this_arg_conv.is_owned = false;
21440         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21441         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
21442         return (uint64_t)ret;
21443 }
21444
21445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21446         LDKMessageHandler this_obj_conv;
21447         this_obj_conv.inner = (void*)(this_obj & (~1));
21448         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21449         MessageHandler_free(this_obj_conv);
21450 }
21451
21452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21453         LDKMessageHandler this_ptr_conv;
21454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21455         this_ptr_conv.is_owned = false;
21456         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
21457         return ret_ret;
21458 }
21459
21460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21461         LDKMessageHandler this_ptr_conv;
21462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21463         this_ptr_conv.is_owned = false;
21464         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
21465         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
21466                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21467                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
21468         }
21469         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
21470 }
21471
21472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21473         LDKMessageHandler this_ptr_conv;
21474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21475         this_ptr_conv.is_owned = false;
21476         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
21477         return ret_ret;
21478 }
21479
21480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21481         LDKMessageHandler this_ptr_conv;
21482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21483         this_ptr_conv.is_owned = false;
21484         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
21485         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21486                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21487                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
21488         }
21489         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
21490 }
21491
21492 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) {
21493         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
21494         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
21495                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21496                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
21497         }
21498         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
21499         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21500                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21501                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
21502         }
21503         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
21504         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21505         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21506         uint64_t ret_ref = (uint64_t)ret_var.inner;
21507         if (ret_var.is_owned) {
21508                 ret_ref |= 1;
21509         }
21510         return ret_ref;
21511 }
21512
21513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21514         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
21515         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
21516         *ret = SocketDescriptor_clone(orig_conv);
21517         return (uint64_t)ret;
21518 }
21519
21520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21521         if ((this_ptr & 1) != 0) return;
21522         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
21523         FREE((void*)this_ptr);
21524         SocketDescriptor_free(this_ptr_conv);
21525 }
21526
21527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21528         LDKPeerHandleError this_obj_conv;
21529         this_obj_conv.inner = (void*)(this_obj & (~1));
21530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21531         PeerHandleError_free(this_obj_conv);
21532 }
21533
21534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
21535         LDKPeerHandleError this_ptr_conv;
21536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21537         this_ptr_conv.is_owned = false;
21538         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
21539         return ret_val;
21540 }
21541
21542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21543         LDKPeerHandleError this_ptr_conv;
21544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21545         this_ptr_conv.is_owned = false;
21546         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
21547 }
21548
21549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
21550         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
21551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21553         uint64_t ret_ref = (uint64_t)ret_var.inner;
21554         if (ret_var.is_owned) {
21555                 ret_ref |= 1;
21556         }
21557         return ret_ref;
21558 }
21559
21560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21561         LDKPeerHandleError orig_conv;
21562         orig_conv.inner = (void*)(orig & (~1));
21563         orig_conv.is_owned = false;
21564         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
21565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21567         uint64_t ret_ref = (uint64_t)ret_var.inner;
21568         if (ret_var.is_owned) {
21569                 ret_ref |= 1;
21570         }
21571         return ret_ref;
21572 }
21573
21574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21575         LDKPeerManager this_obj_conv;
21576         this_obj_conv.inner = (void*)(this_obj & (~1));
21577         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21578         PeerManager_free(this_obj_conv);
21579 }
21580
21581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger) {
21582         LDKMessageHandler message_handler_conv;
21583         message_handler_conv.inner = (void*)(message_handler & (~1));
21584         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
21585         // Warning: we need a move here but no clone is available for LDKMessageHandler
21586         LDKSecretKey our_node_secret_ref;
21587         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
21588         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
21589         unsigned char ephemeral_random_data_arr[32];
21590         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
21591         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
21592         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
21593         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21594         if (logger_conv.free == LDKLogger_JCalls_free) {
21595                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21596                 LDKLogger_JCalls_cloned(&logger_conv);
21597         }
21598         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
21599         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21600         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21601         uint64_t ret_ref = (uint64_t)ret_var.inner;
21602         if (ret_var.is_owned) {
21603                 ret_ref |= 1;
21604         }
21605         return ret_ref;
21606 }
21607
21608 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
21609         LDKPeerManager this_arg_conv;
21610         this_arg_conv.inner = (void*)(this_arg & (~1));
21611         this_arg_conv.is_owned = false;
21612         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
21613         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
21614         ;
21615         for (size_t i = 0; i < ret_var.datalen; i++) {
21616                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
21617                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
21618                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
21619         }
21620         FREE(ret_var.data);
21621         return ret_arr;
21622 }
21623
21624 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) {
21625         LDKPeerManager this_arg_conv;
21626         this_arg_conv.inner = (void*)(this_arg & (~1));
21627         this_arg_conv.is_owned = false;
21628         LDKPublicKey their_node_id_ref;
21629         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
21630         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
21631         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21632         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
21633                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21634                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
21635         }
21636         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21637         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
21638         return (uint64_t)ret_conv;
21639 }
21640
21641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21642         LDKPeerManager this_arg_conv;
21643         this_arg_conv.inner = (void*)(this_arg & (~1));
21644         this_arg_conv.is_owned = false;
21645         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21646         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
21647                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21648                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
21649         }
21650         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21651         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
21652         return (uint64_t)ret_conv;
21653 }
21654
21655 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) {
21656         LDKPeerManager this_arg_conv;
21657         this_arg_conv.inner = (void*)(this_arg & (~1));
21658         this_arg_conv.is_owned = false;
21659         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21660         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21661         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
21662         return (uint64_t)ret_conv;
21663 }
21664
21665 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) {
21666         LDKPeerManager this_arg_conv;
21667         this_arg_conv.inner = (void*)(this_arg & (~1));
21668         this_arg_conv.is_owned = false;
21669         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
21670         LDKu8slice data_ref;
21671         data_ref.datalen = (*env)->GetArrayLength(env, data);
21672         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
21673         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21674         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
21675         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
21676         return (uint64_t)ret_conv;
21677 }
21678
21679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
21680         LDKPeerManager this_arg_conv;
21681         this_arg_conv.inner = (void*)(this_arg & (~1));
21682         this_arg_conv.is_owned = false;
21683         PeerManager_process_events(&this_arg_conv);
21684 }
21685
21686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21687         LDKPeerManager this_arg_conv;
21688         this_arg_conv.inner = (void*)(this_arg & (~1));
21689         this_arg_conv.is_owned = false;
21690         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21691         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
21692 }
21693
21694 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) {
21695         LDKPeerManager this_arg_conv;
21696         this_arg_conv.inner = (void*)(this_arg & (~1));
21697         this_arg_conv.is_owned = false;
21698         LDKPublicKey node_id_ref;
21699         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21700         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21701         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
21702 }
21703
21704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
21705         LDKPeerManager this_arg_conv;
21706         this_arg_conv.inner = (void*)(this_arg & (~1));
21707         this_arg_conv.is_owned = false;
21708         PeerManager_timer_tick_occurred(&this_arg_conv);
21709 }
21710
21711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
21712         unsigned char commitment_seed_arr[32];
21713         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
21714         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
21715         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
21716         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
21718         return ret_arr;
21719 }
21720
21721 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) {
21722         LDKPublicKey per_commitment_point_ref;
21723         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21724         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21725         unsigned char base_secret_arr[32];
21726         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
21727         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
21728         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
21729         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21730         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
21731         return (uint64_t)ret_conv;
21732 }
21733
21734 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) {
21735         LDKPublicKey per_commitment_point_ref;
21736         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21737         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21738         LDKPublicKey base_point_ref;
21739         CHECK((*env)->GetArrayLength(env, base_point) == 33);
21740         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
21741         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21742         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
21743         return (uint64_t)ret_conv;
21744 }
21745
21746 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) {
21747         unsigned char per_commitment_secret_arr[32];
21748         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
21749         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
21750         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
21751         unsigned char countersignatory_revocation_base_secret_arr[32];
21752         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
21753         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
21754         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
21755         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21756         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
21757         return (uint64_t)ret_conv;
21758 }
21759
21760 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) {
21761         LDKPublicKey per_commitment_point_ref;
21762         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21763         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21764         LDKPublicKey countersignatory_revocation_base_point_ref;
21765         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
21766         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
21767         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21768         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
21769         return (uint64_t)ret_conv;
21770 }
21771
21772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21773         LDKTxCreationKeys this_obj_conv;
21774         this_obj_conv.inner = (void*)(this_obj & (~1));
21775         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21776         TxCreationKeys_free(this_obj_conv);
21777 }
21778
21779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21780         LDKTxCreationKeys this_ptr_conv;
21781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21782         this_ptr_conv.is_owned = false;
21783         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21784         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
21785         return ret_arr;
21786 }
21787
21788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21789         LDKTxCreationKeys this_ptr_conv;
21790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21791         this_ptr_conv.is_owned = false;
21792         LDKPublicKey val_ref;
21793         CHECK((*env)->GetArrayLength(env, val) == 33);
21794         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21795         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
21796 }
21797
21798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21799         LDKTxCreationKeys this_ptr_conv;
21800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21801         this_ptr_conv.is_owned = false;
21802         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21803         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
21804         return ret_arr;
21805 }
21806
21807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21808         LDKTxCreationKeys this_ptr_conv;
21809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21810         this_ptr_conv.is_owned = false;
21811         LDKPublicKey val_ref;
21812         CHECK((*env)->GetArrayLength(env, val) == 33);
21813         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21814         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21815 }
21816
21817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21818         LDKTxCreationKeys this_ptr_conv;
21819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21820         this_ptr_conv.is_owned = false;
21821         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21822         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
21823         return ret_arr;
21824 }
21825
21826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21827         LDKTxCreationKeys this_ptr_conv;
21828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21829         this_ptr_conv.is_owned = false;
21830         LDKPublicKey val_ref;
21831         CHECK((*env)->GetArrayLength(env, val) == 33);
21832         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21833         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21834 }
21835
21836 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21837         LDKTxCreationKeys this_ptr_conv;
21838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21839         this_ptr_conv.is_owned = false;
21840         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21841         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
21842         return ret_arr;
21843 }
21844
21845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21846         LDKTxCreationKeys this_ptr_conv;
21847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21848         this_ptr_conv.is_owned = false;
21849         LDKPublicKey val_ref;
21850         CHECK((*env)->GetArrayLength(env, val) == 33);
21851         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21852         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21853 }
21854
21855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21856         LDKTxCreationKeys this_ptr_conv;
21857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21858         this_ptr_conv.is_owned = false;
21859         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21860         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
21861         return ret_arr;
21862 }
21863
21864 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) {
21865         LDKTxCreationKeys this_ptr_conv;
21866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21867         this_ptr_conv.is_owned = false;
21868         LDKPublicKey val_ref;
21869         CHECK((*env)->GetArrayLength(env, val) == 33);
21870         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21871         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21872 }
21873
21874 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) {
21875         LDKPublicKey per_commitment_point_arg_ref;
21876         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
21877         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
21878         LDKPublicKey revocation_key_arg_ref;
21879         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
21880         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
21881         LDKPublicKey broadcaster_htlc_key_arg_ref;
21882         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
21883         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
21884         LDKPublicKey countersignatory_htlc_key_arg_ref;
21885         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
21886         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
21887         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21888         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
21889         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
21890         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);
21891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21893         uint64_t ret_ref = (uint64_t)ret_var.inner;
21894         if (ret_var.is_owned) {
21895                 ret_ref |= 1;
21896         }
21897         return ret_ref;
21898 }
21899
21900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21901         LDKTxCreationKeys orig_conv;
21902         orig_conv.inner = (void*)(orig & (~1));
21903         orig_conv.is_owned = false;
21904         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21905         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21906         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21907         uint64_t ret_ref = (uint64_t)ret_var.inner;
21908         if (ret_var.is_owned) {
21909                 ret_ref |= 1;
21910         }
21911         return ret_ref;
21912 }
21913
21914 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21915         LDKTxCreationKeys obj_conv;
21916         obj_conv.inner = (void*)(obj & (~1));
21917         obj_conv.is_owned = false;
21918         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21919         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21920         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21921         CVec_u8Z_free(ret_var);
21922         return ret_arr;
21923 }
21924
21925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21926         LDKu8slice ser_ref;
21927         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21928         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21929         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21930         *ret_conv = TxCreationKeys_read(ser_ref);
21931         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21932         return (uint64_t)ret_conv;
21933 }
21934
21935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21936         LDKChannelPublicKeys this_obj_conv;
21937         this_obj_conv.inner = (void*)(this_obj & (~1));
21938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21939         ChannelPublicKeys_free(this_obj_conv);
21940 }
21941
21942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21943         LDKChannelPublicKeys this_ptr_conv;
21944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21945         this_ptr_conv.is_owned = false;
21946         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
21948         return ret_arr;
21949 }
21950
21951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21952         LDKChannelPublicKeys this_ptr_conv;
21953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21954         this_ptr_conv.is_owned = false;
21955         LDKPublicKey val_ref;
21956         CHECK((*env)->GetArrayLength(env, val) == 33);
21957         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21958         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21959 }
21960
21961 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21962         LDKChannelPublicKeys this_ptr_conv;
21963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21964         this_ptr_conv.is_owned = false;
21965         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21966         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21967         return ret_arr;
21968 }
21969
21970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21971         LDKChannelPublicKeys this_ptr_conv;
21972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21973         this_ptr_conv.is_owned = false;
21974         LDKPublicKey val_ref;
21975         CHECK((*env)->GetArrayLength(env, val) == 33);
21976         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21977         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21978 }
21979
21980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21981         LDKChannelPublicKeys this_ptr_conv;
21982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21983         this_ptr_conv.is_owned = false;
21984         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21985         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
21986         return ret_arr;
21987 }
21988
21989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21990         LDKChannelPublicKeys this_ptr_conv;
21991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21992         this_ptr_conv.is_owned = false;
21993         LDKPublicKey val_ref;
21994         CHECK((*env)->GetArrayLength(env, val) == 33);
21995         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21996         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21997 }
21998
21999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22000         LDKChannelPublicKeys this_ptr_conv;
22001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22002         this_ptr_conv.is_owned = false;
22003         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22004         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
22005         return ret_arr;
22006 }
22007
22008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22009         LDKChannelPublicKeys this_ptr_conv;
22010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22011         this_ptr_conv.is_owned = false;
22012         LDKPublicKey val_ref;
22013         CHECK((*env)->GetArrayLength(env, val) == 33);
22014         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22015         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22016 }
22017
22018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22019         LDKChannelPublicKeys this_ptr_conv;
22020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22021         this_ptr_conv.is_owned = false;
22022         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22023         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
22024         return ret_arr;
22025 }
22026
22027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22028         LDKChannelPublicKeys this_ptr_conv;
22029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22030         this_ptr_conv.is_owned = false;
22031         LDKPublicKey val_ref;
22032         CHECK((*env)->GetArrayLength(env, val) == 33);
22033         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22034         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
22035 }
22036
22037 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) {
22038         LDKPublicKey funding_pubkey_arg_ref;
22039         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
22040         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
22041         LDKPublicKey revocation_basepoint_arg_ref;
22042         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
22043         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
22044         LDKPublicKey payment_point_arg_ref;
22045         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
22046         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
22047         LDKPublicKey delayed_payment_basepoint_arg_ref;
22048         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
22049         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
22050         LDKPublicKey htlc_basepoint_arg_ref;
22051         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
22052         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
22053         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);
22054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22056         uint64_t ret_ref = (uint64_t)ret_var.inner;
22057         if (ret_var.is_owned) {
22058                 ret_ref |= 1;
22059         }
22060         return ret_ref;
22061 }
22062
22063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22064         LDKChannelPublicKeys orig_conv;
22065         orig_conv.inner = (void*)(orig & (~1));
22066         orig_conv.is_owned = false;
22067         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
22068         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22069         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22070         uint64_t ret_ref = (uint64_t)ret_var.inner;
22071         if (ret_var.is_owned) {
22072                 ret_ref |= 1;
22073         }
22074         return ret_ref;
22075 }
22076
22077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
22078         LDKChannelPublicKeys obj_conv;
22079         obj_conv.inner = (void*)(obj & (~1));
22080         obj_conv.is_owned = false;
22081         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
22082         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22083         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22084         CVec_u8Z_free(ret_var);
22085         return ret_arr;
22086 }
22087
22088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22089         LDKu8slice ser_ref;
22090         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22091         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22092         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
22093         *ret_conv = ChannelPublicKeys_read(ser_ref);
22094         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22095         return (uint64_t)ret_conv;
22096 }
22097
22098 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) {
22099         LDKPublicKey per_commitment_point_ref;
22100         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22101         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22102         LDKPublicKey broadcaster_delayed_payment_base_ref;
22103         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
22104         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
22105         LDKPublicKey broadcaster_htlc_base_ref;
22106         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
22107         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
22108         LDKPublicKey countersignatory_revocation_base_ref;
22109         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
22110         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
22111         LDKPublicKey countersignatory_htlc_base_ref;
22112         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
22113         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
22114         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22115         *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);
22116         return (uint64_t)ret_conv;
22117 }
22118
22119 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) {
22120         LDKPublicKey per_commitment_point_ref;
22121         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22122         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22123         LDKChannelPublicKeys broadcaster_keys_conv;
22124         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22125         broadcaster_keys_conv.is_owned = false;
22126         LDKChannelPublicKeys countersignatory_keys_conv;
22127         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22128         countersignatory_keys_conv.is_owned = false;
22129         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22130         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
22131         return (uint64_t)ret_conv;
22132 }
22133
22134 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) {
22135         LDKPublicKey revocation_key_ref;
22136         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22137         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22138         LDKPublicKey broadcaster_delayed_payment_key_ref;
22139         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22140         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22141         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
22142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22144         CVec_u8Z_free(ret_var);
22145         return ret_arr;
22146 }
22147
22148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22149         LDKHTLCOutputInCommitment this_obj_conv;
22150         this_obj_conv.inner = (void*)(this_obj & (~1));
22151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22152         HTLCOutputInCommitment_free(this_obj_conv);
22153 }
22154
22155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
22156         LDKHTLCOutputInCommitment this_ptr_conv;
22157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22158         this_ptr_conv.is_owned = false;
22159         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
22160         return ret_val;
22161 }
22162
22163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22164         LDKHTLCOutputInCommitment this_ptr_conv;
22165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22166         this_ptr_conv.is_owned = false;
22167         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
22168 }
22169
22170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22171         LDKHTLCOutputInCommitment this_ptr_conv;
22172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22173         this_ptr_conv.is_owned = false;
22174         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
22175         return ret_val;
22176 }
22177
22178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22179         LDKHTLCOutputInCommitment this_ptr_conv;
22180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22181         this_ptr_conv.is_owned = false;
22182         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
22183 }
22184
22185 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
22186         LDKHTLCOutputInCommitment this_ptr_conv;
22187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22188         this_ptr_conv.is_owned = false;
22189         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
22190         return ret_val;
22191 }
22192
22193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22194         LDKHTLCOutputInCommitment this_ptr_conv;
22195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22196         this_ptr_conv.is_owned = false;
22197         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
22198 }
22199
22200 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22201         LDKHTLCOutputInCommitment this_ptr_conv;
22202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22203         this_ptr_conv.is_owned = false;
22204         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22205         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
22206         return ret_arr;
22207 }
22208
22209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22210         LDKHTLCOutputInCommitment this_ptr_conv;
22211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22212         this_ptr_conv.is_owned = false;
22213         LDKThirtyTwoBytes val_ref;
22214         CHECK((*env)->GetArrayLength(env, val) == 32);
22215         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22216         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
22217 }
22218
22219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
22220         LDKHTLCOutputInCommitment this_ptr_conv;
22221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22222         this_ptr_conv.is_owned = false;
22223         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
22224         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
22225         uint64_t ret_ref = (uint64_t)ret_copy;
22226         return ret_ref;
22227 }
22228
22229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22230         LDKHTLCOutputInCommitment this_ptr_conv;
22231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22232         this_ptr_conv.is_owned = false;
22233         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
22234         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
22235 }
22236
22237 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) {
22238         LDKThirtyTwoBytes payment_hash_arg_ref;
22239         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
22240         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
22241         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
22242         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
22243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22245         uint64_t ret_ref = (uint64_t)ret_var.inner;
22246         if (ret_var.is_owned) {
22247                 ret_ref |= 1;
22248         }
22249         return ret_ref;
22250 }
22251
22252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22253         LDKHTLCOutputInCommitment orig_conv;
22254         orig_conv.inner = (void*)(orig & (~1));
22255         orig_conv.is_owned = false;
22256         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
22257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22259         uint64_t ret_ref = (uint64_t)ret_var.inner;
22260         if (ret_var.is_owned) {
22261                 ret_ref |= 1;
22262         }
22263         return ret_ref;
22264 }
22265
22266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
22267         LDKHTLCOutputInCommitment obj_conv;
22268         obj_conv.inner = (void*)(obj & (~1));
22269         obj_conv.is_owned = false;
22270         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
22271         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22272         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22273         CVec_u8Z_free(ret_var);
22274         return ret_arr;
22275 }
22276
22277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22278         LDKu8slice ser_ref;
22279         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22280         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22281         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
22282         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
22283         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22284         return (uint64_t)ret_conv;
22285 }
22286
22287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
22288         LDKHTLCOutputInCommitment htlc_conv;
22289         htlc_conv.inner = (void*)(htlc & (~1));
22290         htlc_conv.is_owned = false;
22291         LDKTxCreationKeys keys_conv;
22292         keys_conv.inner = (void*)(keys & (~1));
22293         keys_conv.is_owned = false;
22294         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
22295         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22296         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22297         CVec_u8Z_free(ret_var);
22298         return ret_arr;
22299 }
22300
22301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
22302         LDKPublicKey broadcaster_ref;
22303         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
22304         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
22305         LDKPublicKey countersignatory_ref;
22306         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
22307         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
22308         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
22309         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22310         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22311         CVec_u8Z_free(ret_var);
22312         return ret_arr;
22313 }
22314
22315 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, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
22316         unsigned char commitment_txid_arr[32];
22317         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
22318         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
22319         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
22320         LDKHTLCOutputInCommitment htlc_conv;
22321         htlc_conv.inner = (void*)(htlc & (~1));
22322         htlc_conv.is_owned = false;
22323         LDKPublicKey broadcaster_delayed_payment_key_ref;
22324         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22325         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22326         LDKPublicKey revocation_key_ref;
22327         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22328         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22329         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
22330         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22331         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22332         Transaction_free(ret_var);
22333         return ret_arr;
22334 }
22335
22336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22337         LDKChannelTransactionParameters this_obj_conv;
22338         this_obj_conv.inner = (void*)(this_obj & (~1));
22339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22340         ChannelTransactionParameters_free(this_obj_conv);
22341 }
22342
22343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22344         LDKChannelTransactionParameters this_ptr_conv;
22345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22346         this_ptr_conv.is_owned = false;
22347         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
22348         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22349         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22350         uint64_t ret_ref = (uint64_t)ret_var.inner;
22351         if (ret_var.is_owned) {
22352                 ret_ref |= 1;
22353         }
22354         return ret_ref;
22355 }
22356
22357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22358         LDKChannelTransactionParameters this_ptr_conv;
22359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22360         this_ptr_conv.is_owned = false;
22361         LDKChannelPublicKeys val_conv;
22362         val_conv.inner = (void*)(val & (~1));
22363         val_conv.is_owned = (val & 1) || (val == 0);
22364         val_conv = ChannelPublicKeys_clone(&val_conv);
22365         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
22366 }
22367
22368 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22369         LDKChannelTransactionParameters this_ptr_conv;
22370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22371         this_ptr_conv.is_owned = false;
22372         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
22373         return ret_val;
22374 }
22375
22376 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) {
22377         LDKChannelTransactionParameters this_ptr_conv;
22378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22379         this_ptr_conv.is_owned = false;
22380         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
22381 }
22382
22383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
22384         LDKChannelTransactionParameters this_ptr_conv;
22385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22386         this_ptr_conv.is_owned = false;
22387         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
22388         return ret_val;
22389 }
22390
22391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22392         LDKChannelTransactionParameters this_ptr_conv;
22393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22394         this_ptr_conv.is_owned = false;
22395         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
22396 }
22397
22398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
22399         LDKChannelTransactionParameters this_ptr_conv;
22400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22401         this_ptr_conv.is_owned = false;
22402         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
22403         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22404         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22405         uint64_t ret_ref = (uint64_t)ret_var.inner;
22406         if (ret_var.is_owned) {
22407                 ret_ref |= 1;
22408         }
22409         return ret_ref;
22410 }
22411
22412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22413         LDKChannelTransactionParameters this_ptr_conv;
22414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22415         this_ptr_conv.is_owned = false;
22416         LDKCounterpartyChannelTransactionParameters val_conv;
22417         val_conv.inner = (void*)(val & (~1));
22418         val_conv.is_owned = (val & 1) || (val == 0);
22419         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
22420         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
22421 }
22422
22423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22424         LDKChannelTransactionParameters this_ptr_conv;
22425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22426         this_ptr_conv.is_owned = false;
22427         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
22428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22430         uint64_t ret_ref = (uint64_t)ret_var.inner;
22431         if (ret_var.is_owned) {
22432                 ret_ref |= 1;
22433         }
22434         return ret_ref;
22435 }
22436
22437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22438         LDKChannelTransactionParameters this_ptr_conv;
22439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22440         this_ptr_conv.is_owned = false;
22441         LDKOutPoint val_conv;
22442         val_conv.inner = (void*)(val & (~1));
22443         val_conv.is_owned = (val & 1) || (val == 0);
22444         val_conv = OutPoint_clone(&val_conv);
22445         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
22446 }
22447
22448 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) {
22449         LDKChannelPublicKeys holder_pubkeys_arg_conv;
22450         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
22451         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
22452         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
22453         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
22454         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
22455         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
22456         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
22457         LDKOutPoint funding_outpoint_arg_conv;
22458         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
22459         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
22460         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
22461         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);
22462         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22463         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22464         uint64_t ret_ref = (uint64_t)ret_var.inner;
22465         if (ret_var.is_owned) {
22466                 ret_ref |= 1;
22467         }
22468         return ret_ref;
22469 }
22470
22471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22472         LDKChannelTransactionParameters orig_conv;
22473         orig_conv.inner = (void*)(orig & (~1));
22474         orig_conv.is_owned = false;
22475         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
22476         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22477         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22478         uint64_t ret_ref = (uint64_t)ret_var.inner;
22479         if (ret_var.is_owned) {
22480                 ret_ref |= 1;
22481         }
22482         return ret_ref;
22483 }
22484
22485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22486         LDKCounterpartyChannelTransactionParameters this_obj_conv;
22487         this_obj_conv.inner = (void*)(this_obj & (~1));
22488         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22489         CounterpartyChannelTransactionParameters_free(this_obj_conv);
22490 }
22491
22492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22493         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22495         this_ptr_conv.is_owned = false;
22496         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
22497         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22498         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22499         uint64_t ret_ref = (uint64_t)ret_var.inner;
22500         if (ret_var.is_owned) {
22501                 ret_ref |= 1;
22502         }
22503         return ret_ref;
22504 }
22505
22506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22507         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22509         this_ptr_conv.is_owned = false;
22510         LDKChannelPublicKeys val_conv;
22511         val_conv.inner = (void*)(val & (~1));
22512         val_conv.is_owned = (val & 1) || (val == 0);
22513         val_conv = ChannelPublicKeys_clone(&val_conv);
22514         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
22515 }
22516
22517 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22518         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22520         this_ptr_conv.is_owned = false;
22521         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
22522         return ret_val;
22523 }
22524
22525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22526         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22528         this_ptr_conv.is_owned = false;
22529         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
22530 }
22531
22532 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) {
22533         LDKChannelPublicKeys pubkeys_arg_conv;
22534         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
22535         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
22536         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
22537         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
22538         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22539         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22540         uint64_t ret_ref = (uint64_t)ret_var.inner;
22541         if (ret_var.is_owned) {
22542                 ret_ref |= 1;
22543         }
22544         return ret_ref;
22545 }
22546
22547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22548         LDKCounterpartyChannelTransactionParameters orig_conv;
22549         orig_conv.inner = (void*)(orig & (~1));
22550         orig_conv.is_owned = false;
22551         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
22552         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22553         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22554         uint64_t ret_ref = (uint64_t)ret_var.inner;
22555         if (ret_var.is_owned) {
22556                 ret_ref |= 1;
22557         }
22558         return ret_ref;
22559 }
22560
22561 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
22562         LDKChannelTransactionParameters this_arg_conv;
22563         this_arg_conv.inner = (void*)(this_arg & (~1));
22564         this_arg_conv.is_owned = false;
22565         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
22566         return ret_val;
22567 }
22568
22569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
22570         LDKChannelTransactionParameters this_arg_conv;
22571         this_arg_conv.inner = (void*)(this_arg & (~1));
22572         this_arg_conv.is_owned = false;
22573         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
22574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22576         uint64_t ret_ref = (uint64_t)ret_var.inner;
22577         if (ret_var.is_owned) {
22578                 ret_ref |= 1;
22579         }
22580         return ret_ref;
22581 }
22582
22583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
22584         LDKChannelTransactionParameters this_arg_conv;
22585         this_arg_conv.inner = (void*)(this_arg & (~1));
22586         this_arg_conv.is_owned = false;
22587         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
22588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22590         uint64_t ret_ref = (uint64_t)ret_var.inner;
22591         if (ret_var.is_owned) {
22592                 ret_ref |= 1;
22593         }
22594         return ret_ref;
22595 }
22596
22597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
22598         LDKCounterpartyChannelTransactionParameters obj_conv;
22599         obj_conv.inner = (void*)(obj & (~1));
22600         obj_conv.is_owned = false;
22601         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
22602         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22603         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22604         CVec_u8Z_free(ret_var);
22605         return ret_arr;
22606 }
22607
22608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22609         LDKu8slice ser_ref;
22610         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22611         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22612         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
22613         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
22614         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22615         return (uint64_t)ret_conv;
22616 }
22617
22618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
22619         LDKChannelTransactionParameters obj_conv;
22620         obj_conv.inner = (void*)(obj & (~1));
22621         obj_conv.is_owned = false;
22622         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
22623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22625         CVec_u8Z_free(ret_var);
22626         return ret_arr;
22627 }
22628
22629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22630         LDKu8slice ser_ref;
22631         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22632         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22633         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
22634         *ret_conv = ChannelTransactionParameters_read(ser_ref);
22635         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22636         return (uint64_t)ret_conv;
22637 }
22638
22639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22640         LDKDirectedChannelTransactionParameters this_obj_conv;
22641         this_obj_conv.inner = (void*)(this_obj & (~1));
22642         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22643         DirectedChannelTransactionParameters_free(this_obj_conv);
22644 }
22645
22646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
22647         LDKDirectedChannelTransactionParameters this_arg_conv;
22648         this_arg_conv.inner = (void*)(this_arg & (~1));
22649         this_arg_conv.is_owned = false;
22650         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
22651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22653         uint64_t ret_ref = (uint64_t)ret_var.inner;
22654         if (ret_var.is_owned) {
22655                 ret_ref |= 1;
22656         }
22657         return ret_ref;
22658 }
22659
22660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
22661         LDKDirectedChannelTransactionParameters this_arg_conv;
22662         this_arg_conv.inner = (void*)(this_arg & (~1));
22663         this_arg_conv.is_owned = false;
22664         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
22665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22667         uint64_t ret_ref = (uint64_t)ret_var.inner;
22668         if (ret_var.is_owned) {
22669                 ret_ref |= 1;
22670         }
22671         return ret_ref;
22672 }
22673
22674 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
22675         LDKDirectedChannelTransactionParameters this_arg_conv;
22676         this_arg_conv.inner = (void*)(this_arg & (~1));
22677         this_arg_conv.is_owned = false;
22678         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
22679         return ret_val;
22680 }
22681
22682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
22683         LDKDirectedChannelTransactionParameters this_arg_conv;
22684         this_arg_conv.inner = (void*)(this_arg & (~1));
22685         this_arg_conv.is_owned = false;
22686         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
22687         return ret_val;
22688 }
22689
22690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
22691         LDKDirectedChannelTransactionParameters this_arg_conv;
22692         this_arg_conv.inner = (void*)(this_arg & (~1));
22693         this_arg_conv.is_owned = false;
22694         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
22695         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22696         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22697         uint64_t ret_ref = (uint64_t)ret_var.inner;
22698         if (ret_var.is_owned) {
22699                 ret_ref |= 1;
22700         }
22701         return ret_ref;
22702 }
22703
22704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22705         LDKHolderCommitmentTransaction this_obj_conv;
22706         this_obj_conv.inner = (void*)(this_obj & (~1));
22707         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22708         HolderCommitmentTransaction_free(this_obj_conv);
22709 }
22710
22711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
22712         LDKHolderCommitmentTransaction this_ptr_conv;
22713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22714         this_ptr_conv.is_owned = false;
22715         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22716         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
22717         return ret_arr;
22718 }
22719
22720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22721         LDKHolderCommitmentTransaction this_ptr_conv;
22722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22723         this_ptr_conv.is_owned = false;
22724         LDKSignature val_ref;
22725         CHECK((*env)->GetArrayLength(env, val) == 64);
22726         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22727         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
22728 }
22729
22730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
22731         LDKHolderCommitmentTransaction this_ptr_conv;
22732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22733         this_ptr_conv.is_owned = false;
22734         LDKCVec_SignatureZ val_constr;
22735         val_constr.datalen = (*env)->GetArrayLength(env, val);
22736         if (val_constr.datalen > 0)
22737                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22738         else
22739                 val_constr.data = NULL;
22740         for (size_t i = 0; i < val_constr.datalen; i++) {
22741                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
22742                 LDKSignature val_conv_8_ref;
22743                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
22744                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
22745                 val_constr.data[i] = val_conv_8_ref;
22746         }
22747         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
22748 }
22749
22750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22751         LDKHolderCommitmentTransaction orig_conv;
22752         orig_conv.inner = (void*)(orig & (~1));
22753         orig_conv.is_owned = false;
22754         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
22755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22757         uint64_t ret_ref = (uint64_t)ret_var.inner;
22758         if (ret_var.is_owned) {
22759                 ret_ref |= 1;
22760         }
22761         return ret_ref;
22762 }
22763
22764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22765         LDKHolderCommitmentTransaction obj_conv;
22766         obj_conv.inner = (void*)(obj & (~1));
22767         obj_conv.is_owned = false;
22768         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
22769         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22770         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22771         CVec_u8Z_free(ret_var);
22772         return ret_arr;
22773 }
22774
22775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22776         LDKu8slice ser_ref;
22777         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22778         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22779         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
22780         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
22781         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22782         return (uint64_t)ret_conv;
22783 }
22784
22785 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) {
22786         LDKCommitmentTransaction commitment_tx_conv;
22787         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
22788         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
22789         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
22790         LDKSignature counterparty_sig_ref;
22791         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
22792         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
22793         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
22794         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
22795         if (counterparty_htlc_sigs_constr.datalen > 0)
22796                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22797         else
22798                 counterparty_htlc_sigs_constr.data = NULL;
22799         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
22800                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
22801                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
22802                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
22803                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
22804                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
22805         }
22806         LDKPublicKey holder_funding_key_ref;
22807         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
22808         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
22809         LDKPublicKey counterparty_funding_key_ref;
22810         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
22811         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
22812         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22813         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22814         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22815         uint64_t ret_ref = (uint64_t)ret_var.inner;
22816         if (ret_var.is_owned) {
22817                 ret_ref |= 1;
22818         }
22819         return ret_ref;
22820 }
22821
22822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22823         LDKBuiltCommitmentTransaction this_obj_conv;
22824         this_obj_conv.inner = (void*)(this_obj & (~1));
22825         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22826         BuiltCommitmentTransaction_free(this_obj_conv);
22827 }
22828
22829 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
22830         LDKBuiltCommitmentTransaction this_ptr_conv;
22831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22832         this_ptr_conv.is_owned = false;
22833         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22834         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22835         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22836         Transaction_free(ret_var);
22837         return ret_arr;
22838 }
22839
22840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22841         LDKBuiltCommitmentTransaction this_ptr_conv;
22842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22843         this_ptr_conv.is_owned = false;
22844         LDKTransaction val_ref;
22845         val_ref.datalen = (*env)->GetArrayLength(env, val);
22846         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22847         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
22848         val_ref.data_is_owned = true;
22849         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22850 }
22851
22852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22853         LDKBuiltCommitmentTransaction this_ptr_conv;
22854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22855         this_ptr_conv.is_owned = false;
22856         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22857         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
22858         return ret_arr;
22859 }
22860
22861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22862         LDKBuiltCommitmentTransaction this_ptr_conv;
22863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22864         this_ptr_conv.is_owned = false;
22865         LDKThirtyTwoBytes val_ref;
22866         CHECK((*env)->GetArrayLength(env, val) == 32);
22867         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22868         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22869 }
22870
22871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
22872         LDKTransaction transaction_arg_ref;
22873         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
22874         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22875         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
22876         transaction_arg_ref.data_is_owned = true;
22877         LDKThirtyTwoBytes txid_arg_ref;
22878         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22879         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22880         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22881         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22882         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22883         uint64_t ret_ref = (uint64_t)ret_var.inner;
22884         if (ret_var.is_owned) {
22885                 ret_ref |= 1;
22886         }
22887         return ret_ref;
22888 }
22889
22890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22891         LDKBuiltCommitmentTransaction orig_conv;
22892         orig_conv.inner = (void*)(orig & (~1));
22893         orig_conv.is_owned = false;
22894         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22897         uint64_t ret_ref = (uint64_t)ret_var.inner;
22898         if (ret_var.is_owned) {
22899                 ret_ref |= 1;
22900         }
22901         return ret_ref;
22902 }
22903
22904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22905         LDKBuiltCommitmentTransaction obj_conv;
22906         obj_conv.inner = (void*)(obj & (~1));
22907         obj_conv.is_owned = false;
22908         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22909         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22910         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22911         CVec_u8Z_free(ret_var);
22912         return ret_arr;
22913 }
22914
22915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22916         LDKu8slice ser_ref;
22917         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22918         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22919         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22920         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22921         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22922         return (uint64_t)ret_conv;
22923 }
22924
22925 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) {
22926         LDKBuiltCommitmentTransaction this_arg_conv;
22927         this_arg_conv.inner = (void*)(this_arg & (~1));
22928         this_arg_conv.is_owned = false;
22929         LDKu8slice funding_redeemscript_ref;
22930         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22931         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22932         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22933         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
22934         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22935         return ret_arr;
22936 }
22937
22938 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) {
22939         LDKBuiltCommitmentTransaction this_arg_conv;
22940         this_arg_conv.inner = (void*)(this_arg & (~1));
22941         this_arg_conv.is_owned = false;
22942         unsigned char funding_key_arr[32];
22943         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
22944         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
22945         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22946         LDKu8slice funding_redeemscript_ref;
22947         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22948         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22949         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22950         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
22951         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22952         return ret_arr;
22953 }
22954
22955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22956         LDKCommitmentTransaction this_obj_conv;
22957         this_obj_conv.inner = (void*)(this_obj & (~1));
22958         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22959         CommitmentTransaction_free(this_obj_conv);
22960 }
22961
22962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22963         LDKCommitmentTransaction orig_conv;
22964         orig_conv.inner = (void*)(orig & (~1));
22965         orig_conv.is_owned = false;
22966         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22967         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22968         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22969         uint64_t ret_ref = (uint64_t)ret_var.inner;
22970         if (ret_var.is_owned) {
22971                 ret_ref |= 1;
22972         }
22973         return ret_ref;
22974 }
22975
22976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22977         LDKCommitmentTransaction obj_conv;
22978         obj_conv.inner = (void*)(obj & (~1));
22979         obj_conv.is_owned = false;
22980         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22981         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22982         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22983         CVec_u8Z_free(ret_var);
22984         return ret_arr;
22985 }
22986
22987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22988         LDKu8slice ser_ref;
22989         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22990         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22991         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22992         *ret_conv = CommitmentTransaction_read(ser_ref);
22993         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22994         return (uint64_t)ret_conv;
22995 }
22996
22997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
22998         LDKCommitmentTransaction this_arg_conv;
22999         this_arg_conv.inner = (void*)(this_arg & (~1));
23000         this_arg_conv.is_owned = false;
23001         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
23002         return ret_val;
23003 }
23004
23005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23006         LDKCommitmentTransaction this_arg_conv;
23007         this_arg_conv.inner = (void*)(this_arg & (~1));
23008         this_arg_conv.is_owned = false;
23009         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
23010         return ret_val;
23011 }
23012
23013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23014         LDKCommitmentTransaction this_arg_conv;
23015         this_arg_conv.inner = (void*)(this_arg & (~1));
23016         this_arg_conv.is_owned = false;
23017         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
23018         return ret_val;
23019 }
23020
23021 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
23022         LDKCommitmentTransaction this_arg_conv;
23023         this_arg_conv.inner = (void*)(this_arg & (~1));
23024         this_arg_conv.is_owned = false;
23025         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
23026         return ret_val;
23027 }
23028
23029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
23030         LDKCommitmentTransaction this_arg_conv;
23031         this_arg_conv.inner = (void*)(this_arg & (~1));
23032         this_arg_conv.is_owned = false;
23033         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
23034         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23035         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23036         uint64_t ret_ref = (uint64_t)ret_var.inner;
23037         if (ret_var.is_owned) {
23038                 ret_ref |= 1;
23039         }
23040         return ret_ref;
23041 }
23042
23043 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) {
23044         LDKCommitmentTransaction this_arg_conv;
23045         this_arg_conv.inner = (void*)(this_arg & (~1));
23046         this_arg_conv.is_owned = false;
23047         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23048         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23049         channel_parameters_conv.is_owned = false;
23050         LDKChannelPublicKeys broadcaster_keys_conv;
23051         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
23052         broadcaster_keys_conv.is_owned = false;
23053         LDKChannelPublicKeys countersignatory_keys_conv;
23054         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
23055         countersignatory_keys_conv.is_owned = false;
23056         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
23057         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
23058         return (uint64_t)ret_conv;
23059 }
23060
23061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23062         LDKTrustedCommitmentTransaction this_obj_conv;
23063         this_obj_conv.inner = (void*)(this_obj & (~1));
23064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23065         TrustedCommitmentTransaction_free(this_obj_conv);
23066 }
23067
23068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
23069         LDKTrustedCommitmentTransaction this_arg_conv;
23070         this_arg_conv.inner = (void*)(this_arg & (~1));
23071         this_arg_conv.is_owned = false;
23072         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23073         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
23074         return ret_arr;
23075 }
23076
23077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
23078         LDKTrustedCommitmentTransaction this_arg_conv;
23079         this_arg_conv.inner = (void*)(this_arg & (~1));
23080         this_arg_conv.is_owned = false;
23081         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
23082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23084         uint64_t ret_ref = (uint64_t)ret_var.inner;
23085         if (ret_var.is_owned) {
23086                 ret_ref |= 1;
23087         }
23088         return ret_ref;
23089 }
23090
23091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
23092         LDKTrustedCommitmentTransaction this_arg_conv;
23093         this_arg_conv.inner = (void*)(this_arg & (~1));
23094         this_arg_conv.is_owned = false;
23095         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
23096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23098         uint64_t ret_ref = (uint64_t)ret_var.inner;
23099         if (ret_var.is_owned) {
23100                 ret_ref |= 1;
23101         }
23102         return ret_ref;
23103 }
23104
23105 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) {
23106         LDKTrustedCommitmentTransaction this_arg_conv;
23107         this_arg_conv.inner = (void*)(this_arg & (~1));
23108         this_arg_conv.is_owned = false;
23109         unsigned char htlc_base_key_arr[32];
23110         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
23111         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
23112         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
23113         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23114         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23115         channel_parameters_conv.is_owned = false;
23116         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
23117         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
23118         return (uint64_t)ret_conv;
23119 }
23120
23121 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) {
23122         LDKPublicKey broadcaster_payment_basepoint_ref;
23123         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
23124         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
23125         LDKPublicKey countersignatory_payment_basepoint_ref;
23126         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
23127         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
23128         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
23129         return ret_val;
23130 }
23131
23132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23133         LDKInitFeatures a_conv;
23134         a_conv.inner = (void*)(a & (~1));
23135         a_conv.is_owned = false;
23136         LDKInitFeatures b_conv;
23137         b_conv.inner = (void*)(b & (~1));
23138         b_conv.is_owned = false;
23139         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
23140         return ret_val;
23141 }
23142
23143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23144         LDKNodeFeatures a_conv;
23145         a_conv.inner = (void*)(a & (~1));
23146         a_conv.is_owned = false;
23147         LDKNodeFeatures b_conv;
23148         b_conv.inner = (void*)(b & (~1));
23149         b_conv.is_owned = false;
23150         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
23151         return ret_val;
23152 }
23153
23154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23155         LDKChannelFeatures a_conv;
23156         a_conv.inner = (void*)(a & (~1));
23157         a_conv.is_owned = false;
23158         LDKChannelFeatures b_conv;
23159         b_conv.inner = (void*)(b & (~1));
23160         b_conv.is_owned = false;
23161         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
23162         return ret_val;
23163 }
23164
23165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23166         LDKInvoiceFeatures a_conv;
23167         a_conv.inner = (void*)(a & (~1));
23168         a_conv.is_owned = false;
23169         LDKInvoiceFeatures b_conv;
23170         b_conv.inner = (void*)(b & (~1));
23171         b_conv.is_owned = false;
23172         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
23173         return ret_val;
23174 }
23175
23176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23177         LDKInitFeatures orig_conv;
23178         orig_conv.inner = (void*)(orig & (~1));
23179         orig_conv.is_owned = false;
23180         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
23181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23182         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23183         uint64_t ret_ref = (uint64_t)ret_var.inner;
23184         if (ret_var.is_owned) {
23185                 ret_ref |= 1;
23186         }
23187         return ret_ref;
23188 }
23189
23190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23191         LDKNodeFeatures orig_conv;
23192         orig_conv.inner = (void*)(orig & (~1));
23193         orig_conv.is_owned = false;
23194         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
23195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23197         uint64_t ret_ref = (uint64_t)ret_var.inner;
23198         if (ret_var.is_owned) {
23199                 ret_ref |= 1;
23200         }
23201         return ret_ref;
23202 }
23203
23204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23205         LDKChannelFeatures orig_conv;
23206         orig_conv.inner = (void*)(orig & (~1));
23207         orig_conv.is_owned = false;
23208         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
23209         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23210         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23211         uint64_t ret_ref = (uint64_t)ret_var.inner;
23212         if (ret_var.is_owned) {
23213                 ret_ref |= 1;
23214         }
23215         return ret_ref;
23216 }
23217
23218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23219         LDKInvoiceFeatures orig_conv;
23220         orig_conv.inner = (void*)(orig & (~1));
23221         orig_conv.is_owned = false;
23222         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
23223         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23224         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23225         uint64_t ret_ref = (uint64_t)ret_var.inner;
23226         if (ret_var.is_owned) {
23227                 ret_ref |= 1;
23228         }
23229         return ret_ref;
23230 }
23231
23232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23233         LDKInitFeatures this_obj_conv;
23234         this_obj_conv.inner = (void*)(this_obj & (~1));
23235         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23236         InitFeatures_free(this_obj_conv);
23237 }
23238
23239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23240         LDKNodeFeatures this_obj_conv;
23241         this_obj_conv.inner = (void*)(this_obj & (~1));
23242         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23243         NodeFeatures_free(this_obj_conv);
23244 }
23245
23246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23247         LDKChannelFeatures this_obj_conv;
23248         this_obj_conv.inner = (void*)(this_obj & (~1));
23249         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23250         ChannelFeatures_free(this_obj_conv);
23251 }
23252
23253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23254         LDKInvoiceFeatures this_obj_conv;
23255         this_obj_conv.inner = (void*)(this_obj & (~1));
23256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23257         InvoiceFeatures_free(this_obj_conv);
23258 }
23259
23260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
23261         LDKInitFeatures ret_var = InitFeatures_empty();
23262         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23263         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23264         uint64_t ret_ref = (uint64_t)ret_var.inner;
23265         if (ret_var.is_owned) {
23266                 ret_ref |= 1;
23267         }
23268         return ret_ref;
23269 }
23270
23271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
23272         LDKInitFeatures ret_var = InitFeatures_known();
23273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23275         uint64_t ret_ref = (uint64_t)ret_var.inner;
23276         if (ret_var.is_owned) {
23277                 ret_ref |= 1;
23278         }
23279         return ret_ref;
23280 }
23281
23282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
23283         LDKNodeFeatures ret_var = NodeFeatures_empty();
23284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23286         uint64_t ret_ref = (uint64_t)ret_var.inner;
23287         if (ret_var.is_owned) {
23288                 ret_ref |= 1;
23289         }
23290         return ret_ref;
23291 }
23292
23293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
23294         LDKNodeFeatures ret_var = NodeFeatures_known();
23295         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23296         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23297         uint64_t ret_ref = (uint64_t)ret_var.inner;
23298         if (ret_var.is_owned) {
23299                 ret_ref |= 1;
23300         }
23301         return ret_ref;
23302 }
23303
23304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
23305         LDKChannelFeatures ret_var = ChannelFeatures_empty();
23306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23308         uint64_t ret_ref = (uint64_t)ret_var.inner;
23309         if (ret_var.is_owned) {
23310                 ret_ref |= 1;
23311         }
23312         return ret_ref;
23313 }
23314
23315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
23316         LDKChannelFeatures ret_var = ChannelFeatures_known();
23317         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23318         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23319         uint64_t ret_ref = (uint64_t)ret_var.inner;
23320         if (ret_var.is_owned) {
23321                 ret_ref |= 1;
23322         }
23323         return ret_ref;
23324 }
23325
23326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
23327         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
23328         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23329         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23330         uint64_t ret_ref = (uint64_t)ret_var.inner;
23331         if (ret_var.is_owned) {
23332                 ret_ref |= 1;
23333         }
23334         return ret_ref;
23335 }
23336
23337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
23338         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
23339         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23340         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23341         uint64_t ret_ref = (uint64_t)ret_var.inner;
23342         if (ret_var.is_owned) {
23343                 ret_ref |= 1;
23344         }
23345         return ret_ref;
23346 }
23347
23348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23349         LDKInitFeatures this_arg_conv;
23350         this_arg_conv.inner = (void*)(this_arg & (~1));
23351         this_arg_conv.is_owned = false;
23352         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
23353         return ret_val;
23354 }
23355
23356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23357         LDKNodeFeatures this_arg_conv;
23358         this_arg_conv.inner = (void*)(this_arg & (~1));
23359         this_arg_conv.is_owned = false;
23360         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
23361         return ret_val;
23362 }
23363
23364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23365         LDKInvoiceFeatures this_arg_conv;
23366         this_arg_conv.inner = (void*)(this_arg & (~1));
23367         this_arg_conv.is_owned = false;
23368         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
23369         return ret_val;
23370 }
23371
23372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23373         LDKInitFeatures obj_conv;
23374         obj_conv.inner = (void*)(obj & (~1));
23375         obj_conv.is_owned = false;
23376         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
23377         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23378         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23379         CVec_u8Z_free(ret_var);
23380         return ret_arr;
23381 }
23382
23383 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23384         LDKNodeFeatures obj_conv;
23385         obj_conv.inner = (void*)(obj & (~1));
23386         obj_conv.is_owned = false;
23387         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
23388         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23389         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23390         CVec_u8Z_free(ret_var);
23391         return ret_arr;
23392 }
23393
23394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23395         LDKChannelFeatures obj_conv;
23396         obj_conv.inner = (void*)(obj & (~1));
23397         obj_conv.is_owned = false;
23398         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
23399         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23400         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23401         CVec_u8Z_free(ret_var);
23402         return ret_arr;
23403 }
23404
23405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23406         LDKInvoiceFeatures obj_conv;
23407         obj_conv.inner = (void*)(obj & (~1));
23408         obj_conv.is_owned = false;
23409         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
23410         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23411         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23412         CVec_u8Z_free(ret_var);
23413         return ret_arr;
23414 }
23415
23416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23417         LDKu8slice ser_ref;
23418         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23419         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23420         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
23421         *ret_conv = InitFeatures_read(ser_ref);
23422         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23423         return (uint64_t)ret_conv;
23424 }
23425
23426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23427         LDKu8slice ser_ref;
23428         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23429         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23430         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
23431         *ret_conv = NodeFeatures_read(ser_ref);
23432         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23433         return (uint64_t)ret_conv;
23434 }
23435
23436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23437         LDKu8slice ser_ref;
23438         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23439         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23440         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
23441         *ret_conv = ChannelFeatures_read(ser_ref);
23442         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23443         return (uint64_t)ret_conv;
23444 }
23445
23446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23447         LDKu8slice ser_ref;
23448         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23449         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23450         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
23451         *ret_conv = InvoiceFeatures_read(ser_ref);
23452         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23453         return (uint64_t)ret_conv;
23454 }
23455
23456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23457         LDKRouteHop this_obj_conv;
23458         this_obj_conv.inner = (void*)(this_obj & (~1));
23459         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23460         RouteHop_free(this_obj_conv);
23461 }
23462
23463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23464         LDKRouteHop this_ptr_conv;
23465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23466         this_ptr_conv.is_owned = false;
23467         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23468         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
23469         return ret_arr;
23470 }
23471
23472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23473         LDKRouteHop this_ptr_conv;
23474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23475         this_ptr_conv.is_owned = false;
23476         LDKPublicKey val_ref;
23477         CHECK((*env)->GetArrayLength(env, val) == 33);
23478         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23479         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
23480 }
23481
23482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23483         LDKRouteHop this_ptr_conv;
23484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23485         this_ptr_conv.is_owned = false;
23486         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
23487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23489         uint64_t ret_ref = (uint64_t)ret_var.inner;
23490         if (ret_var.is_owned) {
23491                 ret_ref |= 1;
23492         }
23493         return ret_ref;
23494 }
23495
23496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23497         LDKRouteHop this_ptr_conv;
23498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23499         this_ptr_conv.is_owned = false;
23500         LDKNodeFeatures val_conv;
23501         val_conv.inner = (void*)(val & (~1));
23502         val_conv.is_owned = (val & 1) || (val == 0);
23503         val_conv = NodeFeatures_clone(&val_conv);
23504         RouteHop_set_node_features(&this_ptr_conv, val_conv);
23505 }
23506
23507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23508         LDKRouteHop this_ptr_conv;
23509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23510         this_ptr_conv.is_owned = false;
23511         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
23512         return ret_val;
23513 }
23514
23515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23516         LDKRouteHop this_ptr_conv;
23517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23518         this_ptr_conv.is_owned = false;
23519         RouteHop_set_short_channel_id(&this_ptr_conv, val);
23520 }
23521
23522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23523         LDKRouteHop this_ptr_conv;
23524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23525         this_ptr_conv.is_owned = false;
23526         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
23527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23529         uint64_t ret_ref = (uint64_t)ret_var.inner;
23530         if (ret_var.is_owned) {
23531                 ret_ref |= 1;
23532         }
23533         return ret_ref;
23534 }
23535
23536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23537         LDKRouteHop this_ptr_conv;
23538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23539         this_ptr_conv.is_owned = false;
23540         LDKChannelFeatures val_conv;
23541         val_conv.inner = (void*)(val & (~1));
23542         val_conv.is_owned = (val & 1) || (val == 0);
23543         val_conv = ChannelFeatures_clone(&val_conv);
23544         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
23545 }
23546
23547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23548         LDKRouteHop this_ptr_conv;
23549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23550         this_ptr_conv.is_owned = false;
23551         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
23552         return ret_val;
23553 }
23554
23555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23556         LDKRouteHop this_ptr_conv;
23557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23558         this_ptr_conv.is_owned = false;
23559         RouteHop_set_fee_msat(&this_ptr_conv, val);
23560 }
23561
23562 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23563         LDKRouteHop this_ptr_conv;
23564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23565         this_ptr_conv.is_owned = false;
23566         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
23567         return ret_val;
23568 }
23569
23570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23571         LDKRouteHop this_ptr_conv;
23572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23573         this_ptr_conv.is_owned = false;
23574         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23575 }
23576
23577 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) {
23578         LDKPublicKey pubkey_arg_ref;
23579         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
23580         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
23581         LDKNodeFeatures node_features_arg_conv;
23582         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
23583         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
23584         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
23585         LDKChannelFeatures channel_features_arg_conv;
23586         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
23587         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
23588         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
23589         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);
23590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23592         uint64_t ret_ref = (uint64_t)ret_var.inner;
23593         if (ret_var.is_owned) {
23594                 ret_ref |= 1;
23595         }
23596         return ret_ref;
23597 }
23598
23599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23600         LDKRouteHop orig_conv;
23601         orig_conv.inner = (void*)(orig & (~1));
23602         orig_conv.is_owned = false;
23603         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
23604         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23605         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23606         uint64_t ret_ref = (uint64_t)ret_var.inner;
23607         if (ret_var.is_owned) {
23608                 ret_ref |= 1;
23609         }
23610         return ret_ref;
23611 }
23612
23613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
23614         LDKRouteHop obj_conv;
23615         obj_conv.inner = (void*)(obj & (~1));
23616         obj_conv.is_owned = false;
23617         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
23618         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23619         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23620         CVec_u8Z_free(ret_var);
23621         return ret_arr;
23622 }
23623
23624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23625         LDKu8slice ser_ref;
23626         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23627         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23628         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
23629         *ret_conv = RouteHop_read(ser_ref);
23630         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23631         return (uint64_t)ret_conv;
23632 }
23633
23634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23635         LDKRoute this_obj_conv;
23636         this_obj_conv.inner = (void*)(this_obj & (~1));
23637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23638         Route_free(this_obj_conv);
23639 }
23640
23641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23642         LDKRoute this_ptr_conv;
23643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23644         this_ptr_conv.is_owned = false;
23645         LDKCVec_CVec_RouteHopZZ val_constr;
23646         val_constr.datalen = (*env)->GetArrayLength(env, val);
23647         if (val_constr.datalen > 0)
23648                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23649         else
23650                 val_constr.data = NULL;
23651         for (size_t m = 0; m < val_constr.datalen; m++) {
23652                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
23653                 LDKCVec_RouteHopZ val_conv_12_constr;
23654                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
23655                 if (val_conv_12_constr.datalen > 0)
23656                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23657                 else
23658                         val_conv_12_constr.data = NULL;
23659                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
23660                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
23661                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
23662                         LDKRouteHop val_conv_12_conv_10_conv;
23663                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
23664                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
23665                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
23666                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
23667                 }
23668                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
23669                 val_constr.data[m] = val_conv_12_constr;
23670         }
23671         Route_set_paths(&this_ptr_conv, val_constr);
23672 }
23673
23674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
23675         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
23676         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
23677         if (paths_arg_constr.datalen > 0)
23678                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23679         else
23680                 paths_arg_constr.data = NULL;
23681         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
23682                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
23683                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
23684                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
23685                 if (paths_arg_conv_12_constr.datalen > 0)
23686                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23687                 else
23688                         paths_arg_conv_12_constr.data = NULL;
23689                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
23690                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
23691                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
23692                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
23693                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
23694                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
23695                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
23696                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
23697                 }
23698                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
23699                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
23700         }
23701         LDKRoute ret_var = Route_new(paths_arg_constr);
23702         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23703         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23704         uint64_t ret_ref = (uint64_t)ret_var.inner;
23705         if (ret_var.is_owned) {
23706                 ret_ref |= 1;
23707         }
23708         return ret_ref;
23709 }
23710
23711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23712         LDKRoute orig_conv;
23713         orig_conv.inner = (void*)(orig & (~1));
23714         orig_conv.is_owned = false;
23715         LDKRoute ret_var = Route_clone(&orig_conv);
23716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23718         uint64_t ret_ref = (uint64_t)ret_var.inner;
23719         if (ret_var.is_owned) {
23720                 ret_ref |= 1;
23721         }
23722         return ret_ref;
23723 }
23724
23725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
23726         LDKRoute obj_conv;
23727         obj_conv.inner = (void*)(obj & (~1));
23728         obj_conv.is_owned = false;
23729         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
23730         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23731         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23732         CVec_u8Z_free(ret_var);
23733         return ret_arr;
23734 }
23735
23736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23737         LDKu8slice ser_ref;
23738         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23739         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23740         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
23741         *ret_conv = Route_read(ser_ref);
23742         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23743         return (uint64_t)ret_conv;
23744 }
23745
23746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23747         LDKRouteHint this_obj_conv;
23748         this_obj_conv.inner = (void*)(this_obj & (~1));
23749         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23750         RouteHint_free(this_obj_conv);
23751 }
23752
23753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23754         LDKRouteHint a_conv;
23755         a_conv.inner = (void*)(a & (~1));
23756         a_conv.is_owned = false;
23757         LDKRouteHint b_conv;
23758         b_conv.inner = (void*)(b & (~1));
23759         b_conv.is_owned = false;
23760         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
23761         return ret_val;
23762 }
23763
23764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23765         LDKRouteHint orig_conv;
23766         orig_conv.inner = (void*)(orig & (~1));
23767         orig_conv.is_owned = false;
23768         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
23769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23771         uint64_t ret_ref = (uint64_t)ret_var.inner;
23772         if (ret_var.is_owned) {
23773                 ret_ref |= 1;
23774         }
23775         return ret_ref;
23776 }
23777
23778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23779         LDKRouteHintHop this_obj_conv;
23780         this_obj_conv.inner = (void*)(this_obj & (~1));
23781         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23782         RouteHintHop_free(this_obj_conv);
23783 }
23784
23785 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23786         LDKRouteHintHop this_ptr_conv;
23787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23788         this_ptr_conv.is_owned = false;
23789         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
23791         return ret_arr;
23792 }
23793
23794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23795         LDKRouteHintHop this_ptr_conv;
23796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23797         this_ptr_conv.is_owned = false;
23798         LDKPublicKey val_ref;
23799         CHECK((*env)->GetArrayLength(env, val) == 33);
23800         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23801         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
23802 }
23803
23804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23805         LDKRouteHintHop this_ptr_conv;
23806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23807         this_ptr_conv.is_owned = false;
23808         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
23809         return ret_val;
23810 }
23811
23812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23813         LDKRouteHintHop this_ptr_conv;
23814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23815         this_ptr_conv.is_owned = false;
23816         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23817 }
23818
23819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23820         LDKRouteHintHop this_ptr_conv;
23821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23822         this_ptr_conv.is_owned = false;
23823         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23824         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23825         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23826         uint64_t ret_ref = (uint64_t)ret_var.inner;
23827         if (ret_var.is_owned) {
23828                 ret_ref |= 1;
23829         }
23830         return ret_ref;
23831 }
23832
23833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23834         LDKRouteHintHop this_ptr_conv;
23835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23836         this_ptr_conv.is_owned = false;
23837         LDKRoutingFees val_conv;
23838         val_conv.inner = (void*)(val & (~1));
23839         val_conv.is_owned = (val & 1) || (val == 0);
23840         val_conv = RoutingFees_clone(&val_conv);
23841         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23842 }
23843
23844 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23845         LDKRouteHintHop this_ptr_conv;
23846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23847         this_ptr_conv.is_owned = false;
23848         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23849         return ret_val;
23850 }
23851
23852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23853         LDKRouteHintHop this_ptr_conv;
23854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23855         this_ptr_conv.is_owned = false;
23856         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23857 }
23858
23859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23860         LDKRouteHintHop this_ptr_conv;
23861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23862         this_ptr_conv.is_owned = false;
23863         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23864         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23865         uint64_t ret_ref = (uint64_t)ret_copy;
23866         return ret_ref;
23867 }
23868
23869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23870         LDKRouteHintHop this_ptr_conv;
23871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23872         this_ptr_conv.is_owned = false;
23873         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23874         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23875 }
23876
23877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23878         LDKRouteHintHop this_ptr_conv;
23879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23880         this_ptr_conv.is_owned = false;
23881         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23882         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23883         uint64_t ret_ref = (uint64_t)ret_copy;
23884         return ret_ref;
23885 }
23886
23887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23888         LDKRouteHintHop this_ptr_conv;
23889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23890         this_ptr_conv.is_owned = false;
23891         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23892         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23893 }
23894
23895 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) {
23896         LDKPublicKey src_node_id_arg_ref;
23897         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
23898         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
23899         LDKRoutingFees fees_arg_conv;
23900         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23901         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23902         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23903         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23904         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23905         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);
23906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23908         uint64_t ret_ref = (uint64_t)ret_var.inner;
23909         if (ret_var.is_owned) {
23910                 ret_ref |= 1;
23911         }
23912         return ret_ref;
23913 }
23914
23915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23916         LDKRouteHintHop a_conv;
23917         a_conv.inner = (void*)(a & (~1));
23918         a_conv.is_owned = false;
23919         LDKRouteHintHop b_conv;
23920         b_conv.inner = (void*)(b & (~1));
23921         b_conv.is_owned = false;
23922         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23923         return ret_val;
23924 }
23925
23926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23927         LDKRouteHintHop orig_conv;
23928         orig_conv.inner = (void*)(orig & (~1));
23929         orig_conv.is_owned = false;
23930         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23933         uint64_t ret_ref = (uint64_t)ret_var.inner;
23934         if (ret_var.is_owned) {
23935                 ret_ref |= 1;
23936         }
23937         return ret_ref;
23938 }
23939
23940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
23941         LDKPublicKey our_node_id_ref;
23942         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23943         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23944         LDKNetworkGraph network_conv;
23945         network_conv.inner = (void*)(network & (~1));
23946         network_conv.is_owned = false;
23947         LDKPublicKey payee_ref;
23948         CHECK((*env)->GetArrayLength(env, payee) == 33);
23949         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
23950         LDKCVec_ChannelDetailsZ first_hops_constr;
23951         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
23952         if (first_hops_constr.datalen > 0)
23953                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23954         else
23955                 first_hops_constr.data = NULL;
23956         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
23957         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23958                 int64_t first_hops_conv_16 = first_hops_vals[q];
23959                 LDKChannelDetails first_hops_conv_16_conv;
23960                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23961                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23962                 first_hops_constr.data[q] = first_hops_conv_16_conv;
23963         }
23964         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
23965         LDKCVec_RouteHintZ last_hops_constr;
23966         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
23967         if (last_hops_constr.datalen > 0)
23968                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23969         else
23970                 last_hops_constr.data = NULL;
23971         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
23972         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23973                 int64_t last_hops_conv_11 = last_hops_vals[l];
23974                 LDKRouteHint last_hops_conv_11_conv;
23975                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23976                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23977                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23978                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23979         }
23980         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
23981         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23982         if (logger_conv.free == LDKLogger_JCalls_free) {
23983                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23984                 LDKLogger_JCalls_cloned(&logger_conv);
23985         }
23986         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23987         *ret_conv = get_keysend_route(our_node_id_ref, &network_conv, payee_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
23988         FREE(first_hops_constr.data);
23989         return (uint64_t)ret_conv;
23990 }
23991
23992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_t payee_features, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
23993         LDKPublicKey our_node_id_ref;
23994         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23995         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23996         LDKNetworkGraph network_conv;
23997         network_conv.inner = (void*)(network & (~1));
23998         network_conv.is_owned = false;
23999         LDKPublicKey payee_ref;
24000         CHECK((*env)->GetArrayLength(env, payee) == 33);
24001         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
24002         LDKInvoiceFeatures payee_features_conv;
24003         payee_features_conv.inner = (void*)(payee_features & (~1));
24004         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
24005         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
24006         LDKCVec_ChannelDetailsZ first_hops_constr;
24007         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
24008         if (first_hops_constr.datalen > 0)
24009                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24010         else
24011                 first_hops_constr.data = NULL;
24012         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
24013         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
24014                 int64_t first_hops_conv_16 = first_hops_vals[q];
24015                 LDKChannelDetails first_hops_conv_16_conv;
24016                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
24017                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
24018                 first_hops_constr.data[q] = first_hops_conv_16_conv;
24019         }
24020         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
24021         LDKCVec_RouteHintZ last_hops_constr;
24022         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
24023         if (last_hops_constr.datalen > 0)
24024                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
24025         else
24026                 last_hops_constr.data = NULL;
24027         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
24028         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
24029                 int64_t last_hops_conv_11 = last_hops_vals[l];
24030                 LDKRouteHint last_hops_conv_11_conv;
24031                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
24032                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
24033                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
24034                 last_hops_constr.data[l] = last_hops_conv_11_conv;
24035         }
24036         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
24037         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24038         if (logger_conv.free == LDKLogger_JCalls_free) {
24039                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24040                 LDKLogger_JCalls_cloned(&logger_conv);
24041         }
24042         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
24043         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
24044         FREE(first_hops_constr.data);
24045         return (uint64_t)ret_conv;
24046 }
24047
24048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24049         LDKNetworkGraph this_obj_conv;
24050         this_obj_conv.inner = (void*)(this_obj & (~1));
24051         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24052         NetworkGraph_free(this_obj_conv);
24053 }
24054
24055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24056         LDKNetworkGraph orig_conv;
24057         orig_conv.inner = (void*)(orig & (~1));
24058         orig_conv.is_owned = false;
24059         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
24060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24062         uint64_t ret_ref = (uint64_t)ret_var.inner;
24063         if (ret_var.is_owned) {
24064                 ret_ref |= 1;
24065         }
24066         return ret_ref;
24067 }
24068
24069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24070         LDKLockedNetworkGraph this_obj_conv;
24071         this_obj_conv.inner = (void*)(this_obj & (~1));
24072         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24073         LockedNetworkGraph_free(this_obj_conv);
24074 }
24075
24076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24077         LDKNetGraphMsgHandler this_obj_conv;
24078         this_obj_conv.inner = (void*)(this_obj & (~1));
24079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24080         NetGraphMsgHandler_free(this_obj_conv);
24081 }
24082
24083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t chain_access, int64_t logger) {
24084         LDKThirtyTwoBytes genesis_hash_ref;
24085         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24086         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24087         LDKAccess *chain_access_conv_ptr = NULL;
24088         if (chain_access != 0) {
24089                 LDKAccess chain_access_conv;
24090                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24091                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24092                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24093                         LDKAccess_JCalls_cloned(&chain_access_conv);
24094                 }
24095                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24096                 *chain_access_conv_ptr = chain_access_conv;
24097         }
24098         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24099         if (logger_conv.free == LDKLogger_JCalls_free) {
24100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24101                 LDKLogger_JCalls_cloned(&logger_conv);
24102         }
24103         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
24104         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24105         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24106         uint64_t ret_ref = (uint64_t)ret_var.inner;
24107         if (ret_var.is_owned) {
24108                 ret_ref |= 1;
24109         }
24110         return ret_ref;
24111 }
24112
24113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv *env, jclass clz, int64_t chain_access, int64_t logger, int64_t network_graph) {
24114         LDKAccess *chain_access_conv_ptr = NULL;
24115         if (chain_access != 0) {
24116                 LDKAccess chain_access_conv;
24117                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24118                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24119                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24120                         LDKAccess_JCalls_cloned(&chain_access_conv);
24121                 }
24122                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24123                 *chain_access_conv_ptr = chain_access_conv;
24124         }
24125         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24126         if (logger_conv.free == LDKLogger_JCalls_free) {
24127                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24128                 LDKLogger_JCalls_cloned(&logger_conv);
24129         }
24130         LDKNetworkGraph network_graph_conv;
24131         network_graph_conv.inner = (void*)(network_graph & (~1));
24132         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
24133         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
24134         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
24135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24137         uint64_t ret_ref = (uint64_t)ret_var.inner;
24138         if (ret_var.is_owned) {
24139                 ret_ref |= 1;
24140         }
24141         return ret_ref;
24142 }
24143
24144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
24145         LDKNetGraphMsgHandler this_arg_conv;
24146         this_arg_conv.inner = (void*)(this_arg & (~1));
24147         this_arg_conv.is_owned = false;
24148         LDKAccess *chain_access_conv_ptr = NULL;
24149         if (chain_access != 0) {
24150                 LDKAccess chain_access_conv;
24151                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24152                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24153                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24154                         LDKAccess_JCalls_cloned(&chain_access_conv);
24155                 }
24156                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24157                 *chain_access_conv_ptr = chain_access_conv;
24158         }
24159         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
24160 }
24161
24162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
24163         LDKNetGraphMsgHandler this_arg_conv;
24164         this_arg_conv.inner = (void*)(this_arg & (~1));
24165         this_arg_conv.is_owned = false;
24166         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
24167         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24168         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24169         uint64_t ret_ref = (uint64_t)ret_var.inner;
24170         if (ret_var.is_owned) {
24171                 ret_ref |= 1;
24172         }
24173         return ret_ref;
24174 }
24175
24176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
24177         LDKLockedNetworkGraph this_arg_conv;
24178         this_arg_conv.inner = (void*)(this_arg & (~1));
24179         this_arg_conv.is_owned = false;
24180         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
24181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24182         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24183         uint64_t ret_ref = (uint64_t)ret_var.inner;
24184         if (ret_var.is_owned) {
24185                 ret_ref |= 1;
24186         }
24187         return ret_ref;
24188 }
24189
24190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24191         LDKNetGraphMsgHandler this_arg_conv;
24192         this_arg_conv.inner = (void*)(this_arg & (~1));
24193         this_arg_conv.is_owned = false;
24194         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
24195         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
24196         return (uint64_t)ret;
24197 }
24198
24199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24200         LDKNetGraphMsgHandler this_arg_conv;
24201         this_arg_conv.inner = (void*)(this_arg & (~1));
24202         this_arg_conv.is_owned = false;
24203         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24204         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
24205         return (uint64_t)ret;
24206 }
24207
24208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24209         LDKDirectionalChannelInfo this_obj_conv;
24210         this_obj_conv.inner = (void*)(this_obj & (~1));
24211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24212         DirectionalChannelInfo_free(this_obj_conv);
24213 }
24214
24215 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
24216         LDKDirectionalChannelInfo this_ptr_conv;
24217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24218         this_ptr_conv.is_owned = false;
24219         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
24220         return ret_val;
24221 }
24222
24223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24224         LDKDirectionalChannelInfo this_ptr_conv;
24225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24226         this_ptr_conv.is_owned = false;
24227         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
24228 }
24229
24230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
24231         LDKDirectionalChannelInfo this_ptr_conv;
24232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24233         this_ptr_conv.is_owned = false;
24234         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
24235         return ret_val;
24236 }
24237
24238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24239         LDKDirectionalChannelInfo this_ptr_conv;
24240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24241         this_ptr_conv.is_owned = false;
24242         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
24243 }
24244
24245 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24246         LDKDirectionalChannelInfo this_ptr_conv;
24247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24248         this_ptr_conv.is_owned = false;
24249         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
24250         return ret_val;
24251 }
24252
24253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24254         LDKDirectionalChannelInfo this_ptr_conv;
24255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24256         this_ptr_conv.is_owned = false;
24257         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24258 }
24259
24260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24261         LDKDirectionalChannelInfo this_ptr_conv;
24262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24263         this_ptr_conv.is_owned = false;
24264         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
24265         return ret_val;
24266 }
24267
24268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24269         LDKDirectionalChannelInfo this_ptr_conv;
24270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24271         this_ptr_conv.is_owned = false;
24272         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
24273 }
24274
24275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24276         LDKDirectionalChannelInfo this_ptr_conv;
24277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24278         this_ptr_conv.is_owned = false;
24279         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24280         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
24281         uint64_t ret_ref = (uint64_t)ret_copy;
24282         return ret_ref;
24283 }
24284
24285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24286         LDKDirectionalChannelInfo this_ptr_conv;
24287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24288         this_ptr_conv.is_owned = false;
24289         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24290         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24291 }
24292
24293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24294         LDKDirectionalChannelInfo this_ptr_conv;
24295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24296         this_ptr_conv.is_owned = false;
24297         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24300         uint64_t ret_ref = (uint64_t)ret_var.inner;
24301         if (ret_var.is_owned) {
24302                 ret_ref |= 1;
24303         }
24304         return ret_ref;
24305 }
24306
24307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24308         LDKDirectionalChannelInfo this_ptr_conv;
24309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24310         this_ptr_conv.is_owned = false;
24311         LDKRoutingFees val_conv;
24312         val_conv.inner = (void*)(val & (~1));
24313         val_conv.is_owned = (val & 1) || (val == 0);
24314         val_conv = RoutingFees_clone(&val_conv);
24315         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24316 }
24317
24318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24319         LDKDirectionalChannelInfo this_ptr_conv;
24320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24321         this_ptr_conv.is_owned = false;
24322         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
24323         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24324         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24325         uint64_t ret_ref = (uint64_t)ret_var.inner;
24326         if (ret_var.is_owned) {
24327                 ret_ref |= 1;
24328         }
24329         return ret_ref;
24330 }
24331
24332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24333         LDKDirectionalChannelInfo this_ptr_conv;
24334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24335         this_ptr_conv.is_owned = false;
24336         LDKChannelUpdate val_conv;
24337         val_conv.inner = (void*)(val & (~1));
24338         val_conv.is_owned = (val & 1) || (val == 0);
24339         val_conv = ChannelUpdate_clone(&val_conv);
24340         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24341 }
24342
24343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_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) {
24344         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24345         LDKRoutingFees fees_arg_conv;
24346         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24347         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24348         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24349         LDKChannelUpdate last_update_message_arg_conv;
24350         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24351         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24352         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24353         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
24354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24356         uint64_t ret_ref = (uint64_t)ret_var.inner;
24357         if (ret_var.is_owned) {
24358                 ret_ref |= 1;
24359         }
24360         return ret_ref;
24361 }
24362
24363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24364         LDKDirectionalChannelInfo orig_conv;
24365         orig_conv.inner = (void*)(orig & (~1));
24366         orig_conv.is_owned = false;
24367         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
24368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24370         uint64_t ret_ref = (uint64_t)ret_var.inner;
24371         if (ret_var.is_owned) {
24372                 ret_ref |= 1;
24373         }
24374         return ret_ref;
24375 }
24376
24377 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24378         LDKDirectionalChannelInfo obj_conv;
24379         obj_conv.inner = (void*)(obj & (~1));
24380         obj_conv.is_owned = false;
24381         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24382         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24383         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24384         CVec_u8Z_free(ret_var);
24385         return ret_arr;
24386 }
24387
24388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24389         LDKu8slice ser_ref;
24390         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24391         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24392         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24393         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24394         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24395         return (uint64_t)ret_conv;
24396 }
24397
24398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24399         LDKChannelInfo this_obj_conv;
24400         this_obj_conv.inner = (void*)(this_obj & (~1));
24401         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24402         ChannelInfo_free(this_obj_conv);
24403 }
24404
24405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24406         LDKChannelInfo this_ptr_conv;
24407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24408         this_ptr_conv.is_owned = false;
24409         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24412         uint64_t ret_ref = (uint64_t)ret_var.inner;
24413         if (ret_var.is_owned) {
24414                 ret_ref |= 1;
24415         }
24416         return ret_ref;
24417 }
24418
24419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24420         LDKChannelInfo this_ptr_conv;
24421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24422         this_ptr_conv.is_owned = false;
24423         LDKChannelFeatures val_conv;
24424         val_conv.inner = (void*)(val & (~1));
24425         val_conv.is_owned = (val & 1) || (val == 0);
24426         val_conv = ChannelFeatures_clone(&val_conv);
24427         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24428 }
24429
24430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24431         LDKChannelInfo this_ptr_conv;
24432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24433         this_ptr_conv.is_owned = false;
24434         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
24436         return ret_arr;
24437 }
24438
24439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24440         LDKChannelInfo this_ptr_conv;
24441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24442         this_ptr_conv.is_owned = false;
24443         LDKPublicKey val_ref;
24444         CHECK((*env)->GetArrayLength(env, val) == 33);
24445         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24446         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
24447 }
24448
24449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24450         LDKChannelInfo this_ptr_conv;
24451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24452         this_ptr_conv.is_owned = false;
24453         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24454         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24455         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24456         uint64_t ret_ref = (uint64_t)ret_var.inner;
24457         if (ret_var.is_owned) {
24458                 ret_ref |= 1;
24459         }
24460         return ret_ref;
24461 }
24462
24463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24464         LDKChannelInfo this_ptr_conv;
24465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24466         this_ptr_conv.is_owned = false;
24467         LDKDirectionalChannelInfo val_conv;
24468         val_conv.inner = (void*)(val & (~1));
24469         val_conv.is_owned = (val & 1) || (val == 0);
24470         val_conv = DirectionalChannelInfo_clone(&val_conv);
24471         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24472 }
24473
24474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24475         LDKChannelInfo this_ptr_conv;
24476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24477         this_ptr_conv.is_owned = false;
24478         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24479         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
24480         return ret_arr;
24481 }
24482
24483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24484         LDKChannelInfo this_ptr_conv;
24485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24486         this_ptr_conv.is_owned = false;
24487         LDKPublicKey val_ref;
24488         CHECK((*env)->GetArrayLength(env, val) == 33);
24489         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24490         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
24491 }
24492
24493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24494         LDKChannelInfo this_ptr_conv;
24495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24496         this_ptr_conv.is_owned = false;
24497         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24498         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24499         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24500         uint64_t ret_ref = (uint64_t)ret_var.inner;
24501         if (ret_var.is_owned) {
24502                 ret_ref |= 1;
24503         }
24504         return ret_ref;
24505 }
24506
24507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24508         LDKChannelInfo this_ptr_conv;
24509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24510         this_ptr_conv.is_owned = false;
24511         LDKDirectionalChannelInfo val_conv;
24512         val_conv.inner = (void*)(val & (~1));
24513         val_conv.is_owned = (val & 1) || (val == 0);
24514         val_conv = DirectionalChannelInfo_clone(&val_conv);
24515         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24516 }
24517
24518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
24519         LDKChannelInfo this_ptr_conv;
24520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24521         this_ptr_conv.is_owned = false;
24522         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24523         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24524         uint64_t ret_ref = (uint64_t)ret_copy;
24525         return ret_ref;
24526 }
24527
24528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24529         LDKChannelInfo this_ptr_conv;
24530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24531         this_ptr_conv.is_owned = false;
24532         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24533         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24534 }
24535
24536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24537         LDKChannelInfo this_ptr_conv;
24538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24539         this_ptr_conv.is_owned = false;
24540         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24543         uint64_t ret_ref = (uint64_t)ret_var.inner;
24544         if (ret_var.is_owned) {
24545                 ret_ref |= 1;
24546         }
24547         return ret_ref;
24548 }
24549
24550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24551         LDKChannelInfo this_ptr_conv;
24552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24553         this_ptr_conv.is_owned = false;
24554         LDKChannelAnnouncement val_conv;
24555         val_conv.inner = (void*)(val & (~1));
24556         val_conv.is_owned = (val & 1) || (val == 0);
24557         val_conv = ChannelAnnouncement_clone(&val_conv);
24558         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24559 }
24560
24561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int8_tArray node_one_arg, int64_t one_to_two_arg, int8_tArray node_two_arg, int64_t two_to_one_arg, int64_t capacity_sats_arg, int64_t announcement_message_arg) {
24562         LDKChannelFeatures features_arg_conv;
24563         features_arg_conv.inner = (void*)(features_arg & (~1));
24564         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24565         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24566         LDKPublicKey node_one_arg_ref;
24567         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
24568         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
24569         LDKDirectionalChannelInfo one_to_two_arg_conv;
24570         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24571         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24572         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24573         LDKPublicKey node_two_arg_ref;
24574         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
24575         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
24576         LDKDirectionalChannelInfo two_to_one_arg_conv;
24577         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24578         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
24579         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
24580         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
24581         LDKChannelAnnouncement announcement_message_arg_conv;
24582         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24583         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24584         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
24585         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_ref, one_to_two_arg_conv, node_two_arg_ref, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
24586         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24587         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24588         uint64_t ret_ref = (uint64_t)ret_var.inner;
24589         if (ret_var.is_owned) {
24590                 ret_ref |= 1;
24591         }
24592         return ret_ref;
24593 }
24594
24595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24596         LDKChannelInfo orig_conv;
24597         orig_conv.inner = (void*)(orig & (~1));
24598         orig_conv.is_owned = false;
24599         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
24600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24602         uint64_t ret_ref = (uint64_t)ret_var.inner;
24603         if (ret_var.is_owned) {
24604                 ret_ref |= 1;
24605         }
24606         return ret_ref;
24607 }
24608
24609 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24610         LDKChannelInfo obj_conv;
24611         obj_conv.inner = (void*)(obj & (~1));
24612         obj_conv.is_owned = false;
24613         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
24614         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24615         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24616         CVec_u8Z_free(ret_var);
24617         return ret_arr;
24618 }
24619
24620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24621         LDKu8slice ser_ref;
24622         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24623         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24624         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
24625         *ret_conv = ChannelInfo_read(ser_ref);
24626         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24627         return (uint64_t)ret_conv;
24628 }
24629
24630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24631         LDKRoutingFees this_obj_conv;
24632         this_obj_conv.inner = (void*)(this_obj & (~1));
24633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24634         RoutingFees_free(this_obj_conv);
24635 }
24636
24637 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24638         LDKRoutingFees this_ptr_conv;
24639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24640         this_ptr_conv.is_owned = false;
24641         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
24642         return ret_val;
24643 }
24644
24645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24646         LDKRoutingFees this_ptr_conv;
24647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24648         this_ptr_conv.is_owned = false;
24649         RoutingFees_set_base_msat(&this_ptr_conv, val);
24650 }
24651
24652 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24653         LDKRoutingFees this_ptr_conv;
24654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24655         this_ptr_conv.is_owned = false;
24656         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
24657         return ret_val;
24658 }
24659
24660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24661         LDKRoutingFees this_ptr_conv;
24662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24663         this_ptr_conv.is_owned = false;
24664         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
24665 }
24666
24667 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) {
24668         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
24669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24671         uint64_t ret_ref = (uint64_t)ret_var.inner;
24672         if (ret_var.is_owned) {
24673                 ret_ref |= 1;
24674         }
24675         return ret_ref;
24676 }
24677
24678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24679         LDKRoutingFees a_conv;
24680         a_conv.inner = (void*)(a & (~1));
24681         a_conv.is_owned = false;
24682         LDKRoutingFees b_conv;
24683         b_conv.inner = (void*)(b & (~1));
24684         b_conv.is_owned = false;
24685         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
24686         return ret_val;
24687 }
24688
24689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24690         LDKRoutingFees orig_conv;
24691         orig_conv.inner = (void*)(orig & (~1));
24692         orig_conv.is_owned = false;
24693         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
24694         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24695         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24696         uint64_t ret_ref = (uint64_t)ret_var.inner;
24697         if (ret_var.is_owned) {
24698                 ret_ref |= 1;
24699         }
24700         return ret_ref;
24701 }
24702
24703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
24704         LDKRoutingFees obj_conv;
24705         obj_conv.inner = (void*)(obj & (~1));
24706         obj_conv.is_owned = false;
24707         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
24708         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24709         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24710         CVec_u8Z_free(ret_var);
24711         return ret_arr;
24712 }
24713
24714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24715         LDKu8slice ser_ref;
24716         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24717         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24718         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
24719         *ret_conv = RoutingFees_read(ser_ref);
24720         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24721         return (uint64_t)ret_conv;
24722 }
24723
24724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24725         LDKNodeAnnouncementInfo this_obj_conv;
24726         this_obj_conv.inner = (void*)(this_obj & (~1));
24727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24728         NodeAnnouncementInfo_free(this_obj_conv);
24729 }
24730
24731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24732         LDKNodeAnnouncementInfo this_ptr_conv;
24733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24734         this_ptr_conv.is_owned = false;
24735         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
24736         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24737         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24738         uint64_t ret_ref = (uint64_t)ret_var.inner;
24739         if (ret_var.is_owned) {
24740                 ret_ref |= 1;
24741         }
24742         return ret_ref;
24743 }
24744
24745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24746         LDKNodeAnnouncementInfo this_ptr_conv;
24747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24748         this_ptr_conv.is_owned = false;
24749         LDKNodeFeatures val_conv;
24750         val_conv.inner = (void*)(val & (~1));
24751         val_conv.is_owned = (val & 1) || (val == 0);
24752         val_conv = NodeFeatures_clone(&val_conv);
24753         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
24754 }
24755
24756 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
24757         LDKNodeAnnouncementInfo this_ptr_conv;
24758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24759         this_ptr_conv.is_owned = false;
24760         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
24761         return ret_val;
24762 }
24763
24764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24765         LDKNodeAnnouncementInfo this_ptr_conv;
24766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24767         this_ptr_conv.is_owned = false;
24768         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
24769 }
24770
24771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
24772         LDKNodeAnnouncementInfo this_ptr_conv;
24773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24774         this_ptr_conv.is_owned = false;
24775         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
24776         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
24777         return ret_arr;
24778 }
24779
24780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24781         LDKNodeAnnouncementInfo this_ptr_conv;
24782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24783         this_ptr_conv.is_owned = false;
24784         LDKThreeBytes val_ref;
24785         CHECK((*env)->GetArrayLength(env, val) == 3);
24786         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
24787         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
24788 }
24789
24790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
24791         LDKNodeAnnouncementInfo this_ptr_conv;
24792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24793         this_ptr_conv.is_owned = false;
24794         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24795         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
24796         return ret_arr;
24797 }
24798
24799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24800         LDKNodeAnnouncementInfo this_ptr_conv;
24801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24802         this_ptr_conv.is_owned = false;
24803         LDKThirtyTwoBytes val_ref;
24804         CHECK((*env)->GetArrayLength(env, val) == 32);
24805         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24806         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
24807 }
24808
24809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24810         LDKNodeAnnouncementInfo this_ptr_conv;
24811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24812         this_ptr_conv.is_owned = false;
24813         LDKCVec_NetAddressZ val_constr;
24814         val_constr.datalen = (*env)->GetArrayLength(env, val);
24815         if (val_constr.datalen > 0)
24816                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24817         else
24818                 val_constr.data = NULL;
24819         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24820         for (size_t m = 0; m < val_constr.datalen; m++) {
24821                 int64_t val_conv_12 = val_vals[m];
24822                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
24823                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
24824                 val_constr.data[m] = val_conv_12_conv;
24825         }
24826         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24827         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
24828 }
24829
24830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24831         LDKNodeAnnouncementInfo this_ptr_conv;
24832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24833         this_ptr_conv.is_owned = false;
24834         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
24835         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24836         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24837         uint64_t ret_ref = (uint64_t)ret_var.inner;
24838         if (ret_var.is_owned) {
24839                 ret_ref |= 1;
24840         }
24841         return ret_ref;
24842 }
24843
24844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24845         LDKNodeAnnouncementInfo this_ptr_conv;
24846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24847         this_ptr_conv.is_owned = false;
24848         LDKNodeAnnouncement val_conv;
24849         val_conv.inner = (void*)(val & (~1));
24850         val_conv.is_owned = (val & 1) || (val == 0);
24851         val_conv = NodeAnnouncement_clone(&val_conv);
24852         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
24853 }
24854
24855 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, int8_tArray alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
24856         LDKNodeFeatures features_arg_conv;
24857         features_arg_conv.inner = (void*)(features_arg & (~1));
24858         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24859         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
24860         LDKThreeBytes rgb_arg_ref;
24861         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
24862         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
24863         LDKThirtyTwoBytes alias_arg_ref;
24864         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
24865         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
24866         LDKCVec_NetAddressZ addresses_arg_constr;
24867         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
24868         if (addresses_arg_constr.datalen > 0)
24869                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24870         else
24871                 addresses_arg_constr.data = NULL;
24872         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
24873         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24874                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
24875                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24876                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24877         }
24878         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
24879         LDKNodeAnnouncement announcement_message_arg_conv;
24880         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24881         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24882         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24883         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24884         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24885         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24886         uint64_t ret_ref = (uint64_t)ret_var.inner;
24887         if (ret_var.is_owned) {
24888                 ret_ref |= 1;
24889         }
24890         return ret_ref;
24891 }
24892
24893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24894         LDKNodeAnnouncementInfo orig_conv;
24895         orig_conv.inner = (void*)(orig & (~1));
24896         orig_conv.is_owned = false;
24897         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24898         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24899         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24900         uint64_t ret_ref = (uint64_t)ret_var.inner;
24901         if (ret_var.is_owned) {
24902                 ret_ref |= 1;
24903         }
24904         return ret_ref;
24905 }
24906
24907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24908         LDKNodeAnnouncementInfo obj_conv;
24909         obj_conv.inner = (void*)(obj & (~1));
24910         obj_conv.is_owned = false;
24911         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24912         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24913         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24914         CVec_u8Z_free(ret_var);
24915         return ret_arr;
24916 }
24917
24918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24919         LDKu8slice ser_ref;
24920         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24921         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24922         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24923         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24924         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24925         return (uint64_t)ret_conv;
24926 }
24927
24928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24929         LDKNodeInfo this_obj_conv;
24930         this_obj_conv.inner = (void*)(this_obj & (~1));
24931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24932         NodeInfo_free(this_obj_conv);
24933 }
24934
24935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24936         LDKNodeInfo this_ptr_conv;
24937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24938         this_ptr_conv.is_owned = false;
24939         LDKCVec_u64Z val_constr;
24940         val_constr.datalen = (*env)->GetArrayLength(env, val);
24941         if (val_constr.datalen > 0)
24942                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24943         else
24944                 val_constr.data = NULL;
24945         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24946         for (size_t g = 0; g < val_constr.datalen; g++) {
24947                 int64_t val_conv_6 = val_vals[g];
24948                 val_constr.data[g] = val_conv_6;
24949         }
24950         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24951         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24952 }
24953
24954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24955         LDKNodeInfo this_ptr_conv;
24956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24957         this_ptr_conv.is_owned = false;
24958         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24959         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24960         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24961         uint64_t ret_ref = (uint64_t)ret_var.inner;
24962         if (ret_var.is_owned) {
24963                 ret_ref |= 1;
24964         }
24965         return ret_ref;
24966 }
24967
24968 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) {
24969         LDKNodeInfo this_ptr_conv;
24970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24971         this_ptr_conv.is_owned = false;
24972         LDKRoutingFees val_conv;
24973         val_conv.inner = (void*)(val & (~1));
24974         val_conv.is_owned = (val & 1) || (val == 0);
24975         val_conv = RoutingFees_clone(&val_conv);
24976         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24977 }
24978
24979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
24980         LDKNodeInfo this_ptr_conv;
24981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24982         this_ptr_conv.is_owned = false;
24983         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24984         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24985         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24986         uint64_t ret_ref = (uint64_t)ret_var.inner;
24987         if (ret_var.is_owned) {
24988                 ret_ref |= 1;
24989         }
24990         return ret_ref;
24991 }
24992
24993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24994         LDKNodeInfo this_ptr_conv;
24995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24996         this_ptr_conv.is_owned = false;
24997         LDKNodeAnnouncementInfo val_conv;
24998         val_conv.inner = (void*)(val & (~1));
24999         val_conv.is_owned = (val & 1) || (val == 0);
25000         val_conv = NodeAnnouncementInfo_clone(&val_conv);
25001         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
25002 }
25003
25004 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) {
25005         LDKCVec_u64Z channels_arg_constr;
25006         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
25007         if (channels_arg_constr.datalen > 0)
25008                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25009         else
25010                 channels_arg_constr.data = NULL;
25011         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
25012         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
25013                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
25014                 channels_arg_constr.data[g] = channels_arg_conv_6;
25015         }
25016         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
25017         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
25018         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
25019         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
25020         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
25021         LDKNodeAnnouncementInfo announcement_info_arg_conv;
25022         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
25023         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
25024         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
25025         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
25026         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25027         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25028         uint64_t ret_ref = (uint64_t)ret_var.inner;
25029         if (ret_var.is_owned) {
25030                 ret_ref |= 1;
25031         }
25032         return ret_ref;
25033 }
25034
25035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25036         LDKNodeInfo orig_conv;
25037         orig_conv.inner = (void*)(orig & (~1));
25038         orig_conv.is_owned = false;
25039         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
25040         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25041         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25042         uint64_t ret_ref = (uint64_t)ret_var.inner;
25043         if (ret_var.is_owned) {
25044                 ret_ref |= 1;
25045         }
25046         return ret_ref;
25047 }
25048
25049 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25050         LDKNodeInfo obj_conv;
25051         obj_conv.inner = (void*)(obj & (~1));
25052         obj_conv.is_owned = false;
25053         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
25054         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25055         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25056         CVec_u8Z_free(ret_var);
25057         return ret_arr;
25058 }
25059
25060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25061         LDKu8slice ser_ref;
25062         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25063         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25064         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
25065         *ret_conv = NodeInfo_read(ser_ref);
25066         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25067         return (uint64_t)ret_conv;
25068 }
25069
25070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
25071         LDKNetworkGraph obj_conv;
25072         obj_conv.inner = (void*)(obj & (~1));
25073         obj_conv.is_owned = false;
25074         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
25075         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25076         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25077         CVec_u8Z_free(ret_var);
25078         return ret_arr;
25079 }
25080
25081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25082         LDKu8slice ser_ref;
25083         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25084         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25085         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
25086         *ret_conv = NetworkGraph_read(ser_ref);
25087         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25088         return (uint64_t)ret_conv;
25089 }
25090
25091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
25092         LDKThirtyTwoBytes genesis_hash_ref;
25093         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
25094         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
25095         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
25096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25098         uint64_t ret_ref = (uint64_t)ret_var.inner;
25099         if (ret_var.is_owned) {
25100                 ret_ref |= 1;
25101         }
25102         return ret_ref;
25103 }
25104
25105 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) {
25106         LDKNetworkGraph this_arg_conv;
25107         this_arg_conv.inner = (void*)(this_arg & (~1));
25108         this_arg_conv.is_owned = false;
25109         LDKNodeAnnouncement msg_conv;
25110         msg_conv.inner = (void*)(msg & (~1));
25111         msg_conv.is_owned = false;
25112         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25113         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
25114         return (uint64_t)ret_conv;
25115 }
25116
25117 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) {
25118         LDKNetworkGraph this_arg_conv;
25119         this_arg_conv.inner = (void*)(this_arg & (~1));
25120         this_arg_conv.is_owned = false;
25121         LDKUnsignedNodeAnnouncement msg_conv;
25122         msg_conv.inner = (void*)(msg & (~1));
25123         msg_conv.is_owned = false;
25124         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25125         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
25126         return (uint64_t)ret_conv;
25127 }
25128
25129 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) {
25130         LDKNetworkGraph this_arg_conv;
25131         this_arg_conv.inner = (void*)(this_arg & (~1));
25132         this_arg_conv.is_owned = false;
25133         LDKChannelAnnouncement msg_conv;
25134         msg_conv.inner = (void*)(msg & (~1));
25135         msg_conv.is_owned = false;
25136         LDKAccess *chain_access_conv_ptr = NULL;
25137         if (chain_access != 0) {
25138                 LDKAccess chain_access_conv;
25139                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25140                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25141                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25142                         LDKAccess_JCalls_cloned(&chain_access_conv);
25143                 }
25144                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25145                 *chain_access_conv_ptr = chain_access_conv;
25146         }
25147         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25148         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
25149         return (uint64_t)ret_conv;
25150 }
25151
25152 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) {
25153         LDKNetworkGraph this_arg_conv;
25154         this_arg_conv.inner = (void*)(this_arg & (~1));
25155         this_arg_conv.is_owned = false;
25156         LDKUnsignedChannelAnnouncement msg_conv;
25157         msg_conv.inner = (void*)(msg & (~1));
25158         msg_conv.is_owned = false;
25159         LDKAccess *chain_access_conv_ptr = NULL;
25160         if (chain_access != 0) {
25161                 LDKAccess chain_access_conv;
25162                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25163                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25164                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25165                         LDKAccess_JCalls_cloned(&chain_access_conv);
25166                 }
25167                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25168                 *chain_access_conv_ptr = chain_access_conv;
25169         }
25170         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25171         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
25172         return (uint64_t)ret_conv;
25173 }
25174
25175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
25176         LDKNetworkGraph this_arg_conv;
25177         this_arg_conv.inner = (void*)(this_arg & (~1));
25178         this_arg_conv.is_owned = false;
25179         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
25180 }
25181
25182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
25183         LDKNetworkGraph this_arg_conv;
25184         this_arg_conv.inner = (void*)(this_arg & (~1));
25185         this_arg_conv.is_owned = false;
25186         LDKChannelUpdate msg_conv;
25187         msg_conv.inner = (void*)(msg & (~1));
25188         msg_conv.is_owned = false;
25189         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25190         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
25191         return (uint64_t)ret_conv;
25192 }
25193
25194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
25195         LDKNetworkGraph this_arg_conv;
25196         this_arg_conv.inner = (void*)(this_arg & (~1));
25197         this_arg_conv.is_owned = false;
25198         LDKUnsignedChannelUpdate msg_conv;
25199         msg_conv.inner = (void*)(msg & (~1));
25200         msg_conv.is_owned = false;
25201         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25202         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
25203         return (uint64_t)ret_conv;
25204 }
25205
25206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25207         LDKFilesystemPersister this_obj_conv;
25208         this_obj_conv.inner = (void*)(this_obj & (~1));
25209         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25210         FilesystemPersister_free(this_obj_conv);
25211 }
25212
25213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
25214         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
25215         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
25216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25218         uint64_t ret_ref = (uint64_t)ret_var.inner;
25219         if (ret_var.is_owned) {
25220                 ret_ref |= 1;
25221         }
25222         return ret_ref;
25223 }
25224
25225 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
25226         LDKFilesystemPersister this_arg_conv;
25227         this_arg_conv.inner = (void*)(this_arg & (~1));
25228         this_arg_conv.is_owned = false;
25229         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
25230         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25231         Str_free(ret_str);
25232         return ret_conv;
25233 }
25234
25235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
25236         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
25237         LDKChannelManager manager_conv;
25238         manager_conv.inner = (void*)(manager & (~1));
25239         manager_conv.is_owned = false;
25240         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25241         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
25242         return (uint64_t)ret_conv;
25243 }
25244
25245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
25246         LDKFilesystemPersister this_arg_conv;
25247         this_arg_conv.inner = (void*)(this_arg & (~1));
25248         this_arg_conv.is_owned = false;
25249         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25250         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25251                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25252                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25253         }
25254         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
25255         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
25256         return (uint64_t)ret_conv;
25257 }
25258
25259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
25260         LDKFilesystemPersister this_arg_conv;
25261         this_arg_conv.inner = (void*)(this_arg & (~1));
25262         this_arg_conv.is_owned = false;
25263         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
25264         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
25265         return (uint64_t)ret;
25266 }
25267
25268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25269         LDKBackgroundProcessor this_obj_conv;
25270         this_obj_conv.inner = (void*)(this_obj & (~1));
25271         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25272         BackgroundProcessor_free(this_obj_conv);
25273 }
25274
25275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25276         if ((this_ptr & 1) != 0) return;
25277         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
25278         FREE((void*)this_ptr);
25279         ChannelManagerPersister_free(this_ptr_conv);
25280 }
25281
25282 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 peer_manager, int64_t logger) {
25283         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
25284         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
25285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25286                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
25287         }
25288         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25289         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
25290                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25291                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
25292         }
25293         LDKChainMonitor chain_monitor_conv;
25294         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
25295         chain_monitor_conv.is_owned = false;
25296         LDKChannelManager channel_manager_conv;
25297         channel_manager_conv.inner = (void*)(channel_manager & (~1));
25298         channel_manager_conv.is_owned = false;
25299         LDKPeerManager peer_manager_conv;
25300         peer_manager_conv.inner = (void*)(peer_manager & (~1));
25301         peer_manager_conv.is_owned = false;
25302         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25303         if (logger_conv.free == LDKLogger_JCalls_free) {
25304                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25305                 LDKLogger_JCalls_cloned(&logger_conv);
25306         }
25307         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
25308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25310         uint64_t ret_ref = (uint64_t)ret_var.inner;
25311         if (ret_var.is_owned) {
25312                 ret_ref |= 1;
25313         }
25314         return ret_ref;
25315 }
25316
25317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
25318         LDKBackgroundProcessor this_arg_conv;
25319         this_arg_conv.inner = (void*)(this_arg & (~1));
25320         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25321         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25322         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25323         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
25324         return (uint64_t)ret_conv;
25325 }
25326
25327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
25328         check_platform();
25329 }
25330
25331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25332         LDKInvoice this_obj_conv;
25333         this_obj_conv.inner = (void*)(this_obj & (~1));
25334         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25335         Invoice_free(this_obj_conv);
25336 }
25337
25338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25339         LDKInvoice a_conv;
25340         a_conv.inner = (void*)(a & (~1));
25341         a_conv.is_owned = false;
25342         LDKInvoice b_conv;
25343         b_conv.inner = (void*)(b & (~1));
25344         b_conv.is_owned = false;
25345         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
25346         return ret_val;
25347 }
25348
25349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25350         LDKInvoice orig_conv;
25351         orig_conv.inner = (void*)(orig & (~1));
25352         orig_conv.is_owned = false;
25353         LDKInvoice ret_var = Invoice_clone(&orig_conv);
25354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25356         uint64_t ret_ref = (uint64_t)ret_var.inner;
25357         if (ret_var.is_owned) {
25358                 ret_ref |= 1;
25359         }
25360         return ret_ref;
25361 }
25362
25363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25364         LDKSignedRawInvoice this_obj_conv;
25365         this_obj_conv.inner = (void*)(this_obj & (~1));
25366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25367         SignedRawInvoice_free(this_obj_conv);
25368 }
25369
25370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25371         LDKSignedRawInvoice a_conv;
25372         a_conv.inner = (void*)(a & (~1));
25373         a_conv.is_owned = false;
25374         LDKSignedRawInvoice b_conv;
25375         b_conv.inner = (void*)(b & (~1));
25376         b_conv.is_owned = false;
25377         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
25378         return ret_val;
25379 }
25380
25381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25382         LDKSignedRawInvoice orig_conv;
25383         orig_conv.inner = (void*)(orig & (~1));
25384         orig_conv.is_owned = false;
25385         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
25386         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25387         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25388         uint64_t ret_ref = (uint64_t)ret_var.inner;
25389         if (ret_var.is_owned) {
25390                 ret_ref |= 1;
25391         }
25392         return ret_ref;
25393 }
25394
25395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25396         LDKRawInvoice this_obj_conv;
25397         this_obj_conv.inner = (void*)(this_obj & (~1));
25398         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25399         RawInvoice_free(this_obj_conv);
25400 }
25401
25402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
25403         LDKRawInvoice this_ptr_conv;
25404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25405         this_ptr_conv.is_owned = false;
25406         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
25407         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25408         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25409         uint64_t ret_ref = (uint64_t)ret_var.inner;
25410         if (ret_var.is_owned) {
25411                 ret_ref |= 1;
25412         }
25413         return ret_ref;
25414 }
25415
25416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25417         LDKRawInvoice this_ptr_conv;
25418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25419         this_ptr_conv.is_owned = false;
25420         LDKRawDataPart val_conv;
25421         val_conv.inner = (void*)(val & (~1));
25422         val_conv.is_owned = (val & 1) || (val == 0);
25423         val_conv = RawDataPart_clone(&val_conv);
25424         RawInvoice_set_data(&this_ptr_conv, val_conv);
25425 }
25426
25427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25428         LDKRawInvoice a_conv;
25429         a_conv.inner = (void*)(a & (~1));
25430         a_conv.is_owned = false;
25431         LDKRawInvoice b_conv;
25432         b_conv.inner = (void*)(b & (~1));
25433         b_conv.is_owned = false;
25434         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
25435         return ret_val;
25436 }
25437
25438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25439         LDKRawInvoice orig_conv;
25440         orig_conv.inner = (void*)(orig & (~1));
25441         orig_conv.is_owned = false;
25442         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
25443         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25444         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25445         uint64_t ret_ref = (uint64_t)ret_var.inner;
25446         if (ret_var.is_owned) {
25447                 ret_ref |= 1;
25448         }
25449         return ret_ref;
25450 }
25451
25452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25453         LDKRawDataPart this_obj_conv;
25454         this_obj_conv.inner = (void*)(this_obj & (~1));
25455         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25456         RawDataPart_free(this_obj_conv);
25457 }
25458
25459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
25460         LDKRawDataPart this_ptr_conv;
25461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25462         this_ptr_conv.is_owned = false;
25463         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
25464         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25465         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25466         uint64_t ret_ref = (uint64_t)ret_var.inner;
25467         if (ret_var.is_owned) {
25468                 ret_ref |= 1;
25469         }
25470         return ret_ref;
25471 }
25472
25473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25474         LDKRawDataPart this_ptr_conv;
25475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25476         this_ptr_conv.is_owned = false;
25477         LDKPositiveTimestamp val_conv;
25478         val_conv.inner = (void*)(val & (~1));
25479         val_conv.is_owned = (val & 1) || (val == 0);
25480         val_conv = PositiveTimestamp_clone(&val_conv);
25481         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
25482 }
25483
25484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25485         LDKRawDataPart a_conv;
25486         a_conv.inner = (void*)(a & (~1));
25487         a_conv.is_owned = false;
25488         LDKRawDataPart b_conv;
25489         b_conv.inner = (void*)(b & (~1));
25490         b_conv.is_owned = false;
25491         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
25492         return ret_val;
25493 }
25494
25495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25496         LDKRawDataPart orig_conv;
25497         orig_conv.inner = (void*)(orig & (~1));
25498         orig_conv.is_owned = false;
25499         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
25500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25502         uint64_t ret_ref = (uint64_t)ret_var.inner;
25503         if (ret_var.is_owned) {
25504                 ret_ref |= 1;
25505         }
25506         return ret_ref;
25507 }
25508
25509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25510         LDKPositiveTimestamp this_obj_conv;
25511         this_obj_conv.inner = (void*)(this_obj & (~1));
25512         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25513         PositiveTimestamp_free(this_obj_conv);
25514 }
25515
25516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25517         LDKPositiveTimestamp a_conv;
25518         a_conv.inner = (void*)(a & (~1));
25519         a_conv.is_owned = false;
25520         LDKPositiveTimestamp b_conv;
25521         b_conv.inner = (void*)(b & (~1));
25522         b_conv.is_owned = false;
25523         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
25524         return ret_val;
25525 }
25526
25527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25528         LDKPositiveTimestamp orig_conv;
25529         orig_conv.inner = (void*)(orig & (~1));
25530         orig_conv.is_owned = false;
25531         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
25532         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25533         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25534         uint64_t ret_ref = (uint64_t)ret_var.inner;
25535         if (ret_var.is_owned) {
25536                 ret_ref |= 1;
25537         }
25538         return ret_ref;
25539 }
25540
25541 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25542         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
25543         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
25544         return ret_conv;
25545 }
25546
25547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25548         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
25549         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
25550         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
25551         return ret_val;
25552 }
25553
25554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
25555         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
25556         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
25557         return ret_val;
25558 }
25559
25560 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25561         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
25562         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
25563         return ret_conv;
25564 }
25565
25566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25567         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
25568         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
25569         jboolean ret_val = Currency_eq(a_conv, b_conv);
25570         return ret_val;
25571 }
25572
25573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25574         LDKSha256 this_obj_conv;
25575         this_obj_conv.inner = (void*)(this_obj & (~1));
25576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25577         Sha256_free(this_obj_conv);
25578 }
25579
25580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25581         LDKSha256 a_conv;
25582         a_conv.inner = (void*)(a & (~1));
25583         a_conv.is_owned = false;
25584         LDKSha256 b_conv;
25585         b_conv.inner = (void*)(b & (~1));
25586         b_conv.is_owned = false;
25587         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
25588         return ret_val;
25589 }
25590
25591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25592         LDKSha256 orig_conv;
25593         orig_conv.inner = (void*)(orig & (~1));
25594         orig_conv.is_owned = false;
25595         LDKSha256 ret_var = Sha256_clone(&orig_conv);
25596         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25597         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25598         uint64_t ret_ref = (uint64_t)ret_var.inner;
25599         if (ret_var.is_owned) {
25600                 ret_ref |= 1;
25601         }
25602         return ret_ref;
25603 }
25604
25605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25606         LDKDescription this_obj_conv;
25607         this_obj_conv.inner = (void*)(this_obj & (~1));
25608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25609         Description_free(this_obj_conv);
25610 }
25611
25612 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25613         LDKDescription a_conv;
25614         a_conv.inner = (void*)(a & (~1));
25615         a_conv.is_owned = false;
25616         LDKDescription b_conv;
25617         b_conv.inner = (void*)(b & (~1));
25618         b_conv.is_owned = false;
25619         jboolean ret_val = Description_eq(&a_conv, &b_conv);
25620         return ret_val;
25621 }
25622
25623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25624         LDKDescription orig_conv;
25625         orig_conv.inner = (void*)(orig & (~1));
25626         orig_conv.is_owned = false;
25627         LDKDescription ret_var = Description_clone(&orig_conv);
25628         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25629         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25630         uint64_t ret_ref = (uint64_t)ret_var.inner;
25631         if (ret_var.is_owned) {
25632                 ret_ref |= 1;
25633         }
25634         return ret_ref;
25635 }
25636
25637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25638         LDKPayeePubKey this_obj_conv;
25639         this_obj_conv.inner = (void*)(this_obj & (~1));
25640         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25641         PayeePubKey_free(this_obj_conv);
25642 }
25643
25644 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25645         LDKPayeePubKey a_conv;
25646         a_conv.inner = (void*)(a & (~1));
25647         a_conv.is_owned = false;
25648         LDKPayeePubKey b_conv;
25649         b_conv.inner = (void*)(b & (~1));
25650         b_conv.is_owned = false;
25651         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
25652         return ret_val;
25653 }
25654
25655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25656         LDKPayeePubKey orig_conv;
25657         orig_conv.inner = (void*)(orig & (~1));
25658         orig_conv.is_owned = false;
25659         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
25660         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25661         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25662         uint64_t ret_ref = (uint64_t)ret_var.inner;
25663         if (ret_var.is_owned) {
25664                 ret_ref |= 1;
25665         }
25666         return ret_ref;
25667 }
25668
25669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25670         LDKExpiryTime this_obj_conv;
25671         this_obj_conv.inner = (void*)(this_obj & (~1));
25672         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25673         ExpiryTime_free(this_obj_conv);
25674 }
25675
25676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25677         LDKExpiryTime a_conv;
25678         a_conv.inner = (void*)(a & (~1));
25679         a_conv.is_owned = false;
25680         LDKExpiryTime b_conv;
25681         b_conv.inner = (void*)(b & (~1));
25682         b_conv.is_owned = false;
25683         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
25684         return ret_val;
25685 }
25686
25687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25688         LDKExpiryTime orig_conv;
25689         orig_conv.inner = (void*)(orig & (~1));
25690         orig_conv.is_owned = false;
25691         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
25692         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25693         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25694         uint64_t ret_ref = (uint64_t)ret_var.inner;
25695         if (ret_var.is_owned) {
25696                 ret_ref |= 1;
25697         }
25698         return ret_ref;
25699 }
25700
25701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25702         LDKMinFinalCltvExpiry this_obj_conv;
25703         this_obj_conv.inner = (void*)(this_obj & (~1));
25704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25705         MinFinalCltvExpiry_free(this_obj_conv);
25706 }
25707
25708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25709         LDKMinFinalCltvExpiry a_conv;
25710         a_conv.inner = (void*)(a & (~1));
25711         a_conv.is_owned = false;
25712         LDKMinFinalCltvExpiry b_conv;
25713         b_conv.inner = (void*)(b & (~1));
25714         b_conv.is_owned = false;
25715         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
25716         return ret_val;
25717 }
25718
25719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25720         LDKMinFinalCltvExpiry orig_conv;
25721         orig_conv.inner = (void*)(orig & (~1));
25722         orig_conv.is_owned = false;
25723         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
25724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25726         uint64_t ret_ref = (uint64_t)ret_var.inner;
25727         if (ret_var.is_owned) {
25728                 ret_ref |= 1;
25729         }
25730         return ret_ref;
25731 }
25732
25733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25734         if ((this_ptr & 1) != 0) return;
25735         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
25736         FREE((void*)this_ptr);
25737         Fallback_free(this_ptr_conv);
25738 }
25739
25740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25741         LDKFallback* orig_conv = (LDKFallback*)orig;
25742         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25743         *ret_copy = Fallback_clone(orig_conv);
25744         uint64_t ret_ref = (uint64_t)ret_copy;
25745         return ret_ref;
25746 }
25747
25748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25749         LDKFallback* a_conv = (LDKFallback*)a;
25750         LDKFallback* b_conv = (LDKFallback*)b;
25751         jboolean ret_val = Fallback_eq(a_conv, b_conv);
25752         return ret_val;
25753 }
25754
25755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25756         LDKInvoiceSignature this_obj_conv;
25757         this_obj_conv.inner = (void*)(this_obj & (~1));
25758         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25759         InvoiceSignature_free(this_obj_conv);
25760 }
25761
25762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25763         LDKInvoiceSignature a_conv;
25764         a_conv.inner = (void*)(a & (~1));
25765         a_conv.is_owned = false;
25766         LDKInvoiceSignature b_conv;
25767         b_conv.inner = (void*)(b & (~1));
25768         b_conv.is_owned = false;
25769         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
25770         return ret_val;
25771 }
25772
25773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25774         LDKInvoiceSignature orig_conv;
25775         orig_conv.inner = (void*)(orig & (~1));
25776         orig_conv.is_owned = false;
25777         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
25778         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25779         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25780         uint64_t ret_ref = (uint64_t)ret_var.inner;
25781         if (ret_var.is_owned) {
25782                 ret_ref |= 1;
25783         }
25784         return ret_ref;
25785 }
25786
25787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25788         LDKPrivateRoute this_obj_conv;
25789         this_obj_conv.inner = (void*)(this_obj & (~1));
25790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25791         PrivateRoute_free(this_obj_conv);
25792 }
25793
25794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25795         LDKPrivateRoute a_conv;
25796         a_conv.inner = (void*)(a & (~1));
25797         a_conv.is_owned = false;
25798         LDKPrivateRoute b_conv;
25799         b_conv.inner = (void*)(b & (~1));
25800         b_conv.is_owned = false;
25801         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
25802         return ret_val;
25803 }
25804
25805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25806         LDKPrivateRoute orig_conv;
25807         orig_conv.inner = (void*)(orig & (~1));
25808         orig_conv.is_owned = false;
25809         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
25810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25812         uint64_t ret_ref = (uint64_t)ret_var.inner;
25813         if (ret_var.is_owned) {
25814                 ret_ref |= 1;
25815         }
25816         return ret_ref;
25817 }
25818
25819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
25820         LDKSignedRawInvoice this_arg_conv;
25821         this_arg_conv.inner = (void*)(this_arg & (~1));
25822         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25823         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
25824         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
25825         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
25826         return (uint64_t)ret_ref;
25827 }
25828
25829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
25830         LDKSignedRawInvoice this_arg_conv;
25831         this_arg_conv.inner = (void*)(this_arg & (~1));
25832         this_arg_conv.is_owned = false;
25833         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
25834         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25835         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25836         uint64_t ret_ref = (uint64_t)ret_var.inner;
25837         if (ret_var.is_owned) {
25838                 ret_ref |= 1;
25839         }
25840         return ret_ref;
25841 }
25842
25843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25844         LDKSignedRawInvoice this_arg_conv;
25845         this_arg_conv.inner = (void*)(this_arg & (~1));
25846         this_arg_conv.is_owned = false;
25847         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
25849         return ret_arr;
25850 }
25851
25852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25853         LDKSignedRawInvoice this_arg_conv;
25854         this_arg_conv.inner = (void*)(this_arg & (~1));
25855         this_arg_conv.is_owned = false;
25856         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
25857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25859         uint64_t ret_ref = (uint64_t)ret_var.inner;
25860         if (ret_var.is_owned) {
25861                 ret_ref |= 1;
25862         }
25863         return ret_ref;
25864 }
25865
25866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25867         LDKSignedRawInvoice this_arg_conv;
25868         this_arg_conv.inner = (void*)(this_arg & (~1));
25869         this_arg_conv.is_owned = false;
25870         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25871         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25872         return (uint64_t)ret_conv;
25873 }
25874
25875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25876         LDKSignedRawInvoice this_arg_conv;
25877         this_arg_conv.inner = (void*)(this_arg & (~1));
25878         this_arg_conv.is_owned = false;
25879         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
25880         return ret_val;
25881 }
25882
25883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25884         LDKRawInvoice this_arg_conv;
25885         this_arg_conv.inner = (void*)(this_arg & (~1));
25886         this_arg_conv.is_owned = false;
25887         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25888         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
25889         return ret_arr;
25890 }
25891
25892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25893         LDKRawInvoice this_arg_conv;
25894         this_arg_conv.inner = (void*)(this_arg & (~1));
25895         this_arg_conv.is_owned = false;
25896         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
25897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25899         uint64_t ret_ref = (uint64_t)ret_var.inner;
25900         if (ret_var.is_owned) {
25901                 ret_ref |= 1;
25902         }
25903         return ret_ref;
25904 }
25905
25906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
25907         LDKRawInvoice this_arg_conv;
25908         this_arg_conv.inner = (void*)(this_arg & (~1));
25909         this_arg_conv.is_owned = false;
25910         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
25911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25913         uint64_t ret_ref = (uint64_t)ret_var.inner;
25914         if (ret_var.is_owned) {
25915                 ret_ref |= 1;
25916         }
25917         return ret_ref;
25918 }
25919
25920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25921         LDKRawInvoice this_arg_conv;
25922         this_arg_conv.inner = (void*)(this_arg & (~1));
25923         this_arg_conv.is_owned = false;
25924         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
25925         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25926         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25927         uint64_t ret_ref = (uint64_t)ret_var.inner;
25928         if (ret_var.is_owned) {
25929                 ret_ref |= 1;
25930         }
25931         return ret_ref;
25932 }
25933
25934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25935         LDKRawInvoice this_arg_conv;
25936         this_arg_conv.inner = (void*)(this_arg & (~1));
25937         this_arg_conv.is_owned = false;
25938         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
25939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25941         uint64_t ret_ref = (uint64_t)ret_var.inner;
25942         if (ret_var.is_owned) {
25943                 ret_ref |= 1;
25944         }
25945         return ret_ref;
25946 }
25947
25948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25949         LDKRawInvoice this_arg_conv;
25950         this_arg_conv.inner = (void*)(this_arg & (~1));
25951         this_arg_conv.is_owned = false;
25952         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
25953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25955         uint64_t ret_ref = (uint64_t)ret_var.inner;
25956         if (ret_var.is_owned) {
25957                 ret_ref |= 1;
25958         }
25959         return ret_ref;
25960 }
25961
25962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25963         LDKRawInvoice this_arg_conv;
25964         this_arg_conv.inner = (void*)(this_arg & (~1));
25965         this_arg_conv.is_owned = false;
25966         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
25967         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25968         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25969         uint64_t ret_ref = (uint64_t)ret_var.inner;
25970         if (ret_var.is_owned) {
25971                 ret_ref |= 1;
25972         }
25973         return ret_ref;
25974 }
25975
25976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25977         LDKRawInvoice this_arg_conv;
25978         this_arg_conv.inner = (void*)(this_arg & (~1));
25979         this_arg_conv.is_owned = false;
25980         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25981         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
25982         return ret_arr;
25983 }
25984
25985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25986         LDKRawInvoice this_arg_conv;
25987         this_arg_conv.inner = (void*)(this_arg & (~1));
25988         this_arg_conv.is_owned = false;
25989         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
25990         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25991         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25992         uint64_t ret_ref = (uint64_t)ret_var.inner;
25993         if (ret_var.is_owned) {
25994                 ret_ref |= 1;
25995         }
25996         return ret_ref;
25997 }
25998
25999 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
26000         LDKRawInvoice this_arg_conv;
26001         this_arg_conv.inner = (void*)(this_arg & (~1));
26002         this_arg_conv.is_owned = false;
26003         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
26004         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26005         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26006         for (size_t o = 0; o < ret_var.datalen; o++) {
26007                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26008                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26009                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26010                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26011                 if (ret_conv_14_var.is_owned) {
26012                         ret_conv_14_ref |= 1;
26013                 }
26014                 ret_arr_ptr[o] = ret_conv_14_ref;
26015         }
26016         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26017         FREE(ret_var.data);
26018         return ret_arr;
26019 }
26020
26021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
26022         LDKRawInvoice this_arg_conv;
26023         this_arg_conv.inner = (void*)(this_arg & (~1));
26024         this_arg_conv.is_owned = false;
26025         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26026         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
26027         uint64_t ret_ref = (uint64_t)ret_copy;
26028         return ret_ref;
26029 }
26030
26031 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
26032         LDKRawInvoice this_arg_conv;
26033         this_arg_conv.inner = (void*)(this_arg & (~1));
26034         this_arg_conv.is_owned = false;
26035         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
26036         return ret_conv;
26037 }
26038
26039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
26040         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26041         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
26042         return (uint64_t)ret_conv;
26043 }
26044
26045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
26046         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26047         *ret_conv = PositiveTimestamp_from_system_time(time);
26048         return (uint64_t)ret_conv;
26049 }
26050
26051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
26052         LDKPositiveTimestamp this_arg_conv;
26053         this_arg_conv.inner = (void*)(this_arg & (~1));
26054         this_arg_conv.is_owned = false;
26055         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
26056         return ret_val;
26057 }
26058
26059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26060         LDKPositiveTimestamp this_arg_conv;
26061         this_arg_conv.inner = (void*)(this_arg & (~1));
26062         this_arg_conv.is_owned = false;
26063         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
26064         return ret_val;
26065 }
26066
26067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
26068         LDKInvoice this_arg_conv;
26069         this_arg_conv.inner = (void*)(this_arg & (~1));
26070         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26071         this_arg_conv = Invoice_clone(&this_arg_conv);
26072         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
26073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26075         uint64_t ret_ref = (uint64_t)ret_var.inner;
26076         if (ret_var.is_owned) {
26077                 ret_ref |= 1;
26078         }
26079         return ret_ref;
26080 }
26081
26082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
26083         LDKInvoice this_arg_conv;
26084         this_arg_conv.inner = (void*)(this_arg & (~1));
26085         this_arg_conv.is_owned = false;
26086         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
26087         *ret_conv = Invoice_check_signature(&this_arg_conv);
26088         return (uint64_t)ret_conv;
26089 }
26090
26091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
26092         LDKSignedRawInvoice signed_invoice_conv;
26093         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
26094         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
26095         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
26096         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
26097         *ret_conv = Invoice_from_signed(signed_invoice_conv);
26098         return (uint64_t)ret_conv;
26099 }
26100
26101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
26102         LDKInvoice this_arg_conv;
26103         this_arg_conv.inner = (void*)(this_arg & (~1));
26104         this_arg_conv.is_owned = false;
26105         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
26106         return ret_val;
26107 }
26108
26109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26110         LDKInvoice this_arg_conv;
26111         this_arg_conv.inner = (void*)(this_arg & (~1));
26112         this_arg_conv.is_owned = false;
26113         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26114         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
26115         return ret_arr;
26116 }
26117
26118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26119         LDKInvoice this_arg_conv;
26120         this_arg_conv.inner = (void*)(this_arg & (~1));
26121         this_arg_conv.is_owned = false;
26122         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26123         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
26124         return ret_arr;
26125 }
26126
26127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26128         LDKInvoice this_arg_conv;
26129         this_arg_conv.inner = (void*)(this_arg & (~1));
26130         this_arg_conv.is_owned = false;
26131         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
26133         return ret_arr;
26134 }
26135
26136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
26137         LDKInvoice this_arg_conv;
26138         this_arg_conv.inner = (void*)(this_arg & (~1));
26139         this_arg_conv.is_owned = false;
26140         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
26141         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26142         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26143         uint64_t ret_ref = (uint64_t)ret_var.inner;
26144         if (ret_var.is_owned) {
26145                 ret_ref |= 1;
26146         }
26147         return ret_ref;
26148 }
26149
26150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26151         LDKInvoice this_arg_conv;
26152         this_arg_conv.inner = (void*)(this_arg & (~1));
26153         this_arg_conv.is_owned = false;
26154         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26155         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
26156         return ret_arr;
26157 }
26158
26159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26160         LDKInvoice this_arg_conv;
26161         this_arg_conv.inner = (void*)(this_arg & (~1));
26162         this_arg_conv.is_owned = false;
26163         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
26164         return ret_val;
26165 }
26166
26167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
26168         LDKInvoice this_arg_conv;
26169         this_arg_conv.inner = (void*)(this_arg & (~1));
26170         this_arg_conv.is_owned = false;
26171         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
26172         return ret_val;
26173 }
26174
26175 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
26176         LDKInvoice this_arg_conv;
26177         this_arg_conv.inner = (void*)(this_arg & (~1));
26178         this_arg_conv.is_owned = false;
26179         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
26180         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26181         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26182         for (size_t o = 0; o < ret_var.datalen; o++) {
26183                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26184                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26185                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26186                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26187                 if (ret_conv_14_var.is_owned) {
26188                         ret_conv_14_ref |= 1;
26189                 }
26190                 ret_arr_ptr[o] = ret_conv_14_ref;
26191         }
26192         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26193         FREE(ret_var.data);
26194         return ret_arr;
26195 }
26196
26197 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
26198         LDKInvoice this_arg_conv;
26199         this_arg_conv.inner = (void*)(this_arg & (~1));
26200         this_arg_conv.is_owned = false;
26201         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
26202         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26203         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26204         for (size_t l = 0; l < ret_var.datalen; l++) {
26205                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
26206                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26207                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26208                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
26209                 if (ret_conv_11_var.is_owned) {
26210                         ret_conv_11_ref |= 1;
26211                 }
26212                 ret_arr_ptr[l] = ret_conv_11_ref;
26213         }
26214         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26215         FREE(ret_var.data);
26216         return ret_arr;
26217 }
26218
26219 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
26220         LDKInvoice this_arg_conv;
26221         this_arg_conv.inner = (void*)(this_arg & (~1));
26222         this_arg_conv.is_owned = false;
26223         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
26224         return ret_conv;
26225 }
26226
26227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
26228         LDKInvoice this_arg_conv;
26229         this_arg_conv.inner = (void*)(this_arg & (~1));
26230         this_arg_conv.is_owned = false;
26231         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26232         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
26233         uint64_t ret_ref = (uint64_t)ret_copy;
26234         return ret_ref;
26235 }
26236
26237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
26238         LDKStr description_conv = java_to_owned_str(env, description);
26239         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
26240         *ret_conv = Description_new(description_conv);
26241         return (uint64_t)ret_conv;
26242 }
26243
26244 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26245         LDKDescription this_arg_conv;
26246         this_arg_conv.inner = (void*)(this_arg & (~1));
26247         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26248         this_arg_conv = Description_clone(&this_arg_conv);
26249         LDKStr ret_str = Description_into_inner(this_arg_conv);
26250         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26251         Str_free(ret_str);
26252         return ret_conv;
26253 }
26254
26255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
26256         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26257         *ret_conv = ExpiryTime_from_seconds(seconds);
26258         return (uint64_t)ret_conv;
26259 }
26260
26261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
26262         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26263         *ret_conv = ExpiryTime_from_duration(duration);
26264         return (uint64_t)ret_conv;
26265 }
26266
26267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
26268         LDKExpiryTime this_arg_conv;
26269         this_arg_conv.inner = (void*)(this_arg & (~1));
26270         this_arg_conv.is_owned = false;
26271         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
26272         return ret_val;
26273 }
26274
26275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
26276         LDKExpiryTime this_arg_conv;
26277         this_arg_conv.inner = (void*)(this_arg & (~1));
26278         this_arg_conv.is_owned = false;
26279         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
26280         return ret_val;
26281 }
26282
26283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
26284         LDKRouteHint hops_conv;
26285         hops_conv.inner = (void*)(hops & (~1));
26286         hops_conv.is_owned = (hops & 1) || (hops == 0);
26287         hops_conv = RouteHint_clone(&hops_conv);
26288         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
26289         *ret_conv = PrivateRoute_new(hops_conv);
26290         return (uint64_t)ret_conv;
26291 }
26292
26293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26294         LDKPrivateRoute this_arg_conv;
26295         this_arg_conv.inner = (void*)(this_arg & (~1));
26296         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26297         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
26298         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
26299         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26300         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26301         uint64_t ret_ref = (uint64_t)ret_var.inner;
26302         if (ret_var.is_owned) {
26303                 ret_ref |= 1;
26304         }
26305         return ret_ref;
26306 }
26307
26308 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26309         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
26310         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
26311         return ret_conv;
26312 }
26313
26314 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26315         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
26316         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
26317         jboolean ret_val = CreationError_eq(a_conv, b_conv);
26318         return ret_val;
26319 }
26320
26321 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26322         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
26323         LDKStr ret_str = CreationError_to_str(o_conv);
26324         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26325         Str_free(ret_str);
26326         return ret_conv;
26327 }
26328
26329 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26330         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
26331         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
26332         return ret_conv;
26333 }
26334
26335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26336         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
26337         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
26338         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
26339         return ret_val;
26340 }
26341
26342 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26343         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
26344         LDKStr ret_str = SemanticError_to_str(o_conv);
26345         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26346         Str_free(ret_str);
26347         return ret_conv;
26348 }
26349
26350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26351         if ((this_ptr & 1) != 0) return;
26352         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
26353         FREE((void*)this_ptr);
26354         SignOrCreationError_free(this_ptr_conv);
26355 }
26356
26357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26358         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
26359         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26360         *ret_copy = SignOrCreationError_clone(orig_conv);
26361         uint64_t ret_ref = (uint64_t)ret_copy;
26362         return ret_ref;
26363 }
26364
26365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26366         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
26367         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
26368         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
26369         return ret_val;
26370 }
26371
26372 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26373         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
26374         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
26375         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26376         Str_free(ret_str);
26377         return ret_conv;
26378 }
26379
26380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description) {
26381         LDKChannelManager channelmanager_conv;
26382         channelmanager_conv.inner = (void*)(channelmanager & (~1));
26383         channelmanager_conv.is_owned = false;
26384         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26385         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26386                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26387                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26388         }
26389         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
26390         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
26391         LDKStr description_conv = java_to_owned_str(env, description);
26392         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26393         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
26394         return (uint64_t)ret_conv;
26395 }
26396
26397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26398         LDKStr s_conv = java_to_owned_str(env, s);
26399         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
26400         *ret_conv = SiPrefix_from_str(s_conv);
26401         return (uint64_t)ret_conv;
26402 }
26403
26404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26405         LDKStr s_conv = java_to_owned_str(env, s);
26406         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
26407         *ret_conv = Invoice_from_str(s_conv);
26408         return (uint64_t)ret_conv;
26409 }
26410
26411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26412         LDKStr s_conv = java_to_owned_str(env, s);
26413         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
26414         *ret_conv = SignedRawInvoice_from_str(s_conv);
26415         return (uint64_t)ret_conv;
26416 }
26417
26418 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26419         LDKInvoice o_conv;
26420         o_conv.inner = (void*)(o & (~1));
26421         o_conv.is_owned = false;
26422         LDKStr ret_str = Invoice_to_str(&o_conv);
26423         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26424         Str_free(ret_str);
26425         return ret_conv;
26426 }
26427
26428 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26429         LDKSignedRawInvoice o_conv;
26430         o_conv.inner = (void*)(o & (~1));
26431         o_conv.is_owned = false;
26432         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
26433         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26434         Str_free(ret_str);
26435         return ret_conv;
26436 }
26437
26438 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26439         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
26440         LDKStr ret_str = Currency_to_str(o_conv);
26441         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26442         Str_free(ret_str);
26443         return ret_conv;
26444 }
26445
26446 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26447         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
26448         LDKStr ret_str = SiPrefix_to_str(o_conv);
26449         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26450         Str_free(ret_str);
26451         return ret_conv;
26452 }
26453