Update auto-generated bindings
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
13 #include <assert.h>
14 // Always run a, then assert it is true:
15 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
16 // Assert a is true or do nothing
17 #define CHECK(a) DO_ASSERT(a)
18
19 void __attribute__((constructor)) debug_log_version() {
20         if (check_get_ldk_version() == NULL)
21                 DEBUG_PRINT("LDK version did not match the header we built against\n");
22         if (check_get_ldk_bindings_version() == NULL)
23                 DEBUG_PRINT("LDK C Bindings version did not match the header we built against\n");
24         DEBUG_PRINT("Loaded LDK-Java Bindings with LDK %s and LDK-C-Bindings %s\n", check_get_ldk_version(), check_get_ldk_bindings_version());
25 }
26
27 // Running a leak check across all the allocations and frees of the JDK is a mess,
28 // so instead we implement our own naive leak checker here, relying on the -wrap
29 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
30 // and free'd in Rust or C across the generated bindings shared library.
31 #include <threads.h>
32 #include <execinfo.h>
33
34 #include <unistd.h>
35 static mtx_t allocation_mtx;
36
37 void __attribute__((constructor)) init_mtx() {
38         DO_ASSERT(mtx_init(&allocation_mtx, mtx_plain) == thrd_success);
39 }
40
41 #define BT_MAX 128
42 typedef struct allocation {
43         struct allocation* next;
44         void* ptr;
45         const char* struct_name;
46         void* bt[BT_MAX];
47         int bt_len;
48         unsigned long alloc_len;
49 } allocation;
50 static allocation* allocation_ll = NULL;
51
52 void* __real_malloc(size_t len);
53 void* __real_calloc(size_t nmemb, size_t len);
54 static void new_allocation(void* res, const char* struct_name, size_t len) {
55         allocation* new_alloc = __real_malloc(sizeof(allocation));
56         new_alloc->ptr = res;
57         new_alloc->struct_name = struct_name;
58         new_alloc->bt_len = backtrace(new_alloc->bt, BT_MAX);
59         new_alloc->alloc_len = len;
60         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
61         new_alloc->next = allocation_ll;
62         allocation_ll = new_alloc;
63         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
64 }
65 static void* MALLOC(size_t len, const char* struct_name) {
66         void* res = __real_malloc(len);
67         new_allocation(res, struct_name, len);
68         return res;
69 }
70 void __real_free(void* ptr);
71 static void alloc_freed(void* ptr) {
72         allocation* p = NULL;
73         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
74         allocation* it = allocation_ll;
75         while (it->ptr != ptr) {
76                 p = it; it = it->next;
77                 if (it == NULL) {
78                         DEBUG_PRINT("Tried to free unknown pointer %p at:\n", ptr);
79                         void* bt[BT_MAX];
80                         int bt_len = backtrace(bt, BT_MAX);
81                         backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
82                         DEBUG_PRINT("\n\n");
83                         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
84                         return; // addrsan should catch malloc-unknown and print more info than we have
85                 }
86         }
87         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
88         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
89         DO_ASSERT(it->ptr == ptr);
90         __real_free(it);
91 }
92 static void FREE(void* ptr) {
93         if ((uint64_t)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
94         alloc_freed(ptr);
95         __real_free(ptr);
96 }
97
98 void* __wrap_malloc(size_t len) {
99         void* res = __real_malloc(len);
100         new_allocation(res, "malloc call", len);
101         return res;
102 }
103 void* __wrap_calloc(size_t nmemb, size_t len) {
104         void* res = __real_calloc(nmemb, len);
105         new_allocation(res, "calloc call", len);
106         return res;
107 }
108 void __wrap_free(void* ptr) {
109         if (ptr == NULL) return;
110         alloc_freed(ptr);
111         __real_free(ptr);
112 }
113
114 void* __real_realloc(void* ptr, size_t newlen);
115 void* __wrap_realloc(void* ptr, size_t len) {
116         if (ptr != NULL) alloc_freed(ptr);
117         void* res = __real_realloc(ptr, len);
118         new_allocation(res, "realloc call", len);
119         return res;
120 }
121 void __wrap_reallocarray(void* ptr, size_t new_sz) {
122         // Rust doesn't seem to use reallocarray currently
123         DO_ASSERT(false);
124 }
125
126 void __attribute__((destructor)) check_leaks() {
127         unsigned long alloc_count = 0;
128         unsigned long alloc_size = 0;
129         DEBUG_PRINT("The following LDK-allocated blocks still remain.\n");
130         DEBUG_PRINT("Note that this is only accurate if System.gc(); System.runFinalization()\n");
131         DEBUG_PRINT("was called prior to exit after all LDK objects were out of scope.\n");
132         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
133                 DEBUG_PRINT("%s %p (%lu bytes) remains:\n", a->struct_name, a->ptr, a->alloc_len);
134                 backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
135                 DEBUG_PRINT("\n\n");
136                 alloc_count++;
137                 alloc_size += a->alloc_len;
138         }
139         DEBUG_PRINT("%lu allocations remained for %lu bytes.\n", alloc_count, alloc_size);
140         DEBUG_PRINT("Note that this is only accurate if System.gc(); System.runFinalization()\n");
141         DEBUG_PRINT("was called prior to exit after all LDK objects were out of scope.\n");
142 }
143
144 static jmethodID ordinal_meth = NULL;
145 static jmethodID slicedef_meth = NULL;
146 static jclass slicedef_cls = NULL;
147 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
148         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
149         CHECK(ordinal_meth != NULL);
150         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
151         CHECK(slicedef_meth != NULL);
152         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
153         CHECK(slicedef_cls != NULL);
154 }
155
156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
157         return *((bool*)ptr);
158 }
159 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
160         return *((long*)ptr);
161 }
162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
163         FREE((void*)ptr);
164 }
165 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
166         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
167         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
168         return ret_arr;
169 }
170 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
171         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
172         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
173         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
174         return ret_arr;
175 }
176 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
177         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
178         vec->datalen = (*env)->GetArrayLength(env, bytes);
179         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
180         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
181         return (uint64_t)vec;
182 }
183 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
184         LDKTransaction *txdata = (LDKTransaction*)ptr;
185         LDKu8slice slice;
186         slice.data = txdata->data;
187         slice.datalen = txdata->datalen;
188         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
189 }
190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
191         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
192         txdata->datalen = (*env)->GetArrayLength(env, bytes);
193         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
194         txdata->data_is_owned = false;
195         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
196         return (uint64_t)txdata;
197 }
198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
199         LDKTransaction *tx = (LDKTransaction*)ptr;
200         tx->data_is_owned = true;
201         Transaction_free(*tx);
202         FREE((void*)ptr);
203 }
204 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
205         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
206         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
207         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
208         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
209         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
210         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
211         return (uint64_t)vec->datalen;
212 }
213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
214         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
215         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
216         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
217         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
218         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
219         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
220         vec->data = NULL;
221         vec->datalen = 0;
222         return (uint64_t)vec;
223 }
224
225 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
226 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
227 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
228 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
229
230 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
231 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
232 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
233
234 typedef jlongArray int64_tArray;
235 typedef jbyteArray int8_tArray;
236
237 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
238         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
239         char* conv_buf = MALLOC(len + 1, "str conv buf");
240         memcpy(conv_buf, chars, len);
241         conv_buf[len] = 0;
242         jstring ret = (*env)->NewStringUTF(env, conv_buf);
243         FREE(conv_buf);
244         return ret;
245 }
246 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
247         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
248         char* newchars = MALLOC(str_len + 1, "String chars");
249         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
250         memcpy(newchars, jchars, str_len);
251         newchars[str_len] = 0;
252         (*env)->ReleaseStringUTFChars(env, str, jchars);
253         LDKStr res = {
254                 .chars = newchars,
255                 .len = str_len,
256                 .chars_is_owned = true
257         };
258         return res;
259 }
260
261 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
262         return str_ref_to_java(env, "v0.0.99.1-7-gf7a4eb8-dirty", strlen("v0.0.99.1-7-gf7a4eb8-dirty"));
263 }
264 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
265         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
266 }
267 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
268         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
269 }
270 static jclass arr_of_B_clz = NULL;
271 static jclass arr_of_J_clz = NULL;
272 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
273         arr_of_B_clz = (*env)->FindClass(env, "[B");
274         CHECK(arr_of_B_clz != NULL);
275         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
276         arr_of_J_clz = (*env)->FindClass(env, "[J");
277         CHECK(arr_of_J_clz != NULL);
278         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
279 }
280 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
281 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
282         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
283                 case 0: return LDKAccessError_UnknownChain;
284                 case 1: return LDKAccessError_UnknownTx;
285         }
286         abort();
287 }
288 static jclass AccessError_class = NULL;
289 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
290 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
291 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
292         AccessError_class = (*env)->NewGlobalRef(env, clz);
293         CHECK(AccessError_class != NULL);
294         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
295         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
296         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
297         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
298 }
299 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
300         switch (val) {
301                 case LDKAccessError_UnknownChain:
302                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
303                 case LDKAccessError_UnknownTx:
304                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
305                 default: abort();
306         }
307 }
308
309 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
310         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
311                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
312                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
313         }
314         abort();
315 }
316 static jclass ChannelMonitorUpdateErr_class = NULL;
317 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
318 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
319 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
320         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
321         CHECK(ChannelMonitorUpdateErr_class != NULL);
322         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
323         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
324         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
325         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
326 }
327 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
328         switch (val) {
329                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
330                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
331                 case LDKChannelMonitorUpdateErr_PermanentFailure:
332                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
333                 default: abort();
334         }
335 }
336
337 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
338         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
339                 case 0: return LDKConfirmationTarget_Background;
340                 case 1: return LDKConfirmationTarget_Normal;
341                 case 2: return LDKConfirmationTarget_HighPriority;
342         }
343         abort();
344 }
345 static jclass ConfirmationTarget_class = NULL;
346 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
347 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
348 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
349 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
350         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
351         CHECK(ConfirmationTarget_class != NULL);
352         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
353         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
354         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
355         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
356         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
357         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
358 }
359 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
360         switch (val) {
361                 case LDKConfirmationTarget_Background:
362                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
363                 case LDKConfirmationTarget_Normal:
364                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
365                 case LDKConfirmationTarget_HighPriority:
366                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
367                 default: abort();
368         }
369 }
370
371 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
372         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
373                 case 0: return LDKCreationError_DescriptionTooLong;
374                 case 1: return LDKCreationError_RouteTooLong;
375                 case 2: return LDKCreationError_TimestampOutOfBounds;
376                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
377         }
378         abort();
379 }
380 static jclass CreationError_class = NULL;
381 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
382 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
383 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
384 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
385 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
386         CreationError_class = (*env)->NewGlobalRef(env, clz);
387         CHECK(CreationError_class != NULL);
388         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
389         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
390         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
391         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
392         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
393         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
394         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
395         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
396 }
397 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
398         switch (val) {
399                 case LDKCreationError_DescriptionTooLong:
400                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
401                 case LDKCreationError_RouteTooLong:
402                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
403                 case LDKCreationError_TimestampOutOfBounds:
404                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
405                 case LDKCreationError_ExpiryTimeOutOfBounds:
406                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
407                 default: abort();
408         }
409 }
410
411 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
412         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
413                 case 0: return LDKCurrency_Bitcoin;
414                 case 1: return LDKCurrency_BitcoinTestnet;
415                 case 2: return LDKCurrency_Regtest;
416                 case 3: return LDKCurrency_Simnet;
417                 case 4: return LDKCurrency_Signet;
418         }
419         abort();
420 }
421 static jclass Currency_class = NULL;
422 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
423 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
424 static jfieldID Currency_LDKCurrency_Regtest = NULL;
425 static jfieldID Currency_LDKCurrency_Simnet = NULL;
426 static jfieldID Currency_LDKCurrency_Signet = NULL;
427 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
428         Currency_class = (*env)->NewGlobalRef(env, clz);
429         CHECK(Currency_class != NULL);
430         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
431         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
432         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
433         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
434         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
435         CHECK(Currency_LDKCurrency_Regtest != NULL);
436         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
437         CHECK(Currency_LDKCurrency_Simnet != NULL);
438         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
439         CHECK(Currency_LDKCurrency_Signet != NULL);
440 }
441 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
442         switch (val) {
443                 case LDKCurrency_Bitcoin:
444                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
445                 case LDKCurrency_BitcoinTestnet:
446                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
447                 case LDKCurrency_Regtest:
448                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
449                 case LDKCurrency_Simnet:
450                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
451                 case LDKCurrency_Signet:
452                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
453                 default: abort();
454         }
455 }
456
457 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
458         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
459                 case 0: return LDKIOError_NotFound;
460                 case 1: return LDKIOError_PermissionDenied;
461                 case 2: return LDKIOError_ConnectionRefused;
462                 case 3: return LDKIOError_ConnectionReset;
463                 case 4: return LDKIOError_ConnectionAborted;
464                 case 5: return LDKIOError_NotConnected;
465                 case 6: return LDKIOError_AddrInUse;
466                 case 7: return LDKIOError_AddrNotAvailable;
467                 case 8: return LDKIOError_BrokenPipe;
468                 case 9: return LDKIOError_AlreadyExists;
469                 case 10: return LDKIOError_WouldBlock;
470                 case 11: return LDKIOError_InvalidInput;
471                 case 12: return LDKIOError_InvalidData;
472                 case 13: return LDKIOError_TimedOut;
473                 case 14: return LDKIOError_WriteZero;
474                 case 15: return LDKIOError_Interrupted;
475                 case 16: return LDKIOError_Other;
476                 case 17: return LDKIOError_UnexpectedEof;
477         }
478         abort();
479 }
480 static jclass IOError_class = NULL;
481 static jfieldID IOError_LDKIOError_NotFound = NULL;
482 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
483 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
484 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
485 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
486 static jfieldID IOError_LDKIOError_NotConnected = NULL;
487 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
488 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
489 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
490 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
491 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
492 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
493 static jfieldID IOError_LDKIOError_InvalidData = NULL;
494 static jfieldID IOError_LDKIOError_TimedOut = NULL;
495 static jfieldID IOError_LDKIOError_WriteZero = NULL;
496 static jfieldID IOError_LDKIOError_Interrupted = NULL;
497 static jfieldID IOError_LDKIOError_Other = NULL;
498 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
499 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
500         IOError_class = (*env)->NewGlobalRef(env, clz);
501         CHECK(IOError_class != NULL);
502         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
503         CHECK(IOError_LDKIOError_NotFound != NULL);
504         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
505         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
506         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
507         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
508         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
509         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
510         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
511         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
512         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
513         CHECK(IOError_LDKIOError_NotConnected != NULL);
514         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
515         CHECK(IOError_LDKIOError_AddrInUse != NULL);
516         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
517         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
518         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
519         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
520         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
521         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
522         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
523         CHECK(IOError_LDKIOError_WouldBlock != NULL);
524         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
525         CHECK(IOError_LDKIOError_InvalidInput != NULL);
526         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
527         CHECK(IOError_LDKIOError_InvalidData != NULL);
528         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
529         CHECK(IOError_LDKIOError_TimedOut != NULL);
530         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
531         CHECK(IOError_LDKIOError_WriteZero != NULL);
532         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
533         CHECK(IOError_LDKIOError_Interrupted != NULL);
534         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
535         CHECK(IOError_LDKIOError_Other != NULL);
536         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
537         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
538 }
539 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
540         switch (val) {
541                 case LDKIOError_NotFound:
542                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
543                 case LDKIOError_PermissionDenied:
544                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
545                 case LDKIOError_ConnectionRefused:
546                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
547                 case LDKIOError_ConnectionReset:
548                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
549                 case LDKIOError_ConnectionAborted:
550                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
551                 case LDKIOError_NotConnected:
552                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
553                 case LDKIOError_AddrInUse:
554                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
555                 case LDKIOError_AddrNotAvailable:
556                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
557                 case LDKIOError_BrokenPipe:
558                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
559                 case LDKIOError_AlreadyExists:
560                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
561                 case LDKIOError_WouldBlock:
562                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
563                 case LDKIOError_InvalidInput:
564                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
565                 case LDKIOError_InvalidData:
566                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
567                 case LDKIOError_TimedOut:
568                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
569                 case LDKIOError_WriteZero:
570                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
571                 case LDKIOError_Interrupted:
572                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
573                 case LDKIOError_Other:
574                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
575                 case LDKIOError_UnexpectedEof:
576                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
577                 default: abort();
578         }
579 }
580
581 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
582         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
583                 case 0: return LDKLevel_Trace;
584                 case 1: return LDKLevel_Debug;
585                 case 2: return LDKLevel_Info;
586                 case 3: return LDKLevel_Warn;
587                 case 4: return LDKLevel_Error;
588         }
589         abort();
590 }
591 static jclass Level_class = NULL;
592 static jfieldID Level_LDKLevel_Trace = NULL;
593 static jfieldID Level_LDKLevel_Debug = NULL;
594 static jfieldID Level_LDKLevel_Info = NULL;
595 static jfieldID Level_LDKLevel_Warn = NULL;
596 static jfieldID Level_LDKLevel_Error = NULL;
597 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
598         Level_class = (*env)->NewGlobalRef(env, clz);
599         CHECK(Level_class != NULL);
600         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
601         CHECK(Level_LDKLevel_Trace != NULL);
602         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
603         CHECK(Level_LDKLevel_Debug != NULL);
604         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
605         CHECK(Level_LDKLevel_Info != NULL);
606         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
607         CHECK(Level_LDKLevel_Warn != NULL);
608         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
609         CHECK(Level_LDKLevel_Error != NULL);
610 }
611 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
612         switch (val) {
613                 case LDKLevel_Trace:
614                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
615                 case LDKLevel_Debug:
616                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
617                 case LDKLevel_Info:
618                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
619                 case LDKLevel_Warn:
620                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
621                 case LDKLevel_Error:
622                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
623                 default: abort();
624         }
625 }
626
627 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
628         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
629                 case 0: return LDKNetwork_Bitcoin;
630                 case 1: return LDKNetwork_Testnet;
631                 case 2: return LDKNetwork_Regtest;
632                 case 3: return LDKNetwork_Signet;
633         }
634         abort();
635 }
636 static jclass Network_class = NULL;
637 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
638 static jfieldID Network_LDKNetwork_Testnet = NULL;
639 static jfieldID Network_LDKNetwork_Regtest = NULL;
640 static jfieldID Network_LDKNetwork_Signet = NULL;
641 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
642         Network_class = (*env)->NewGlobalRef(env, clz);
643         CHECK(Network_class != NULL);
644         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
645         CHECK(Network_LDKNetwork_Bitcoin != NULL);
646         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
647         CHECK(Network_LDKNetwork_Testnet != NULL);
648         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
649         CHECK(Network_LDKNetwork_Regtest != NULL);
650         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
651         CHECK(Network_LDKNetwork_Signet != NULL);
652 }
653 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
654         switch (val) {
655                 case LDKNetwork_Bitcoin:
656                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
657                 case LDKNetwork_Testnet:
658                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
659                 case LDKNetwork_Regtest:
660                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
661                 case LDKNetwork_Signet:
662                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
663                 default: abort();
664         }
665 }
666
667 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
668         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
669                 case 0: return LDKSecp256k1Error_IncorrectSignature;
670                 case 1: return LDKSecp256k1Error_InvalidMessage;
671                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
672                 case 3: return LDKSecp256k1Error_InvalidSignature;
673                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
674                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
675                 case 6: return LDKSecp256k1Error_InvalidTweak;
676                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
677                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
678         }
679         abort();
680 }
681 static jclass Secp256k1Error_class = NULL;
682 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
683 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
684 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
685 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
686 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
687 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
688 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
689 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
690 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
691 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
692         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
693         CHECK(Secp256k1Error_class != NULL);
694         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
695         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
696         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
697         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
698         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
699         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
700         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
701         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
702         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
703         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
704         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
705         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
706         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
707         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
708         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
709         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
710         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
711         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
712 }
713 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
714         switch (val) {
715                 case LDKSecp256k1Error_IncorrectSignature:
716                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
717                 case LDKSecp256k1Error_InvalidMessage:
718                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
719                 case LDKSecp256k1Error_InvalidPublicKey:
720                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
721                 case LDKSecp256k1Error_InvalidSignature:
722                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
723                 case LDKSecp256k1Error_InvalidSecretKey:
724                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
725                 case LDKSecp256k1Error_InvalidRecoveryId:
726                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
727                 case LDKSecp256k1Error_InvalidTweak:
728                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
729                 case LDKSecp256k1Error_TweakCheckFailed:
730                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
731                 case LDKSecp256k1Error_NotEnoughMemory:
732                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
733                 default: abort();
734         }
735 }
736
737 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
738         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
739                 case 0: return LDKSemanticError_NoPaymentHash;
740                 case 1: return LDKSemanticError_MultiplePaymentHashes;
741                 case 2: return LDKSemanticError_NoDescription;
742                 case 3: return LDKSemanticError_MultipleDescriptions;
743                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
744                 case 5: return LDKSemanticError_InvalidFeatures;
745                 case 6: return LDKSemanticError_InvalidRecoveryId;
746                 case 7: return LDKSemanticError_InvalidSignature;
747         }
748         abort();
749 }
750 static jclass SemanticError_class = NULL;
751 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
752 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
753 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
754 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
755 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
756 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
757 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
758 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
759 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
760         SemanticError_class = (*env)->NewGlobalRef(env, clz);
761         CHECK(SemanticError_class != NULL);
762         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
763         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
764         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
765         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
766         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
767         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
768         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
769         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
770         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
771         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
772         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
773         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
774         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
775         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
776         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
777         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
778 }
779 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
780         switch (val) {
781                 case LDKSemanticError_NoPaymentHash:
782                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
783                 case LDKSemanticError_MultiplePaymentHashes:
784                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
785                 case LDKSemanticError_NoDescription:
786                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
787                 case LDKSemanticError_MultipleDescriptions:
788                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
789                 case LDKSemanticError_MultiplePaymentSecrets:
790                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
791                 case LDKSemanticError_InvalidFeatures:
792                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
793                 case LDKSemanticError_InvalidRecoveryId:
794                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
795                 case LDKSemanticError_InvalidSignature:
796                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
797                 default: abort();
798         }
799 }
800
801 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
802         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
803                 case 0: return LDKSiPrefix_Milli;
804                 case 1: return LDKSiPrefix_Micro;
805                 case 2: return LDKSiPrefix_Nano;
806                 case 3: return LDKSiPrefix_Pico;
807         }
808         abort();
809 }
810 static jclass SiPrefix_class = NULL;
811 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
812 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
813 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
814 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
815 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
816         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
817         CHECK(SiPrefix_class != NULL);
818         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
819         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
820         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
821         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
822         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
823         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
824         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
825         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
826 }
827 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
828         switch (val) {
829                 case LDKSiPrefix_Milli:
830                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
831                 case LDKSiPrefix_Micro:
832                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
833                 case LDKSiPrefix_Nano:
834                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
835                 case LDKSiPrefix_Pico:
836                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
837                 default: abort();
838         }
839 }
840
841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
842         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
843         ret->datalen = (*env)->GetArrayLength(env, elems);
844         if (ret->datalen == 0) {
845                 ret->data = NULL;
846         } else {
847                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
848                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
849                 for (size_t i = 0; i < ret->datalen; i++) {
850                         ret->data[i] = java_elems[i];
851                 }
852                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
853         }
854         return (uint64_t)ret;
855 }
856 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
857         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
858         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
859         return ret;
860 }
861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
862         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
863 }
864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
865         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
866         CHECK(val->result_ok);
867         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
868         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
869         return res_arr;
870 }
871 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
872         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
873         CHECK(!val->result_ok);
874         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
875         return err_conv;
876 }
877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
878         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
879 }
880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
881         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
882         CHECK(val->result_ok);
883         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
884         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
885         return res_arr;
886 }
887 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
888         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
889         CHECK(!val->result_ok);
890         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
891         return err_conv;
892 }
893 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
894         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
895 }
896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
897         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
898         CHECK(val->result_ok);
899         LDKTxCreationKeys res_var = (*val->contents.result);
900         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
901         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
902         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
903         return res_ref;
904 }
905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
906         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
907         CHECK(!val->result_ok);
908         LDKDecodeError err_var = (*val->contents.err);
909         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
910         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
911         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
912         return err_ref;
913 }
914 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
915         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
916 }
917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
918         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
919         CHECK(val->result_ok);
920         LDKChannelPublicKeys res_var = (*val->contents.result);
921         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
922         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
923         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
924         return res_ref;
925 }
926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
927         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
928         CHECK(!val->result_ok);
929         LDKDecodeError err_var = (*val->contents.err);
930         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
931         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
932         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
933         return err_ref;
934 }
935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
936         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
937 }
938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
939         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
940         CHECK(val->result_ok);
941         LDKTxCreationKeys res_var = (*val->contents.result);
942         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
943         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
944         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
945         return res_ref;
946 }
947 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
948         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
949         CHECK(!val->result_ok);
950         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
951         return err_conv;
952 }
953 static jclass LDKCOption_u32Z_Some_class = NULL;
954 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
955 static jclass LDKCOption_u32Z_None_class = NULL;
956 static jmethodID LDKCOption_u32Z_None_meth = NULL;
957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
958         LDKCOption_u32Z_Some_class =
959                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
960         CHECK(LDKCOption_u32Z_Some_class != NULL);
961         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
962         CHECK(LDKCOption_u32Z_Some_meth != NULL);
963         LDKCOption_u32Z_None_class =
964                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
965         CHECK(LDKCOption_u32Z_None_class != NULL);
966         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
967         CHECK(LDKCOption_u32Z_None_meth != NULL);
968 }
969 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
970         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
971         switch(obj->tag) {
972                 case LDKCOption_u32Z_Some: {
973                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
974                 }
975                 case LDKCOption_u32Z_None: {
976                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
977                 }
978                 default: abort();
979         }
980 }
981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
982         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
983 }
984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
985         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
986         CHECK(val->result_ok);
987         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
988         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
989         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
990         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
991         return res_ref;
992 }
993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
994         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
995         CHECK(!val->result_ok);
996         LDKDecodeError err_var = (*val->contents.err);
997         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
998         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
999         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1000         return err_ref;
1001 }
1002 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1003         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
1004 }
1005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1006         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1007         CHECK(val->result_ok);
1008         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
1009         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1010         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1011         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1012         return res_ref;
1013 }
1014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1015         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1016         CHECK(!val->result_ok);
1017         LDKDecodeError err_var = (*val->contents.err);
1018         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1021         return err_ref;
1022 }
1023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1024         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
1025 }
1026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1027         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1028         CHECK(val->result_ok);
1029         LDKChannelTransactionParameters res_var = (*val->contents.result);
1030         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1031         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1032         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1033         return res_ref;
1034 }
1035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1036         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1037         CHECK(!val->result_ok);
1038         LDKDecodeError err_var = (*val->contents.err);
1039         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1040         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1041         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1042         return err_ref;
1043 }
1044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1045         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1046 }
1047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1048         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1049         CHECK(val->result_ok);
1050         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
1051         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1052         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1053         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1054         return res_ref;
1055 }
1056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1057         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1058         CHECK(!val->result_ok);
1059         LDKDecodeError err_var = (*val->contents.err);
1060         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1061         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1062         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1063         return err_ref;
1064 }
1065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1066         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1067 }
1068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1069         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1070         CHECK(val->result_ok);
1071         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
1072         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1073         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1074         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1075         return res_ref;
1076 }
1077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1078         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1079         CHECK(!val->result_ok);
1080         LDKDecodeError err_var = (*val->contents.err);
1081         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1082         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1083         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1084         return err_ref;
1085 }
1086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1087         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1088 }
1089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1090         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1091         CHECK(val->result_ok);
1092         LDKCommitmentTransaction res_var = (*val->contents.result);
1093         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1094         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1095         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1096         return res_ref;
1097 }
1098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1099         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1100         CHECK(!val->result_ok);
1101         LDKDecodeError err_var = (*val->contents.err);
1102         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1103         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1104         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1105         return err_ref;
1106 }
1107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1108         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
1109 }
1110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1111         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1112         CHECK(val->result_ok);
1113         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1114         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1115         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1116         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1117         return res_ref;
1118 }
1119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1120         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1121         CHECK(!val->result_ok);
1122         return *val->contents.err;
1123 }
1124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1125         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1126 }
1127 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1128         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1129         CHECK(val->result_ok);
1130         LDKCVec_SignatureZ res_var = (*val->contents.result);
1131         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1132         ;
1133         for (size_t i = 0; i < res_var.datalen; i++) {
1134                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1135                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1136                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1137         }
1138         return res_arr;
1139 }
1140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1141         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1142         CHECK(!val->result_ok);
1143         return *val->contents.err;
1144 }
1145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1146         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1147 }
1148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1149         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1150         CHECK(val->result_ok);
1151         return *val->contents.result;
1152 }
1153 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1154         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1155         CHECK(!val->result_ok);
1156         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1157         return err_conv;
1158 }
1159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1160         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1161 }
1162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1163         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1164         CHECK(val->result_ok);
1165         LDKRouteHop res_var = (*val->contents.result);
1166         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1167         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1168         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1169         return res_ref;
1170 }
1171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1172         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1173         CHECK(!val->result_ok);
1174         LDKDecodeError err_var = (*val->contents.err);
1175         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1176         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1177         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1178         return err_ref;
1179 }
1180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1181         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1182         ret->datalen = (*env)->GetArrayLength(env, elems);
1183         if (ret->datalen == 0) {
1184                 ret->data = NULL;
1185         } else {
1186                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1187                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1188                 for (size_t i = 0; i < ret->datalen; i++) {
1189                         int64_t arr_elem = java_elems[i];
1190                         LDKRouteHop arr_elem_conv;
1191                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1192                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1193                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1194                         ret->data[i] = arr_elem_conv;
1195                 }
1196                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1197         }
1198         return (uint64_t)ret;
1199 }
1200 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1201         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1202         for (size_t i = 0; i < ret.datalen; i++) {
1203                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1204         }
1205         return ret;
1206 }
1207 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1208         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1209         for (size_t i = 0; i < ret.datalen; i++) {
1210                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1211         }
1212         return ret;
1213 }
1214 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1215         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1216 }
1217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1218         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1219         CHECK(val->result_ok);
1220         LDKRoute res_var = (*val->contents.result);
1221         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1224         return res_ref;
1225 }
1226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1227         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1228         CHECK(!val->result_ok);
1229         LDKDecodeError err_var = (*val->contents.err);
1230         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1231         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1232         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1233         return err_ref;
1234 }
1235 static jclass LDKCOption_u64Z_Some_class = NULL;
1236 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1237 static jclass LDKCOption_u64Z_None_class = NULL;
1238 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1240         LDKCOption_u64Z_Some_class =
1241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1242         CHECK(LDKCOption_u64Z_Some_class != NULL);
1243         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1244         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1245         LDKCOption_u64Z_None_class =
1246                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1247         CHECK(LDKCOption_u64Z_None_class != NULL);
1248         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1249         CHECK(LDKCOption_u64Z_None_meth != NULL);
1250 }
1251 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1252         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1253         switch(obj->tag) {
1254                 case LDKCOption_u64Z_Some: {
1255                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1256                 }
1257                 case LDKCOption_u64Z_None: {
1258                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1259                 }
1260                 default: abort();
1261         }
1262 }
1263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1264         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1265         ret->datalen = (*env)->GetArrayLength(env, elems);
1266         if (ret->datalen == 0) {
1267                 ret->data = NULL;
1268         } else {
1269                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1270                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1271                 for (size_t i = 0; i < ret->datalen; i++) {
1272                         int64_t arr_elem = java_elems[i];
1273                         LDKChannelDetails arr_elem_conv;
1274                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1275                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1276                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1277                         ret->data[i] = arr_elem_conv;
1278                 }
1279                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1280         }
1281         return (uint64_t)ret;
1282 }
1283 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1284         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1285         for (size_t i = 0; i < ret.datalen; i++) {
1286                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1287         }
1288         return ret;
1289 }
1290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1291         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1292         ret->datalen = (*env)->GetArrayLength(env, elems);
1293         if (ret->datalen == 0) {
1294                 ret->data = NULL;
1295         } else {
1296                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1297                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1298                 for (size_t i = 0; i < ret->datalen; i++) {
1299                         int64_t arr_elem = java_elems[i];
1300                         LDKRouteHint arr_elem_conv;
1301                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1302                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1303                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1304                         ret->data[i] = arr_elem_conv;
1305                 }
1306                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1307         }
1308         return (uint64_t)ret;
1309 }
1310 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1311         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1312         for (size_t i = 0; i < ret.datalen; i++) {
1313                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1314         }
1315         return ret;
1316 }
1317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1318         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1319 }
1320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1321         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1322         CHECK(val->result_ok);
1323         LDKRoute res_var = (*val->contents.result);
1324         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1325         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1326         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1327         return res_ref;
1328 }
1329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1330         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1331         CHECK(!val->result_ok);
1332         LDKLightningError err_var = (*val->contents.err);
1333         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1334         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1335         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1336         return err_ref;
1337 }
1338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1339         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1340 }
1341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1342         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1343         CHECK(val->result_ok);
1344         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1345         return (uint64_t)res_ref;
1346 }
1347 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1348         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1349         CHECK(!val->result_ok);
1350         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1351         return err_conv;
1352 }
1353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1354         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1355         ret->a = a;
1356         LDKTransaction b_ref;
1357         b_ref.datalen = (*env)->GetArrayLength(env, b);
1358         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1359         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1360         b_ref.data_is_owned = false;
1361         ret->b = b_ref;
1362         return (uint64_t)ret;
1363 }
1364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1365         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1366         return tuple->a;
1367 }
1368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1369         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1370         LDKTransaction b_var = tuple->b;
1371         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1372         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1373         return b_arr;
1374 }
1375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1376         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1377         ret->datalen = (*env)->GetArrayLength(env, elems);
1378         if (ret->datalen == 0) {
1379                 ret->data = NULL;
1380         } else {
1381                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1382                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1383                 for (size_t i = 0; i < ret->datalen; i++) {
1384                         int64_t arr_elem = java_elems[i];
1385                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1386                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1387                         ret->data[i] = arr_elem_conv;
1388                 }
1389                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1390         }
1391         return (uint64_t)ret;
1392 }
1393 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1394         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1395         for (size_t i = 0; i < ret.datalen; i++) {
1396                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1397         }
1398         return ret;
1399 }
1400 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1401         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1402         for (size_t i = 0; i < ret.datalen; i++) {
1403                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1404         }
1405         return ret;
1406 }
1407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1408         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1409 }
1410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1411         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1412         CHECK(val->result_ok);
1413         return *val->contents.result;
1414 }
1415 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1416         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1417         CHECK(!val->result_ok);
1418         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1419         return err_conv;
1420 }
1421 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1422 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1423 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1424 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1426         LDKMonitorEvent_HTLCEvent_class =
1427                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1428         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1429         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1430         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1431         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1433         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1434         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1435         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1436 }
1437 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1438         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1439         switch(obj->tag) {
1440                 case LDKMonitorEvent_HTLCEvent: {
1441                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1442                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1443                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1444                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1445                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1446                 }
1447                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1448                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1449                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1450                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1451                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1452                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1453                 }
1454                 default: abort();
1455         }
1456 }
1457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1458         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1459         ret->datalen = (*env)->GetArrayLength(env, elems);
1460         if (ret->datalen == 0) {
1461                 ret->data = NULL;
1462         } else {
1463                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1464                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1465                 for (size_t i = 0; i < ret->datalen; i++) {
1466                         int64_t arr_elem = java_elems[i];
1467                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1468                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1469                         ret->data[i] = arr_elem_conv;
1470                 }
1471                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1472         }
1473         return (uint64_t)ret;
1474 }
1475 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1476         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1477         for (size_t i = 0; i < ret.datalen; i++) {
1478                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1479         }
1480         return ret;
1481 }
1482 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1483 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1484 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1485 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1487         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1488                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1489         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1490         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1491         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1492         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1493                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1494         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1495         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1496         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1497 }
1498 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1499         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1500         switch(obj->tag) {
1501                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1502                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1503                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1504                 }
1505                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1506                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1507                 }
1508                 default: abort();
1509         }
1510 }
1511 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1512 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1513 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1514 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1515 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1516 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1518         LDKSpendableOutputDescriptor_StaticOutput_class =
1519                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1520         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1521         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1522         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1523         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1524                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1525         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1526         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1527         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1528         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1529                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1530         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1531         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1532         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1533 }
1534 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1535         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1536         switch(obj->tag) {
1537                 case LDKSpendableOutputDescriptor_StaticOutput: {
1538                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1539                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1540                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1541                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1542                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1543                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1544                 }
1545                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1546                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1547                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1548                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1549                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1550                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1551                 }
1552                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1553                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1554                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1555                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1556                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1557                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1558                 }
1559                 default: abort();
1560         }
1561 }
1562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1563         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1564         ret->datalen = (*env)->GetArrayLength(env, elems);
1565         if (ret->datalen == 0) {
1566                 ret->data = NULL;
1567         } else {
1568                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1569                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1570                 for (size_t i = 0; i < ret->datalen; i++) {
1571                         int64_t arr_elem = java_elems[i];
1572                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1573                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1574                         ret->data[i] = arr_elem_conv;
1575                 }
1576                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1577         }
1578         return (uint64_t)ret;
1579 }
1580 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1581         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1582         for (size_t i = 0; i < ret.datalen; i++) {
1583                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1584         }
1585         return ret;
1586 }
1587 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1588 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1589 static jclass LDKErrorAction_IgnoreError_class = NULL;
1590 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1591 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1592 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1593 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1594 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1596         LDKErrorAction_DisconnectPeer_class =
1597                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1598         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1599         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1600         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1601         LDKErrorAction_IgnoreError_class =
1602                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1603         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1604         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1605         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1606         LDKErrorAction_IgnoreAndLog_class =
1607                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1608         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1609         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1610         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1611         LDKErrorAction_SendErrorMessage_class =
1612                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1613         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1614         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1615         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1616 }
1617 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1618         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1619         switch(obj->tag) {
1620                 case LDKErrorAction_DisconnectPeer: {
1621                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1622                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1623                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1624                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1625                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1626                 }
1627                 case LDKErrorAction_IgnoreError: {
1628                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1629                 }
1630                 case LDKErrorAction_IgnoreAndLog: {
1631                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1632                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1633                 }
1634                 case LDKErrorAction_SendErrorMessage: {
1635                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1636                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1637                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1638                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1639                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1640                 }
1641                 default: abort();
1642         }
1643 }
1644 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1645 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1646 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1647 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1648 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1649 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1651         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1652                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1653         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1654         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1655         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1656         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1657                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1658         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1659         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1660         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1661         LDKHTLCFailChannelUpdate_NodeFailure_class =
1662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1663         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1664         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1665         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1666 }
1667 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1668         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1669         switch(obj->tag) {
1670                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1671                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1672                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1673                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1674                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1675                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1676                 }
1677                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1678                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1679                 }
1680                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1681                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1682                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1683                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1684                 }
1685                 default: abort();
1686         }
1687 }
1688 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1689 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1690 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1691 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1692 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1693 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1694 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1695 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1696 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1697 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1698 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1699 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1700 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1701 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1702 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1703 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1704 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1705 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1706 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1707 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1708 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1709 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1710 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1711 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1712 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1713 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1714 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1715 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1716 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1717 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1718 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1719 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1720 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1721 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1722 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1723 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1724 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1725 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1726 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1727 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1729         LDKMessageSendEvent_SendAcceptChannel_class =
1730                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1731         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1732         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1733         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1734         LDKMessageSendEvent_SendOpenChannel_class =
1735                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1736         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1737         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1738         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1739         LDKMessageSendEvent_SendFundingCreated_class =
1740                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1741         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1742         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1743         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1744         LDKMessageSendEvent_SendFundingSigned_class =
1745                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1746         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1747         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1748         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1749         LDKMessageSendEvent_SendFundingLocked_class =
1750                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1751         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1752         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1753         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1754         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1755                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1756         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1757         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1758         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1759         LDKMessageSendEvent_UpdateHTLCs_class =
1760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1761         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1762         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1763         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1764         LDKMessageSendEvent_SendRevokeAndACK_class =
1765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1766         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1767         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1768         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1769         LDKMessageSendEvent_SendClosingSigned_class =
1770                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1771         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1772         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1773         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1774         LDKMessageSendEvent_SendShutdown_class =
1775                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1776         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1777         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1778         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1779         LDKMessageSendEvent_SendChannelReestablish_class =
1780                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1781         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1782         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1783         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1784         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1785                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1786         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1787         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1788         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1789         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1790                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1791         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1792         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1793         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1794         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1795                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1796         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1797         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1798         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1799         LDKMessageSendEvent_SendChannelUpdate_class =
1800                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1801         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1802         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1803         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1804         LDKMessageSendEvent_HandleError_class =
1805                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1806         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1807         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1808         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1809         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1810                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1811         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1812         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1813         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1814         LDKMessageSendEvent_SendChannelRangeQuery_class =
1815                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1816         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1817         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1818         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1819         LDKMessageSendEvent_SendShortIdsQuery_class =
1820                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1821         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1822         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1823         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1824         LDKMessageSendEvent_SendReplyChannelRange_class =
1825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1826         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1827         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1828         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1829 }
1830 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1831         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1832         switch(obj->tag) {
1833                 case LDKMessageSendEvent_SendAcceptChannel: {
1834                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1835                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1836                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1837                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1838                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1839                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1840                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1841                 }
1842                 case LDKMessageSendEvent_SendOpenChannel: {
1843                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1844                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1845                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1846                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1847                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1848                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1849                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1850                 }
1851                 case LDKMessageSendEvent_SendFundingCreated: {
1852                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1853                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1854                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1855                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1856                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1857                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1858                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1859                 }
1860                 case LDKMessageSendEvent_SendFundingSigned: {
1861                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1862                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1863                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1864                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1865                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1866                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1867                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1868                 }
1869                 case LDKMessageSendEvent_SendFundingLocked: {
1870                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1871                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1872                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1873                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1874                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1875                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1876                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1877                 }
1878                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1879                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1880                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1881                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1882                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1883                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1884                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1885                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1886                 }
1887                 case LDKMessageSendEvent_UpdateHTLCs: {
1888                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1889                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1890                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1891                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1892                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1893                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1894                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1895                 }
1896                 case LDKMessageSendEvent_SendRevokeAndACK: {
1897                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1898                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1899                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1900                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1901                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1902                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1903                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1904                 }
1905                 case LDKMessageSendEvent_SendClosingSigned: {
1906                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1907                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1908                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1909                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1910                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1911                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1912                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1913                 }
1914                 case LDKMessageSendEvent_SendShutdown: {
1915                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1916                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1917                         LDKShutdown msg_var = obj->send_shutdown.msg;
1918                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1919                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1920                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1921                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1922                 }
1923                 case LDKMessageSendEvent_SendChannelReestablish: {
1924                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1925                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1926                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1927                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1928                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1929                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1930                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1931                 }
1932                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1933                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1934                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1935                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1936                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1937                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1938                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1939                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1940                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1941                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1942                 }
1943                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1944                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1945                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1946                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1947                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1948                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1949                 }
1950                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1951                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1952                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1953                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1954                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1955                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1956                 }
1957                 case LDKMessageSendEvent_SendChannelUpdate: {
1958                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1959                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1960                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1961                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1962                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1963                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1964                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1965                 }
1966                 case LDKMessageSendEvent_HandleError: {
1967                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1968                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1969                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1970                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1971                 }
1972                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1973                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1974                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1975                 }
1976                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1977                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1978                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1979                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1980                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1981                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1982                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1983                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1984                 }
1985                 case LDKMessageSendEvent_SendShortIdsQuery: {
1986                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1987                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1988                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1989                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1990                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1991                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1992                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1993                 }
1994                 case LDKMessageSendEvent_SendReplyChannelRange: {
1995                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1996                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1997                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1998                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1999                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2000                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
2001                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2002                 }
2003                 default: abort();
2004         }
2005 }
2006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2007         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
2008         ret->datalen = (*env)->GetArrayLength(env, elems);
2009         if (ret->datalen == 0) {
2010                 ret->data = NULL;
2011         } else {
2012                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
2013                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2014                 for (size_t i = 0; i < ret->datalen; i++) {
2015                         int64_t arr_elem = java_elems[i];
2016                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
2017                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
2018                         ret->data[i] = arr_elem_conv;
2019                 }
2020                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2021         }
2022         return (uint64_t)ret;
2023 }
2024 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2025         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2026         for (size_t i = 0; i < ret.datalen; i++) {
2027                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2028         }
2029         return ret;
2030 }
2031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2032         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
2033 }
2034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2035         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2036         CHECK(val->result_ok);
2037         LDKInitFeatures res_var = (*val->contents.result);
2038         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2039         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2040         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2041         return res_ref;
2042 }
2043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2044         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2045         CHECK(!val->result_ok);
2046         LDKDecodeError err_var = (*val->contents.err);
2047         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2048         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2049         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2050         return err_ref;
2051 }
2052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2053         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
2054 }
2055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2056         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2057         CHECK(val->result_ok);
2058         LDKNodeFeatures res_var = (*val->contents.result);
2059         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2060         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2061         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2062         return res_ref;
2063 }
2064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2065         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2066         CHECK(!val->result_ok);
2067         LDKDecodeError err_var = (*val->contents.err);
2068         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2069         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2070         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2071         return err_ref;
2072 }
2073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2074         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
2075 }
2076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2077         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2078         CHECK(val->result_ok);
2079         LDKChannelFeatures res_var = (*val->contents.result);
2080         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2081         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2082         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2083         return res_ref;
2084 }
2085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2086         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2087         CHECK(!val->result_ok);
2088         LDKDecodeError err_var = (*val->contents.err);
2089         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2090         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2091         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2092         return err_ref;
2093 }
2094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2095         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
2096 }
2097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2098         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2099         CHECK(val->result_ok);
2100         LDKInvoiceFeatures res_var = (*val->contents.result);
2101         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2102         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2103         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2104         return res_ref;
2105 }
2106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2107         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2108         CHECK(!val->result_ok);
2109         LDKDecodeError err_var = (*val->contents.err);
2110         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2111         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2112         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2113         return err_ref;
2114 }
2115 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2116         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2117 }
2118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2119         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2120         CHECK(val->result_ok);
2121         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2122         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2123         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2124         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2125         return res_ref;
2126 }
2127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2128         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2129         CHECK(!val->result_ok);
2130         LDKDecodeError err_var = (*val->contents.err);
2131         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2132         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2133         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2134         return err_ref;
2135 }
2136 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2137         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2138 }
2139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2140         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2141         CHECK(val->result_ok);
2142         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2143         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2144         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2145         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2146         return res_ref;
2147 }
2148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2149         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2150         CHECK(!val->result_ok);
2151         LDKDecodeError err_var = (*val->contents.err);
2152         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2153         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2154         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2155         return err_ref;
2156 }
2157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2158         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2159 }
2160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2161         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2162         CHECK(val->result_ok);
2163         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2164         return res_ref;
2165 }
2166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2167         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2168         CHECK(!val->result_ok);
2169         LDKDecodeError err_var = (*val->contents.err);
2170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2172         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2173         return err_ref;
2174 }
2175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2176         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2177         LDKSignature a_ref;
2178         CHECK((*env)->GetArrayLength(env, a) == 64);
2179         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2180         ret->a = a_ref;
2181         LDKCVec_SignatureZ b_constr;
2182         b_constr.datalen = (*env)->GetArrayLength(env, b);
2183         if (b_constr.datalen > 0)
2184                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2185         else
2186                 b_constr.data = NULL;
2187         for (size_t i = 0; i < b_constr.datalen; i++) {
2188                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2189                 LDKSignature b_conv_8_ref;
2190                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2191                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2192                 b_constr.data[i] = b_conv_8_ref;
2193         }
2194         ret->b = b_constr;
2195         return (uint64_t)ret;
2196 }
2197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2198         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2199         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2200         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2201         return a_arr;
2202 }
2203 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2204         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2205         LDKCVec_SignatureZ b_var = tuple->b;
2206         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2207         ;
2208         for (size_t i = 0; i < b_var.datalen; i++) {
2209                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2210                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2211                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2212         }
2213         return b_arr;
2214 }
2215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2216         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2217 }
2218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2219         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2220         CHECK(val->result_ok);
2221         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2222         return res_ref;
2223 }
2224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2225         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2226         CHECK(!val->result_ok);
2227         return *val->contents.err;
2228 }
2229 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2230         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2231 }
2232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2233         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2234         CHECK(val->result_ok);
2235         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2236         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2237         return res_arr;
2238 }
2239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2240         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2241         CHECK(!val->result_ok);
2242         return *val->contents.err;
2243 }
2244 typedef struct LDKBaseSign_JCalls {
2245         atomic_size_t refcnt;
2246         JavaVM *vm;
2247         jweak o;
2248         jmethodID get_per_commitment_point_meth;
2249         jmethodID release_commitment_secret_meth;
2250         jmethodID channel_keys_id_meth;
2251         jmethodID sign_counterparty_commitment_meth;
2252         jmethodID sign_holder_commitment_and_htlcs_meth;
2253         jmethodID sign_justice_revoked_output_meth;
2254         jmethodID sign_justice_revoked_htlc_meth;
2255         jmethodID sign_counterparty_htlc_transaction_meth;
2256         jmethodID sign_closing_transaction_meth;
2257         jmethodID sign_channel_announcement_meth;
2258         jmethodID ready_channel_meth;
2259 } LDKBaseSign_JCalls;
2260 static void LDKBaseSign_JCalls_free(void* this_arg) {
2261         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2262         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2263                 JNIEnv *env;
2264                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2265                 if (get_jenv_res == JNI_EDETACHED) {
2266                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2267                 } else {
2268                         DO_ASSERT(get_jenv_res == JNI_OK);
2269                 }
2270                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2271                 if (get_jenv_res == JNI_EDETACHED) {
2272                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2273                 }
2274                 FREE(j_calls);
2275         }
2276 }
2277 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2278         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2279         JNIEnv *env;
2280         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2281         if (get_jenv_res == JNI_EDETACHED) {
2282                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2283         } else {
2284                 DO_ASSERT(get_jenv_res == JNI_OK);
2285         }
2286         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2287         CHECK(obj != NULL);
2288         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2289         if ((*env)->ExceptionCheck(env)) {
2290                 (*env)->ExceptionDescribe(env);
2291                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2292         }
2293         LDKPublicKey ret_ref;
2294         CHECK((*env)->GetArrayLength(env, ret) == 33);
2295         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2296         if (get_jenv_res == JNI_EDETACHED) {
2297                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2298         }
2299         return ret_ref;
2300 }
2301 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2302         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2303         JNIEnv *env;
2304         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2305         if (get_jenv_res == JNI_EDETACHED) {
2306                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2307         } else {
2308                 DO_ASSERT(get_jenv_res == JNI_OK);
2309         }
2310         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2311         CHECK(obj != NULL);
2312         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2313         if ((*env)->ExceptionCheck(env)) {
2314                 (*env)->ExceptionDescribe(env);
2315                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2316         }
2317         LDKThirtyTwoBytes ret_ref;
2318         CHECK((*env)->GetArrayLength(env, ret) == 32);
2319         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2320         if (get_jenv_res == JNI_EDETACHED) {
2321                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2322         }
2323         return ret_ref;
2324 }
2325 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2326         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2327         JNIEnv *env;
2328         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2329         if (get_jenv_res == JNI_EDETACHED) {
2330                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2331         } else {
2332                 DO_ASSERT(get_jenv_res == JNI_OK);
2333         }
2334         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2335         CHECK(obj != NULL);
2336         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2337         if ((*env)->ExceptionCheck(env)) {
2338                 (*env)->ExceptionDescribe(env);
2339                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2340         }
2341         LDKThirtyTwoBytes ret_ref;
2342         CHECK((*env)->GetArrayLength(env, ret) == 32);
2343         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2344         if (get_jenv_res == JNI_EDETACHED) {
2345                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2346         }
2347         return ret_ref;
2348 }
2349 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2350         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2351         JNIEnv *env;
2352         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2353         if (get_jenv_res == JNI_EDETACHED) {
2354                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2355         } else {
2356                 DO_ASSERT(get_jenv_res == JNI_OK);
2357         }
2358         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2359         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2360         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2361         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2362         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2363         if (commitment_tx_var.is_owned) {
2364                 commitment_tx_ref |= 1;
2365         }
2366         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2367         CHECK(obj != NULL);
2368         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2369         if ((*env)->ExceptionCheck(env)) {
2370                 (*env)->ExceptionDescribe(env);
2371                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2372         }
2373         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2374         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2375         if (get_jenv_res == JNI_EDETACHED) {
2376                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2377         }
2378         return ret_conv;
2379 }
2380 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2381         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2382         JNIEnv *env;
2383         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2384         if (get_jenv_res == JNI_EDETACHED) {
2385                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2386         } else {
2387                 DO_ASSERT(get_jenv_res == JNI_OK);
2388         }
2389         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2390         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2391         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2392         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2393         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2394         if (commitment_tx_var.is_owned) {
2395                 commitment_tx_ref |= 1;
2396         }
2397         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2398         CHECK(obj != NULL);
2399         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2400         if ((*env)->ExceptionCheck(env)) {
2401                 (*env)->ExceptionDescribe(env);
2402                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2403         }
2404         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2405         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2406         if (get_jenv_res == JNI_EDETACHED) {
2407                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2408         }
2409         return ret_conv;
2410 }
2411 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]) {
2412         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2413         JNIEnv *env;
2414         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2415         if (get_jenv_res == JNI_EDETACHED) {
2416                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2417         } else {
2418                 DO_ASSERT(get_jenv_res == JNI_OK);
2419         }
2420         LDKTransaction justice_tx_var = justice_tx;
2421         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2422         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2423         Transaction_free(justice_tx_var);
2424         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2425         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2426         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2427         CHECK(obj != NULL);
2428         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);
2429         if ((*env)->ExceptionCheck(env)) {
2430                 (*env)->ExceptionDescribe(env);
2431                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2432         }
2433         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2434         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2435         if (get_jenv_res == JNI_EDETACHED) {
2436                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2437         }
2438         return ret_conv;
2439 }
2440 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) {
2441         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2442         JNIEnv *env;
2443         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2444         if (get_jenv_res == JNI_EDETACHED) {
2445                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2446         } else {
2447                 DO_ASSERT(get_jenv_res == JNI_OK);
2448         }
2449         LDKTransaction justice_tx_var = justice_tx;
2450         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2451         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2452         Transaction_free(justice_tx_var);
2453         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2454         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2455         LDKHTLCOutputInCommitment htlc_var = *htlc;
2456         htlc_var = HTLCOutputInCommitment_clone(htlc);
2457         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2458         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2459         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2460         if (htlc_var.is_owned) {
2461                 htlc_ref |= 1;
2462         }
2463         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2464         CHECK(obj != NULL);
2465         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);
2466         if ((*env)->ExceptionCheck(env)) {
2467                 (*env)->ExceptionDescribe(env);
2468                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2469         }
2470         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2471         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2472         if (get_jenv_res == JNI_EDETACHED) {
2473                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2474         }
2475         return ret_conv;
2476 }
2477 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) {
2478         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2479         JNIEnv *env;
2480         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2481         if (get_jenv_res == JNI_EDETACHED) {
2482                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2483         } else {
2484                 DO_ASSERT(get_jenv_res == JNI_OK);
2485         }
2486         LDKTransaction htlc_tx_var = htlc_tx;
2487         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2488         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2489         Transaction_free(htlc_tx_var);
2490         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2491         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2492         LDKHTLCOutputInCommitment htlc_var = *htlc;
2493         htlc_var = HTLCOutputInCommitment_clone(htlc);
2494         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2495         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2496         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2497         if (htlc_var.is_owned) {
2498                 htlc_ref |= 1;
2499         }
2500         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2501         CHECK(obj != NULL);
2502         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);
2503         if ((*env)->ExceptionCheck(env)) {
2504                 (*env)->ExceptionDescribe(env);
2505                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2506         }
2507         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2508         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2509         if (get_jenv_res == JNI_EDETACHED) {
2510                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2511         }
2512         return ret_conv;
2513 }
2514 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2515         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2516         JNIEnv *env;
2517         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2518         if (get_jenv_res == JNI_EDETACHED) {
2519                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2520         } else {
2521                 DO_ASSERT(get_jenv_res == JNI_OK);
2522         }
2523         LDKTransaction closing_tx_var = closing_tx;
2524         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2525         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2526         Transaction_free(closing_tx_var);
2527         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2528         CHECK(obj != NULL);
2529         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2530         if ((*env)->ExceptionCheck(env)) {
2531                 (*env)->ExceptionDescribe(env);
2532                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2533         }
2534         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2535         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2536         if (get_jenv_res == JNI_EDETACHED) {
2537                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2538         }
2539         return ret_conv;
2540 }
2541 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2542         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2543         JNIEnv *env;
2544         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2545         if (get_jenv_res == JNI_EDETACHED) {
2546                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2547         } else {
2548                 DO_ASSERT(get_jenv_res == JNI_OK);
2549         }
2550         LDKUnsignedChannelAnnouncement msg_var = *msg;
2551         msg_var = UnsignedChannelAnnouncement_clone(msg);
2552         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2553         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2554         uint64_t msg_ref = (uint64_t)msg_var.inner;
2555         if (msg_var.is_owned) {
2556                 msg_ref |= 1;
2557         }
2558         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2559         CHECK(obj != NULL);
2560         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2561         if ((*env)->ExceptionCheck(env)) {
2562                 (*env)->ExceptionDescribe(env);
2563                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2564         }
2565         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2566         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2567         if (get_jenv_res == JNI_EDETACHED) {
2568                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2569         }
2570         return ret_conv;
2571 }
2572 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2573         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2574         JNIEnv *env;
2575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2576         if (get_jenv_res == JNI_EDETACHED) {
2577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2578         } else {
2579                 DO_ASSERT(get_jenv_res == JNI_OK);
2580         }
2581         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2582         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2583         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2584         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2585         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2586         if (channel_parameters_var.is_owned) {
2587                 channel_parameters_ref |= 1;
2588         }
2589         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2590         CHECK(obj != NULL);
2591         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2592         if ((*env)->ExceptionCheck(env)) {
2593                 (*env)->ExceptionDescribe(env);
2594                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2595         }
2596         if (get_jenv_res == JNI_EDETACHED) {
2597                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2598         }
2599 }
2600 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2601         jclass c = (*env)->GetObjectClass(env, o);
2602         CHECK(c != NULL);
2603         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2604         atomic_init(&calls->refcnt, 1);
2605         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2606         calls->o = (*env)->NewWeakGlobalRef(env, o);
2607         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2608         CHECK(calls->get_per_commitment_point_meth != NULL);
2609         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2610         CHECK(calls->release_commitment_secret_meth != NULL);
2611         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2612         CHECK(calls->channel_keys_id_meth != NULL);
2613         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2614         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2615         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2616         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2617         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2618         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2619         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2620         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2621         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2622         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2623         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2624         CHECK(calls->sign_closing_transaction_meth != NULL);
2625         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2626         CHECK(calls->sign_channel_announcement_meth != NULL);
2627         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2628         CHECK(calls->ready_channel_meth != NULL);
2629
2630         LDKChannelPublicKeys pubkeys_conv;
2631         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2632         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2633         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2634
2635         LDKBaseSign ret = {
2636                 .this_arg = (void*) calls,
2637                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2638                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2639                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2640                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2641                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2642                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2643                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2644                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2645                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2646                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2647                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2648                 .free = LDKBaseSign_JCalls_free,
2649                 .pubkeys = pubkeys_conv,
2650                 .set_pubkeys = NULL,
2651         };
2652         return ret;
2653 }
2654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2655         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2656         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2657         return (uint64_t)res_ptr;
2658 }
2659 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) {
2660         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2661         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2662         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2663         return ret_arr;
2664 }
2665
2666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2667         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2668         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2669         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2670         return ret_arr;
2671 }
2672
2673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2674         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2675         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2676         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2677         return ret_arr;
2678 }
2679
2680 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) {
2681         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2682         LDKCommitmentTransaction commitment_tx_conv;
2683         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2684         commitment_tx_conv.is_owned = false;
2685         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2686         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2687         return (uint64_t)ret_conv;
2688 }
2689
2690 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) {
2691         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2692         LDKHolderCommitmentTransaction commitment_tx_conv;
2693         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2694         commitment_tx_conv.is_owned = false;
2695         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2696         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2697         return (uint64_t)ret_conv;
2698 }
2699
2700 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) {
2701         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2702         LDKTransaction justice_tx_ref;
2703         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2704         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2705         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2706         justice_tx_ref.data_is_owned = true;
2707         unsigned char per_commitment_key_arr[32];
2708         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2709         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2710         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2711         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2712         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2713         return (uint64_t)ret_conv;
2714 }
2715
2716 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) {
2717         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2718         LDKTransaction justice_tx_ref;
2719         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2720         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2721         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2722         justice_tx_ref.data_is_owned = true;
2723         unsigned char per_commitment_key_arr[32];
2724         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2725         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2726         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2727         LDKHTLCOutputInCommitment htlc_conv;
2728         htlc_conv.inner = (void*)(htlc & (~1));
2729         htlc_conv.is_owned = false;
2730         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2731         *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);
2732         return (uint64_t)ret_conv;
2733 }
2734
2735 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) {
2736         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2737         LDKTransaction htlc_tx_ref;
2738         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2739         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2740         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2741         htlc_tx_ref.data_is_owned = true;
2742         LDKPublicKey per_commitment_point_ref;
2743         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2744         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2745         LDKHTLCOutputInCommitment htlc_conv;
2746         htlc_conv.inner = (void*)(htlc & (~1));
2747         htlc_conv.is_owned = false;
2748         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2749         *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);
2750         return (uint64_t)ret_conv;
2751 }
2752
2753 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) {
2754         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2755         LDKTransaction closing_tx_ref;
2756         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2757         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2758         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2759         closing_tx_ref.data_is_owned = true;
2760         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2761         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2762         return (uint64_t)ret_conv;
2763 }
2764
2765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2766         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2767         LDKUnsignedChannelAnnouncement msg_conv;
2768         msg_conv.inner = (void*)(msg & (~1));
2769         msg_conv.is_owned = false;
2770         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2771         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2772         return (uint64_t)ret_conv;
2773 }
2774
2775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2776         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2777         LDKChannelTransactionParameters channel_parameters_conv;
2778         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2779         channel_parameters_conv.is_owned = false;
2780         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2781 }
2782
2783 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2784         if (this_arg->set_pubkeys != NULL)
2785                 this_arg->set_pubkeys(this_arg);
2786         return this_arg->pubkeys;
2787 }
2788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2789         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2790         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2791         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2792         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2793         uint64_t ret_ref = (uint64_t)ret_var.inner;
2794         if (ret_var.is_owned) {
2795                 ret_ref |= 1;
2796         }
2797         return ret_ref;
2798 }
2799
2800 typedef struct LDKSign_JCalls {
2801         atomic_size_t refcnt;
2802         JavaVM *vm;
2803         jweak o;
2804         LDKBaseSign_JCalls* BaseSign;
2805         jmethodID write_meth;
2806 } LDKSign_JCalls;
2807 static void LDKSign_JCalls_free(void* this_arg) {
2808         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2809         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2810                 JNIEnv *env;
2811                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2812                 if (get_jenv_res == JNI_EDETACHED) {
2813                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2814                 } else {
2815                         DO_ASSERT(get_jenv_res == JNI_OK);
2816                 }
2817                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2818                 if (get_jenv_res == JNI_EDETACHED) {
2819                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2820                 }
2821                 FREE(j_calls);
2822         }
2823 }
2824 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2825         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2826         JNIEnv *env;
2827         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2828         if (get_jenv_res == JNI_EDETACHED) {
2829                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2830         } else {
2831                 DO_ASSERT(get_jenv_res == JNI_OK);
2832         }
2833         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2834         CHECK(obj != NULL);
2835         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2836         if ((*env)->ExceptionCheck(env)) {
2837                 (*env)->ExceptionDescribe(env);
2838                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2839         }
2840         LDKCVec_u8Z ret_ref;
2841         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2842         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2843         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2844         if (get_jenv_res == JNI_EDETACHED) {
2845                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2846         }
2847         return ret_ref;
2848 }
2849 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2850         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2851         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2852         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2853 }
2854 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2855         jclass c = (*env)->GetObjectClass(env, o);
2856         CHECK(c != NULL);
2857         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2858         atomic_init(&calls->refcnt, 1);
2859         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2860         calls->o = (*env)->NewWeakGlobalRef(env, o);
2861         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2862         CHECK(calls->write_meth != NULL);
2863
2864         LDKChannelPublicKeys pubkeys_conv;
2865         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2866         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2867         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2868
2869         LDKSign ret = {
2870                 .this_arg = (void*) calls,
2871                 .write = write_LDKSign_jcall,
2872                 .cloned = LDKSign_JCalls_cloned,
2873                 .free = LDKSign_JCalls_free,
2874                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2875         };
2876         calls->BaseSign = ret.BaseSign.this_arg;
2877         return ret;
2878 }
2879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2880         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2881         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2882         return (uint64_t)res_ptr;
2883 }
2884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
2885         LDKSign *inp = (LDKSign *)(arg & ~1);
2886         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
2887         DO_ASSERT((res_ptr & 1) == 0);
2888         return (int64_t)(res_ptr | 1);
2889 }
2890 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2891         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2892         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2893         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2894         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2895         CVec_u8Z_free(ret_var);
2896         return ret_arr;
2897 }
2898
2899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2900         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2901 }
2902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2903         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2904         CHECK(val->result_ok);
2905         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2906         *ret = Sign_clone(&(*val->contents.result));
2907         return (uint64_t)ret;
2908 }
2909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2910         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2911         CHECK(!val->result_ok);
2912         LDKDecodeError err_var = (*val->contents.err);
2913         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2914         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2915         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2916         return err_ref;
2917 }
2918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2919         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2920 }
2921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2922         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2923         CHECK(val->result_ok);
2924         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2925         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2926         return es_arr;
2927 }
2928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2929         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2930         CHECK(!val->result_ok);
2931         return *val->contents.err;
2932 }
2933 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2934         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2935         for (size_t i = 0; i < ret.datalen; i++) {
2936                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2937         }
2938         return ret;
2939 }
2940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2941         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2942 }
2943 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2944         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2945         CHECK(val->result_ok);
2946         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2947         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2948         ;
2949         for (size_t i = 0; i < res_var.datalen; i++) {
2950                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2951                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2952                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2953                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2954         }
2955         return res_arr;
2956 }
2957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2958         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2959         CHECK(!val->result_ok);
2960         return *val->contents.err;
2961 }
2962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2963         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2964 }
2965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2966         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2967         CHECK(val->result_ok);
2968         LDKInMemorySigner res_var = (*val->contents.result);
2969         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2970         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2971         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2972         return res_ref;
2973 }
2974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2975         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2976         CHECK(!val->result_ok);
2977         LDKDecodeError err_var = (*val->contents.err);
2978         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2979         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2980         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2981         return err_ref;
2982 }
2983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2984         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2985         ret->datalen = (*env)->GetArrayLength(env, elems);
2986         if (ret->datalen == 0) {
2987                 ret->data = NULL;
2988         } else {
2989                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2990                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2991                 for (size_t i = 0; i < ret->datalen; i++) {
2992                         int64_t arr_elem = java_elems[i];
2993                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2994                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2995                         ret->data[i] = arr_elem_conv;
2996                 }
2997                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2998         }
2999         return (uint64_t)ret;
3000 }
3001 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3002         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3003         for (size_t i = 0; i < ret.datalen; i++) {
3004                 ret.data[i] = TxOut_clone(&orig->data[i]);
3005         }
3006         return ret;
3007 }
3008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3009         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3010 }
3011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3012         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3013         CHECK(val->result_ok);
3014         LDKTransaction res_var = (*val->contents.result);
3015         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3016         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3017         return res_arr;
3018 }
3019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3020         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3021         CHECK(!val->result_ok);
3022         return *val->contents.err;
3023 }
3024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3025         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3026         LDKThirtyTwoBytes a_ref;
3027         CHECK((*env)->GetArrayLength(env, a) == 32);
3028         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3029         ret->a = a_ref;
3030         LDKChannelMonitor b_conv;
3031         b_conv.inner = (void*)(b & (~1));
3032         b_conv.is_owned = (b & 1) || (b == 0);
3033         b_conv = ChannelMonitor_clone(&b_conv);
3034         ret->b = b_conv;
3035         return (uint64_t)ret;
3036 }
3037 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3038         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
3039         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3040         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3041         return a_arr;
3042 }
3043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3044         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
3045         LDKChannelMonitor b_var = tuple->b;
3046         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3047         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3048         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3049         return b_ref;
3050 }
3051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3052         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
3053         ret->datalen = (*env)->GetArrayLength(env, elems);
3054         if (ret->datalen == 0) {
3055                 ret->data = NULL;
3056         } else {
3057                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
3058                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3059                 for (size_t i = 0; i < ret->datalen; i++) {
3060                         int64_t arr_elem = java_elems[i];
3061                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
3062                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
3063                         ret->data[i] = arr_elem_conv;
3064                 }
3065                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3066         }
3067         return (uint64_t)ret;
3068 }
3069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3070         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
3071 }
3072 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3073         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3074         CHECK(val->result_ok);
3075         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3076         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
3077         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3078         for (size_t i = 0; i < res_var.datalen; i++) {
3079                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
3080                 res_arr_ptr[i] = res_conv_34_ref;
3081         }
3082         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3083         return res_arr;
3084 }
3085 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3086         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3087         CHECK(!val->result_ok);
3088         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3089         return err_conv;
3090 }
3091 static jclass LDKCOption_u16Z_Some_class = NULL;
3092 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3093 static jclass LDKCOption_u16Z_None_class = NULL;
3094 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3096         LDKCOption_u16Z_Some_class =
3097                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3098         CHECK(LDKCOption_u16Z_Some_class != NULL);
3099         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3100         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3101         LDKCOption_u16Z_None_class =
3102                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3103         CHECK(LDKCOption_u16Z_None_class != NULL);
3104         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3105         CHECK(LDKCOption_u16Z_None_meth != NULL);
3106 }
3107 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3108         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3109         switch(obj->tag) {
3110                 case LDKCOption_u16Z_Some: {
3111                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3112                 }
3113                 case LDKCOption_u16Z_None: {
3114                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3115                 }
3116                 default: abort();
3117         }
3118 }
3119 static jclass LDKAPIError_APIMisuseError_class = NULL;
3120 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3121 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3122 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3123 static jclass LDKAPIError_RouteError_class = NULL;
3124 static jmethodID LDKAPIError_RouteError_meth = NULL;
3125 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3126 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3127 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3128 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3130         LDKAPIError_APIMisuseError_class =
3131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3132         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3133         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3134         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3135         LDKAPIError_FeeRateTooHigh_class =
3136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3137         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3138         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3139         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3140         LDKAPIError_RouteError_class =
3141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3142         CHECK(LDKAPIError_RouteError_class != NULL);
3143         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3144         CHECK(LDKAPIError_RouteError_meth != NULL);
3145         LDKAPIError_ChannelUnavailable_class =
3146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3147         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3148         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3149         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3150         LDKAPIError_MonitorUpdateFailed_class =
3151                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3152         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3153         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3154         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3155 }
3156 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3157         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3158         switch(obj->tag) {
3159                 case LDKAPIError_APIMisuseError: {
3160                         LDKStr err_str = obj->api_misuse_error.err;
3161                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3162                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3163                 }
3164                 case LDKAPIError_FeeRateTooHigh: {
3165                         LDKStr err_str = obj->fee_rate_too_high.err;
3166                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3167                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3168                 }
3169                 case LDKAPIError_RouteError: {
3170                         LDKStr err_str = obj->route_error.err;
3171                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3172                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3173                 }
3174                 case LDKAPIError_ChannelUnavailable: {
3175                         LDKStr err_str = obj->channel_unavailable.err;
3176                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3177                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3178                 }
3179                 case LDKAPIError_MonitorUpdateFailed: {
3180                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3181                 }
3182                 default: abort();
3183         }
3184 }
3185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3186         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3187 }
3188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3189         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3190         CHECK(val->result_ok);
3191         return *val->contents.result;
3192 }
3193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3194         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3195         CHECK(!val->result_ok);
3196         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3197         return err_ref;
3198 }
3199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3200         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3201         ret->datalen = (*env)->GetArrayLength(env, elems);
3202         if (ret->datalen == 0) {
3203                 ret->data = NULL;
3204         } else {
3205                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3206                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3207                 for (size_t i = 0; i < ret->datalen; i++) {
3208                         int64_t arr_elem = java_elems[i];
3209                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3210                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3211                         ret->data[i] = arr_elem_conv;
3212                 }
3213                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3214         }
3215         return (uint64_t)ret;
3216 }
3217 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3218         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3219         for (size_t i = 0; i < ret.datalen; i++) {
3220                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3221         }
3222         return ret;
3223 }
3224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3225         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3226         ret->datalen = (*env)->GetArrayLength(env, elems);
3227         if (ret->datalen == 0) {
3228                 ret->data = NULL;
3229         } else {
3230                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3231                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3232                 for (size_t i = 0; i < ret->datalen; i++) {
3233                         int64_t arr_elem = java_elems[i];
3234                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3235                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3236                         ret->data[i] = arr_elem_conv;
3237                 }
3238                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3239         }
3240         return (uint64_t)ret;
3241 }
3242 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3243         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3244         for (size_t i = 0; i < ret.datalen; i++) {
3245                 ret.data[i] = APIError_clone(&orig->data[i]);
3246         }
3247         return ret;
3248 }
3249 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3250 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3251 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3252 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3253 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3254 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3255 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3256 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3258         LDKPaymentSendFailure_ParameterError_class =
3259                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3260         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3261         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3262         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3263         LDKPaymentSendFailure_PathParameterError_class =
3264                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3265         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3266         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3267         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3268         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3269                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3270         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3271         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3272         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3273         LDKPaymentSendFailure_PartialFailure_class =
3274                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3275         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3276         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3277         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3278 }
3279 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3280         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3281         switch(obj->tag) {
3282                 case LDKPaymentSendFailure_ParameterError: {
3283                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3284                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3285                 }
3286                 case LDKPaymentSendFailure_PathParameterError: {
3287                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3288                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3289                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3290                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3291                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3292                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3293                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3294                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3295                         }
3296                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3297                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3298                 }
3299                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3300                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3301                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3302                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3303                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3304                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3305                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3306                         }
3307                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3308                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3309                 }
3310                 case LDKPaymentSendFailure_PartialFailure: {
3311                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3312                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3313                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3314                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3315                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3316                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3317                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3318                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3319                         }
3320                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3321                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3322                 }
3323                 default: abort();
3324         }
3325 }
3326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3327         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3328 }
3329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3330         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3331         CHECK(val->result_ok);
3332         return *val->contents.result;
3333 }
3334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3335         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3336         CHECK(!val->result_ok);
3337         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3338         return err_ref;
3339 }
3340 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3341         return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok;
3342 }
3343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3344         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3345         CHECK(val->result_ok);
3346         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3347         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3348         return res_arr;
3349 }
3350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3351         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3352         CHECK(!val->result_ok);
3353         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3354         return err_ref;
3355 }
3356 static jclass LDKNetAddress_IPv4_class = NULL;
3357 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3358 static jclass LDKNetAddress_IPv6_class = NULL;
3359 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3360 static jclass LDKNetAddress_OnionV2_class = NULL;
3361 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3362 static jclass LDKNetAddress_OnionV3_class = NULL;
3363 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3365         LDKNetAddress_IPv4_class =
3366                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3367         CHECK(LDKNetAddress_IPv4_class != NULL);
3368         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3369         CHECK(LDKNetAddress_IPv4_meth != NULL);
3370         LDKNetAddress_IPv6_class =
3371                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3372         CHECK(LDKNetAddress_IPv6_class != NULL);
3373         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3374         CHECK(LDKNetAddress_IPv6_meth != NULL);
3375         LDKNetAddress_OnionV2_class =
3376                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3377         CHECK(LDKNetAddress_OnionV2_class != NULL);
3378         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3379         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3380         LDKNetAddress_OnionV3_class =
3381                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3382         CHECK(LDKNetAddress_OnionV3_class != NULL);
3383         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3384         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3385 }
3386 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3387         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3388         switch(obj->tag) {
3389                 case LDKNetAddress_IPv4: {
3390                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3391                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3392                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3393                 }
3394                 case LDKNetAddress_IPv6: {
3395                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3396                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3397                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3398                 }
3399                 case LDKNetAddress_OnionV2: {
3400                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3401                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3402                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3403                 }
3404                 case LDKNetAddress_OnionV3: {
3405                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3406                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3407                         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);
3408                 }
3409                 default: abort();
3410         }
3411 }
3412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3413         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3414         ret->datalen = (*env)->GetArrayLength(env, elems);
3415         if (ret->datalen == 0) {
3416                 ret->data = NULL;
3417         } else {
3418                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3419                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3420                 for (size_t i = 0; i < ret->datalen; i++) {
3421                         int64_t arr_elem = java_elems[i];
3422                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3423                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3424                         ret->data[i] = arr_elem_conv;
3425                 }
3426                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3427         }
3428         return (uint64_t)ret;
3429 }
3430 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3431         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3432         for (size_t i = 0; i < ret.datalen; i++) {
3433                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3434         }
3435         return ret;
3436 }
3437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3438         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3439         LDKThirtyTwoBytes a_ref;
3440         CHECK((*env)->GetArrayLength(env, a) == 32);
3441         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3442         ret->a = a_ref;
3443         LDKThirtyTwoBytes b_ref;
3444         CHECK((*env)->GetArrayLength(env, b) == 32);
3445         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3446         ret->b = b_ref;
3447         return (uint64_t)ret;
3448 }
3449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3450         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3451         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3452         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3453         return a_arr;
3454 }
3455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3456         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3457         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3458         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3459         return b_arr;
3460 }
3461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3462         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3463 }
3464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3465         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3466         CHECK(val->result_ok);
3467         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3468         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3469         return res_arr;
3470 }
3471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3472         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3473         CHECK(!val->result_ok);
3474         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3475         return err_ref;
3476 }
3477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3478         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3479         ret->datalen = (*env)->GetArrayLength(env, elems);
3480         if (ret->datalen == 0) {
3481                 ret->data = NULL;
3482         } else {
3483                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3484                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3485                 for (size_t i = 0; i < ret->datalen; i++) {
3486                         int64_t arr_elem = java_elems[i];
3487                         LDKChannelMonitor arr_elem_conv;
3488                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3489                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3490                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3491                         ret->data[i] = arr_elem_conv;
3492                 }
3493                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3494         }
3495         return (uint64_t)ret;
3496 }
3497 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3498         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3499         for (size_t i = 0; i < ret.datalen; i++) {
3500                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3501         }
3502         return ret;
3503 }
3504 typedef struct LDKWatch_JCalls {
3505         atomic_size_t refcnt;
3506         JavaVM *vm;
3507         jweak o;
3508         jmethodID watch_channel_meth;
3509         jmethodID update_channel_meth;
3510         jmethodID release_pending_monitor_events_meth;
3511 } LDKWatch_JCalls;
3512 static void LDKWatch_JCalls_free(void* this_arg) {
3513         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3514         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3515                 JNIEnv *env;
3516                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3517                 if (get_jenv_res == JNI_EDETACHED) {
3518                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3519                 } else {
3520                         DO_ASSERT(get_jenv_res == JNI_OK);
3521                 }
3522                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3523                 if (get_jenv_res == JNI_EDETACHED) {
3524                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3525                 }
3526                 FREE(j_calls);
3527         }
3528 }
3529 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3530         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3531         JNIEnv *env;
3532         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3533         if (get_jenv_res == JNI_EDETACHED) {
3534                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3535         } else {
3536                 DO_ASSERT(get_jenv_res == JNI_OK);
3537         }
3538         LDKOutPoint funding_txo_var = funding_txo;
3539         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3540         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3541         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3542         if (funding_txo_var.is_owned) {
3543                 funding_txo_ref |= 1;
3544         }
3545         LDKChannelMonitor monitor_var = monitor;
3546         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3547         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3548         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3549         if (monitor_var.is_owned) {
3550                 monitor_ref |= 1;
3551         }
3552         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3553         CHECK(obj != NULL);
3554         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3555         if ((*env)->ExceptionCheck(env)) {
3556                 (*env)->ExceptionDescribe(env);
3557                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3558         }
3559         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3560         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3561         if (get_jenv_res == JNI_EDETACHED) {
3562                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3563         }
3564         return ret_conv;
3565 }
3566 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3567         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3568         JNIEnv *env;
3569         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3570         if (get_jenv_res == JNI_EDETACHED) {
3571                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3572         } else {
3573                 DO_ASSERT(get_jenv_res == JNI_OK);
3574         }
3575         LDKOutPoint funding_txo_var = funding_txo;
3576         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3577         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3578         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3579         if (funding_txo_var.is_owned) {
3580                 funding_txo_ref |= 1;
3581         }
3582         LDKChannelMonitorUpdate update_var = update;
3583         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3584         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3585         uint64_t update_ref = (uint64_t)update_var.inner;
3586         if (update_var.is_owned) {
3587                 update_ref |= 1;
3588         }
3589         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3590         CHECK(obj != NULL);
3591         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3592         if ((*env)->ExceptionCheck(env)) {
3593                 (*env)->ExceptionDescribe(env);
3594                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3595         }
3596         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3597         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3598         if (get_jenv_res == JNI_EDETACHED) {
3599                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3600         }
3601         return ret_conv;
3602 }
3603 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3604         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3605         JNIEnv *env;
3606         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3607         if (get_jenv_res == JNI_EDETACHED) {
3608                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3609         } else {
3610                 DO_ASSERT(get_jenv_res == JNI_OK);
3611         }
3612         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3613         CHECK(obj != NULL);
3614         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3615         if ((*env)->ExceptionCheck(env)) {
3616                 (*env)->ExceptionDescribe(env);
3617                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3618         }
3619         LDKCVec_MonitorEventZ ret_constr;
3620         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3621         if (ret_constr.datalen > 0)
3622                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3623         else
3624                 ret_constr.data = NULL;
3625         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3626         for (size_t o = 0; o < ret_constr.datalen; o++) {
3627                 int64_t ret_conv_14 = ret_vals[o];
3628                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3629                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3630                 ret_constr.data[o] = ret_conv_14_conv;
3631         }
3632         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3633         if (get_jenv_res == JNI_EDETACHED) {
3634                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3635         }
3636         return ret_constr;
3637 }
3638 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3639         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3640         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3641 }
3642 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3643         jclass c = (*env)->GetObjectClass(env, o);
3644         CHECK(c != NULL);
3645         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3646         atomic_init(&calls->refcnt, 1);
3647         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3648         calls->o = (*env)->NewWeakGlobalRef(env, o);
3649         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3650         CHECK(calls->watch_channel_meth != NULL);
3651         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3652         CHECK(calls->update_channel_meth != NULL);
3653         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3654         CHECK(calls->release_pending_monitor_events_meth != NULL);
3655
3656         LDKWatch ret = {
3657                 .this_arg = (void*) calls,
3658                 .watch_channel = watch_channel_LDKWatch_jcall,
3659                 .update_channel = update_channel_LDKWatch_jcall,
3660                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3661                 .free = LDKWatch_JCalls_free,
3662         };
3663         return ret;
3664 }
3665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3666         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3667         *res_ptr = LDKWatch_init(env, clz, o);
3668         return (uint64_t)res_ptr;
3669 }
3670 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) {
3671         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3672         LDKOutPoint funding_txo_conv;
3673         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3674         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3675         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3676         LDKChannelMonitor monitor_conv;
3677         monitor_conv.inner = (void*)(monitor & (~1));
3678         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3679         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3680         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3681         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3682         return (uint64_t)ret_conv;
3683 }
3684
3685 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) {
3686         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3687         LDKOutPoint funding_txo_conv;
3688         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3689         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3690         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3691         LDKChannelMonitorUpdate update_conv;
3692         update_conv.inner = (void*)(update & (~1));
3693         update_conv.is_owned = (update & 1) || (update == 0);
3694         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3695         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3696         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3697         return (uint64_t)ret_conv;
3698 }
3699
3700 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3701         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3702         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3703         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3704         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3705         for (size_t o = 0; o < ret_var.datalen; o++) {
3706                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3707                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3708                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3709                 ret_arr_ptr[o] = ret_conv_14_ref;
3710         }
3711         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3712         FREE(ret_var.data);
3713         return ret_arr;
3714 }
3715
3716 typedef struct LDKBroadcasterInterface_JCalls {
3717         atomic_size_t refcnt;
3718         JavaVM *vm;
3719         jweak o;
3720         jmethodID broadcast_transaction_meth;
3721 } LDKBroadcasterInterface_JCalls;
3722 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3723         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3724         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3725                 JNIEnv *env;
3726                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3727                 if (get_jenv_res == JNI_EDETACHED) {
3728                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3729                 } else {
3730                         DO_ASSERT(get_jenv_res == JNI_OK);
3731                 }
3732                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3733                 if (get_jenv_res == JNI_EDETACHED) {
3734                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3735                 }
3736                 FREE(j_calls);
3737         }
3738 }
3739 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3740         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3741         JNIEnv *env;
3742         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3743         if (get_jenv_res == JNI_EDETACHED) {
3744                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3745         } else {
3746                 DO_ASSERT(get_jenv_res == JNI_OK);
3747         }
3748         LDKTransaction tx_var = tx;
3749         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3750         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3751         Transaction_free(tx_var);
3752         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3753         CHECK(obj != NULL);
3754         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3755         if ((*env)->ExceptionCheck(env)) {
3756                 (*env)->ExceptionDescribe(env);
3757                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3758         }
3759         if (get_jenv_res == JNI_EDETACHED) {
3760                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3761         }
3762 }
3763 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3764         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3765         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3766 }
3767 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3768         jclass c = (*env)->GetObjectClass(env, o);
3769         CHECK(c != NULL);
3770         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3771         atomic_init(&calls->refcnt, 1);
3772         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3773         calls->o = (*env)->NewWeakGlobalRef(env, o);
3774         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3775         CHECK(calls->broadcast_transaction_meth != NULL);
3776
3777         LDKBroadcasterInterface ret = {
3778                 .this_arg = (void*) calls,
3779                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3780                 .free = LDKBroadcasterInterface_JCalls_free,
3781         };
3782         return ret;
3783 }
3784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3785         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3786         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3787         return (uint64_t)res_ptr;
3788 }
3789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3790         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3791         LDKTransaction tx_ref;
3792         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3793         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3794         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3795         tx_ref.data_is_owned = true;
3796         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3797 }
3798
3799 typedef struct LDKKeysInterface_JCalls {
3800         atomic_size_t refcnt;
3801         JavaVM *vm;
3802         jweak o;
3803         jmethodID get_node_secret_meth;
3804         jmethodID get_destination_script_meth;
3805         jmethodID get_shutdown_pubkey_meth;
3806         jmethodID get_channel_signer_meth;
3807         jmethodID get_secure_random_bytes_meth;
3808         jmethodID read_chan_signer_meth;
3809         jmethodID sign_invoice_meth;
3810 } LDKKeysInterface_JCalls;
3811 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3812         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3813         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3814                 JNIEnv *env;
3815                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3816                 if (get_jenv_res == JNI_EDETACHED) {
3817                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3818                 } else {
3819                         DO_ASSERT(get_jenv_res == JNI_OK);
3820                 }
3821                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3822                 if (get_jenv_res == JNI_EDETACHED) {
3823                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3824                 }
3825                 FREE(j_calls);
3826         }
3827 }
3828 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3829         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3830         JNIEnv *env;
3831         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3832         if (get_jenv_res == JNI_EDETACHED) {
3833                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3834         } else {
3835                 DO_ASSERT(get_jenv_res == JNI_OK);
3836         }
3837         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3838         CHECK(obj != NULL);
3839         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3840         if ((*env)->ExceptionCheck(env)) {
3841                 (*env)->ExceptionDescribe(env);
3842                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3843         }
3844         LDKSecretKey ret_ref;
3845         CHECK((*env)->GetArrayLength(env, ret) == 32);
3846         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3847         if (get_jenv_res == JNI_EDETACHED) {
3848                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3849         }
3850         return ret_ref;
3851 }
3852 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3853         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3854         JNIEnv *env;
3855         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3856         if (get_jenv_res == JNI_EDETACHED) {
3857                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3858         } else {
3859                 DO_ASSERT(get_jenv_res == JNI_OK);
3860         }
3861         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3862         CHECK(obj != NULL);
3863         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3864         if ((*env)->ExceptionCheck(env)) {
3865                 (*env)->ExceptionDescribe(env);
3866                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
3867         }
3868         LDKCVec_u8Z ret_ref;
3869         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3870         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3871         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3872         if (get_jenv_res == JNI_EDETACHED) {
3873                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3874         }
3875         return ret_ref;
3876 }
3877 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3878         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3879         JNIEnv *env;
3880         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3881         if (get_jenv_res == JNI_EDETACHED) {
3882                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3883         } else {
3884                 DO_ASSERT(get_jenv_res == JNI_OK);
3885         }
3886         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3887         CHECK(obj != NULL);
3888         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3889         if ((*env)->ExceptionCheck(env)) {
3890                 (*env)->ExceptionDescribe(env);
3891                 (*env)->FatalError(env, "A call to get_shutdown_pubkey in LDKKeysInterface from rust threw an exception.");
3892         }
3893         LDKPublicKey ret_ref;
3894         CHECK((*env)->GetArrayLength(env, ret) == 33);
3895         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3896         if (get_jenv_res == JNI_EDETACHED) {
3897                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3898         }
3899         return ret_ref;
3900 }
3901 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3902         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3903         JNIEnv *env;
3904         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3905         if (get_jenv_res == JNI_EDETACHED) {
3906                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3907         } else {
3908                 DO_ASSERT(get_jenv_res == JNI_OK);
3909         }
3910         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3911         CHECK(obj != NULL);
3912         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3913         if ((*env)->ExceptionCheck(env)) {
3914                 (*env)->ExceptionDescribe(env);
3915                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
3916         }
3917         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3918         ret_conv = Sign_clone(ret);
3919         if (get_jenv_res == JNI_EDETACHED) {
3920                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3921         }
3922         return ret_conv;
3923 }
3924 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3925         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3926         JNIEnv *env;
3927         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3928         if (get_jenv_res == JNI_EDETACHED) {
3929                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3930         } else {
3931                 DO_ASSERT(get_jenv_res == JNI_OK);
3932         }
3933         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3934         CHECK(obj != NULL);
3935         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3936         if ((*env)->ExceptionCheck(env)) {
3937                 (*env)->ExceptionDescribe(env);
3938                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
3939         }
3940         LDKThirtyTwoBytes ret_ref;
3941         CHECK((*env)->GetArrayLength(env, ret) == 32);
3942         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3943         if (get_jenv_res == JNI_EDETACHED) {
3944                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3945         }
3946         return ret_ref;
3947 }
3948 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3949         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3950         JNIEnv *env;
3951         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3952         if (get_jenv_res == JNI_EDETACHED) {
3953                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3954         } else {
3955                 DO_ASSERT(get_jenv_res == JNI_OK);
3956         }
3957         LDKu8slice reader_var = reader;
3958         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3959         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3960         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3961         CHECK(obj != NULL);
3962         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3963         if ((*env)->ExceptionCheck(env)) {
3964                 (*env)->ExceptionDescribe(env);
3965                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
3966         }
3967         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3968         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3969         if (get_jenv_res == JNI_EDETACHED) {
3970                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3971         }
3972         return ret_conv;
3973 }
3974 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3975         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3976         JNIEnv *env;
3977         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3978         if (get_jenv_res == JNI_EDETACHED) {
3979                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3980         } else {
3981                 DO_ASSERT(get_jenv_res == JNI_OK);
3982         }
3983         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3984         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3985         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3986         CVec_u8Z_free(invoice_preimage_var);
3987         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3988         CHECK(obj != NULL);
3989         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3990         if ((*env)->ExceptionCheck(env)) {
3991                 (*env)->ExceptionDescribe(env);
3992                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
3993         }
3994         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3995         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3996         if (get_jenv_res == JNI_EDETACHED) {
3997                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3998         }
3999         return ret_conv;
4000 }
4001 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4002         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4003         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4004 }
4005 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4006         jclass c = (*env)->GetObjectClass(env, o);
4007         CHECK(c != NULL);
4008         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4009         atomic_init(&calls->refcnt, 1);
4010         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4011         calls->o = (*env)->NewWeakGlobalRef(env, o);
4012         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4013         CHECK(calls->get_node_secret_meth != NULL);
4014         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4015         CHECK(calls->get_destination_script_meth != NULL);
4016         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
4017         CHECK(calls->get_shutdown_pubkey_meth != NULL);
4018         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4019         CHECK(calls->get_channel_signer_meth != NULL);
4020         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4021         CHECK(calls->get_secure_random_bytes_meth != NULL);
4022         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4023         CHECK(calls->read_chan_signer_meth != NULL);
4024         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4025         CHECK(calls->sign_invoice_meth != NULL);
4026
4027         LDKKeysInterface ret = {
4028                 .this_arg = (void*) calls,
4029                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4030                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4031                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
4032                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4033                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4034                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4035                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4036                 .free = LDKKeysInterface_JCalls_free,
4037         };
4038         return ret;
4039 }
4040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4041         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4042         *res_ptr = LDKKeysInterface_init(env, clz, o);
4043         return (uint64_t)res_ptr;
4044 }
4045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4046         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4047         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4049         return ret_arr;
4050 }
4051
4052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4053         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4054         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4055         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4056         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4057         CVec_u8Z_free(ret_var);
4058         return ret_arr;
4059 }
4060
4061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4062         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4063         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4064         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
4065         return ret_arr;
4066 }
4067
4068 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) {
4069         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4070         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
4071         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4072         return (uint64_t)ret;
4073 }
4074
4075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4076         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4077         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4078         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4079         return ret_arr;
4080 }
4081
4082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4083         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4084         LDKu8slice reader_ref;
4085         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4086         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4087         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4088         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4089         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4090         return (uint64_t)ret_conv;
4091 }
4092
4093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4094         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4095         LDKCVec_u8Z invoice_preimage_ref;
4096         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4097         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4098         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4099         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4100         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4101         return (uint64_t)ret_conv;
4102 }
4103
4104 typedef struct LDKFeeEstimator_JCalls {
4105         atomic_size_t refcnt;
4106         JavaVM *vm;
4107         jweak o;
4108         jmethodID get_est_sat_per_1000_weight_meth;
4109 } LDKFeeEstimator_JCalls;
4110 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4111         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4112         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4113                 JNIEnv *env;
4114                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4115                 if (get_jenv_res == JNI_EDETACHED) {
4116                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4117                 } else {
4118                         DO_ASSERT(get_jenv_res == JNI_OK);
4119                 }
4120                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4121                 if (get_jenv_res == JNI_EDETACHED) {
4122                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4123                 }
4124                 FREE(j_calls);
4125         }
4126 }
4127 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4128         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4129         JNIEnv *env;
4130         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4131         if (get_jenv_res == JNI_EDETACHED) {
4132                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4133         } else {
4134                 DO_ASSERT(get_jenv_res == JNI_OK);
4135         }
4136         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4137         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4138         CHECK(obj != NULL);
4139         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4140         if ((*env)->ExceptionCheck(env)) {
4141                 (*env)->ExceptionDescribe(env);
4142                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4143         }
4144         if (get_jenv_res == JNI_EDETACHED) {
4145                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4146         }
4147         return ret;
4148 }
4149 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4150         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4151         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4152 }
4153 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4154         jclass c = (*env)->GetObjectClass(env, o);
4155         CHECK(c != NULL);
4156         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4157         atomic_init(&calls->refcnt, 1);
4158         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4159         calls->o = (*env)->NewWeakGlobalRef(env, o);
4160         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4161         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4162
4163         LDKFeeEstimator ret = {
4164                 .this_arg = (void*) calls,
4165                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4166                 .free = LDKFeeEstimator_JCalls_free,
4167         };
4168         return ret;
4169 }
4170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4171         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4172         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4173         return (uint64_t)res_ptr;
4174 }
4175 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) {
4176         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4177         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4178         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4179         return ret_val;
4180 }
4181
4182 typedef struct LDKLogger_JCalls {
4183         atomic_size_t refcnt;
4184         JavaVM *vm;
4185         jweak o;
4186         jmethodID log_meth;
4187 } LDKLogger_JCalls;
4188 static void LDKLogger_JCalls_free(void* this_arg) {
4189         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4190         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4191                 JNIEnv *env;
4192                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4193                 if (get_jenv_res == JNI_EDETACHED) {
4194                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4195                 } else {
4196                         DO_ASSERT(get_jenv_res == JNI_OK);
4197                 }
4198                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4199                 if (get_jenv_res == JNI_EDETACHED) {
4200                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4201                 }
4202                 FREE(j_calls);
4203         }
4204 }
4205 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4206         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4207         JNIEnv *env;
4208         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4209         if (get_jenv_res == JNI_EDETACHED) {
4210                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4211         } else {
4212                 DO_ASSERT(get_jenv_res == JNI_OK);
4213         }
4214         const char* record_str = record;
4215         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4216         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4217         CHECK(obj != NULL);
4218         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4219         if ((*env)->ExceptionCheck(env)) {
4220                 (*env)->ExceptionDescribe(env);
4221                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4222         }
4223         if (get_jenv_res == JNI_EDETACHED) {
4224                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4225         }
4226 }
4227 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4228         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4229         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4230 }
4231 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4232         jclass c = (*env)->GetObjectClass(env, o);
4233         CHECK(c != NULL);
4234         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4235         atomic_init(&calls->refcnt, 1);
4236         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4237         calls->o = (*env)->NewWeakGlobalRef(env, o);
4238         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4239         CHECK(calls->log_meth != NULL);
4240
4241         LDKLogger ret = {
4242                 .this_arg = (void*) calls,
4243                 .log = log_LDKLogger_jcall,
4244                 .free = LDKLogger_JCalls_free,
4245         };
4246         return ret;
4247 }
4248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4249         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4250         *res_ptr = LDKLogger_init(env, clz, o);
4251         return (uint64_t)res_ptr;
4252 }
4253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4254         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4255         LDKThirtyTwoBytes a_ref;
4256         CHECK((*env)->GetArrayLength(env, a) == 32);
4257         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4258         ret->a = a_ref;
4259         LDKChannelManager b_conv;
4260         b_conv.inner = (void*)(b & (~1));
4261         b_conv.is_owned = (b & 1) || (b == 0);
4262         // Warning: we need a move here but no clone is available for LDKChannelManager
4263         ret->b = b_conv;
4264         return (uint64_t)ret;
4265 }
4266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4267         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4268         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4269         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4270         return a_arr;
4271 }
4272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4273         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4274         LDKChannelManager b_var = tuple->b;
4275         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4276         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4277         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4278         return b_ref;
4279 }
4280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4281         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4282 }
4283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4284         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4285         CHECK(val->result_ok);
4286         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4287         return res_ref;
4288 }
4289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4290         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4291         CHECK(!val->result_ok);
4292         LDKDecodeError err_var = (*val->contents.err);
4293         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4294         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4295         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4296         return err_ref;
4297 }
4298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4299         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4300 }
4301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4302         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4303         CHECK(val->result_ok);
4304         LDKChannelConfig res_var = (*val->contents.result);
4305         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4306         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4307         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4308         return res_ref;
4309 }
4310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4311         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4312         CHECK(!val->result_ok);
4313         LDKDecodeError err_var = (*val->contents.err);
4314         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4315         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4316         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4317         return err_ref;
4318 }
4319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4320         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4321 }
4322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4323         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4324         CHECK(val->result_ok);
4325         LDKOutPoint res_var = (*val->contents.result);
4326         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4327         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4328         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4329         return res_ref;
4330 }
4331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4332         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4333         CHECK(!val->result_ok);
4334         LDKDecodeError err_var = (*val->contents.err);
4335         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4336         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4337         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4338         return err_ref;
4339 }
4340 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4341         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4342 }
4343 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4344         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4345         CHECK(val->result_ok);
4346         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4347         return res_conv;
4348 }
4349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4350         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4351         CHECK(!val->result_ok);
4352         return *val->contents.err;
4353 }
4354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4355         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4356 }
4357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4358         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4359         CHECK(val->result_ok);
4360         LDKInvoice res_var = (*val->contents.result);
4361         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4362         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4363         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4364         return res_ref;
4365 }
4366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4367         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4368         CHECK(!val->result_ok);
4369         return *val->contents.err;
4370 }
4371 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4372         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4373 }
4374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4375         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4376         CHECK(val->result_ok);
4377         LDKSignedRawInvoice res_var = (*val->contents.result);
4378         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4379         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4380         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4381         return res_ref;
4382 }
4383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4384         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4385         CHECK(!val->result_ok);
4386         return *val->contents.err;
4387 }
4388 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) {
4389         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4390         LDKRawInvoice a_conv;
4391         a_conv.inner = (void*)(a & (~1));
4392         a_conv.is_owned = (a & 1) || (a == 0);
4393         a_conv = RawInvoice_clone(&a_conv);
4394         ret->a = a_conv;
4395         LDKThirtyTwoBytes b_ref;
4396         CHECK((*env)->GetArrayLength(env, b) == 32);
4397         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4398         ret->b = b_ref;
4399         LDKInvoiceSignature c_conv;
4400         c_conv.inner = (void*)(c & (~1));
4401         c_conv.is_owned = (c & 1) || (c == 0);
4402         c_conv = InvoiceSignature_clone(&c_conv);
4403         ret->c = c_conv;
4404         return (uint64_t)ret;
4405 }
4406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4407         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4408         LDKRawInvoice a_var = tuple->a;
4409         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4410         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4411         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4412         return a_ref;
4413 }
4414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4415         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4416         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4417         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4418         return b_arr;
4419 }
4420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4421         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4422         LDKInvoiceSignature c_var = tuple->c;
4423         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4424         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4425         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4426         return c_ref;
4427 }
4428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4429         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4430 }
4431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4432         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4433         CHECK(val->result_ok);
4434         LDKPayeePubKey res_var = (*val->contents.result);
4435         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4436         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4437         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4438         return res_ref;
4439 }
4440 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4441         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4442         CHECK(!val->result_ok);
4443         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4444         return err_conv;
4445 }
4446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4447         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4448         ret->datalen = (*env)->GetArrayLength(env, elems);
4449         if (ret->datalen == 0) {
4450                 ret->data = NULL;
4451         } else {
4452                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4453                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4454                 for (size_t i = 0; i < ret->datalen; i++) {
4455                         int64_t arr_elem = java_elems[i];
4456                         LDKPrivateRoute arr_elem_conv;
4457                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4458                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4459                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4460                         ret->data[i] = arr_elem_conv;
4461                 }
4462                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4463         }
4464         return (uint64_t)ret;
4465 }
4466 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4467         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4468         for (size_t i = 0; i < ret.datalen; i++) {
4469                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4470         }
4471         return ret;
4472 }
4473 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4474         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4475 }
4476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4477         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4478         CHECK(val->result_ok);
4479         LDKPositiveTimestamp res_var = (*val->contents.result);
4480         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4481         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4482         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4483         return res_ref;
4484 }
4485 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4486         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4487         CHECK(!val->result_ok);
4488         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4489         return err_conv;
4490 }
4491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4492         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4493 }
4494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4495         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4496         CHECK(val->result_ok);
4497         return *val->contents.result;
4498 }
4499 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4500         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4501         CHECK(!val->result_ok);
4502         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4503         return err_conv;
4504 }
4505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4506         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4507 }
4508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4509         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4510         CHECK(val->result_ok);
4511         LDKInvoice res_var = (*val->contents.result);
4512         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4513         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4514         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4515         return res_ref;
4516 }
4517 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4518         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4519         CHECK(!val->result_ok);
4520         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4521         return err_conv;
4522 }
4523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4524         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4525 }
4526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4527         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4528         CHECK(val->result_ok);
4529         LDKDescription res_var = (*val->contents.result);
4530         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4531         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4532         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4533         return res_ref;
4534 }
4535 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4536         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4537         CHECK(!val->result_ok);
4538         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4539         return err_conv;
4540 }
4541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4542         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4543 }
4544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4545         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4546         CHECK(val->result_ok);
4547         LDKExpiryTime res_var = (*val->contents.result);
4548         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4549         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4550         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4551         return res_ref;
4552 }
4553 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4554         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4555         CHECK(!val->result_ok);
4556         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4557         return err_conv;
4558 }
4559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4560         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4561 }
4562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4563         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4564         CHECK(val->result_ok);
4565         LDKPrivateRoute res_var = (*val->contents.result);
4566         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4567         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4568         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4569         return res_ref;
4570 }
4571 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4572         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4573         CHECK(!val->result_ok);
4574         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4575         return err_conv;
4576 }
4577 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4578         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4579 }
4580 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4581         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4582         CHECK(val->result_ok);
4583         LDKStr res_str = (*val->contents.result);
4584         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4585         return res_conv;
4586 }
4587 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4588         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4589         CHECK(!val->result_ok);
4590         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4591         return err_conv;
4592 }
4593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4594         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4595 }
4596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4597         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4598         CHECK(val->result_ok);
4599         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4600         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4601         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4602         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4603         return res_ref;
4604 }
4605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4606         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4607         CHECK(!val->result_ok);
4608         LDKDecodeError err_var = (*val->contents.err);
4609         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4610         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4611         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4612         return err_ref;
4613 }
4614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4615         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4616 }
4617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4618         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4619         CHECK(val->result_ok);
4620         LDKHTLCUpdate res_var = (*val->contents.result);
4621         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4622         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4623         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4624         return res_ref;
4625 }
4626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4627         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4628         CHECK(!val->result_ok);
4629         LDKDecodeError err_var = (*val->contents.err);
4630         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4631         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4632         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4633         return err_ref;
4634 }
4635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4636         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4637 }
4638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4639         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4640         CHECK(val->result_ok);
4641         return *val->contents.result;
4642 }
4643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4644         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4645         CHECK(!val->result_ok);
4646         LDKMonitorUpdateError err_var = (*val->contents.err);
4647         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4648         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4649         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4650         return err_ref;
4651 }
4652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4653         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4654         LDKOutPoint a_conv;
4655         a_conv.inner = (void*)(a & (~1));
4656         a_conv.is_owned = (a & 1) || (a == 0);
4657         a_conv = OutPoint_clone(&a_conv);
4658         ret->a = a_conv;
4659         LDKCVec_u8Z b_ref;
4660         b_ref.datalen = (*env)->GetArrayLength(env, b);
4661         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4662         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4663         ret->b = b_ref;
4664         return (uint64_t)ret;
4665 }
4666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4667         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4668         LDKOutPoint a_var = tuple->a;
4669         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4670         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4671         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4672         return a_ref;
4673 }
4674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4675         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4676         LDKCVec_u8Z b_var = tuple->b;
4677         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4678         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4679         return b_arr;
4680 }
4681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4682         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4683         ret->a = a;
4684         LDKCVec_u8Z b_ref;
4685         b_ref.datalen = (*env)->GetArrayLength(env, b);
4686         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4687         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4688         ret->b = b_ref;
4689         return (uint64_t)ret;
4690 }
4691 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4692         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4693         return tuple->a;
4694 }
4695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4696         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4697         LDKCVec_u8Z b_var = tuple->b;
4698         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4699         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4700         return b_arr;
4701 }
4702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4703         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4704         ret->datalen = (*env)->GetArrayLength(env, elems);
4705         if (ret->datalen == 0) {
4706                 ret->data = NULL;
4707         } else {
4708                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4709                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4710                 for (size_t i = 0; i < ret->datalen; i++) {
4711                         int64_t arr_elem = java_elems[i];
4712                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4713                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4714                         ret->data[i] = arr_elem_conv;
4715                 }
4716                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4717         }
4718         return (uint64_t)ret;
4719 }
4720 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4721         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4722         for (size_t i = 0; i < ret.datalen; i++) {
4723                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4724         }
4725         return ret;
4726 }
4727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4728         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4729         LDKThirtyTwoBytes a_ref;
4730         CHECK((*env)->GetArrayLength(env, a) == 32);
4731         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4732         ret->a = a_ref;
4733         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4734         b_constr.datalen = (*env)->GetArrayLength(env, b);
4735         if (b_constr.datalen > 0)
4736                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4737         else
4738                 b_constr.data = NULL;
4739         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4740         for (size_t b = 0; b < b_constr.datalen; b++) {
4741                 int64_t b_conv_27 = b_vals[b];
4742                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4743                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4744                 b_constr.data[b] = b_conv_27_conv;
4745         }
4746         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4747         ret->b = b_constr;
4748         return (uint64_t)ret;
4749 }
4750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4751         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4752         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4753         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4754         return a_arr;
4755 }
4756 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4757         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4758         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4759         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4760         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4761         for (size_t b = 0; b < b_var.datalen; b++) {
4762                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4763                 b_arr_ptr[b] = b_conv_27_ref;
4764         }
4765         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4766         return b_arr;
4767 }
4768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4769         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4770         ret->datalen = (*env)->GetArrayLength(env, elems);
4771         if (ret->datalen == 0) {
4772                 ret->data = NULL;
4773         } else {
4774                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4775                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4776                 for (size_t i = 0; i < ret->datalen; i++) {
4777                         int64_t arr_elem = java_elems[i];
4778                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4779                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4780                         ret->data[i] = arr_elem_conv;
4781                 }
4782                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4783         }
4784         return (uint64_t)ret;
4785 }
4786 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4787         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 };
4788         for (size_t i = 0; i < ret.datalen; i++) {
4789                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4790         }
4791         return ret;
4792 }
4793 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
4794 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
4795 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
4796 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
4797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
4798         LDKPaymentPurpose_InvoicePayment_class =
4799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
4800         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
4801         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
4802         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
4803         LDKPaymentPurpose_SpontaneousPayment_class =
4804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
4805         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
4806         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
4807         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
4808 }
4809 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4810         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
4811         switch(obj->tag) {
4812                 case LDKPaymentPurpose_InvoicePayment: {
4813                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4814                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
4815                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4816                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
4817                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
4818                 }
4819                 case LDKPaymentPurpose_SpontaneousPayment: {
4820                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
4821                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
4822                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
4823                 }
4824                 default: abort();
4825         }
4826 }
4827 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4828 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4829 static jclass LDKEvent_PaymentReceived_class = NULL;
4830 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4831 static jclass LDKEvent_PaymentSent_class = NULL;
4832 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4833 static jclass LDKEvent_PaymentFailed_class = NULL;
4834 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4835 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4836 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4837 static jclass LDKEvent_SpendableOutputs_class = NULL;
4838 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4840         LDKEvent_FundingGenerationReady_class =
4841                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4842         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4843         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4844         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4845         LDKEvent_PaymentReceived_class =
4846                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4847         CHECK(LDKEvent_PaymentReceived_class != NULL);
4848         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
4849         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4850         LDKEvent_PaymentSent_class =
4851                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4852         CHECK(LDKEvent_PaymentSent_class != NULL);
4853         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4854         CHECK(LDKEvent_PaymentSent_meth != NULL);
4855         LDKEvent_PaymentFailed_class =
4856                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4857         CHECK(LDKEvent_PaymentFailed_class != NULL);
4858         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4859         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4860         LDKEvent_PendingHTLCsForwardable_class =
4861                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4862         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4863         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4864         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4865         LDKEvent_SpendableOutputs_class =
4866                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4867         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4868         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4869         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4870 }
4871 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4872         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4873         switch(obj->tag) {
4874                 case LDKEvent_FundingGenerationReady: {
4875                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4876                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4877                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4878                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4879                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4880                         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);
4881                 }
4882                 case LDKEvent_PaymentReceived: {
4883                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4884                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4885                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
4886                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
4887                 }
4888                 case LDKEvent_PaymentSent: {
4889                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4890                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4891                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4892                 }
4893                 case LDKEvent_PaymentFailed: {
4894                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4895                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4896                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4897                 }
4898                 case LDKEvent_PendingHTLCsForwardable: {
4899                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4900                 }
4901                 case LDKEvent_SpendableOutputs: {
4902                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4903                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4904                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4905                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4906                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4907                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4908                         }
4909                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4910                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4911                 }
4912                 default: abort();
4913         }
4914 }
4915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4916         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4917         ret->datalen = (*env)->GetArrayLength(env, elems);
4918         if (ret->datalen == 0) {
4919                 ret->data = NULL;
4920         } else {
4921                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4922                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4923                 for (size_t i = 0; i < ret->datalen; i++) {
4924                         int64_t arr_elem = java_elems[i];
4925                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4926                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4927                         ret->data[i] = arr_elem_conv;
4928                 }
4929                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4930         }
4931         return (uint64_t)ret;
4932 }
4933 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4934         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4935         for (size_t i = 0; i < ret.datalen; i++) {
4936                 ret.data[i] = Event_clone(&orig->data[i]);
4937         }
4938         return ret;
4939 }
4940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4941         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4942         ret->a = a;
4943         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4944         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4945         ret->b = b_conv;
4946         return (uint64_t)ret;
4947 }
4948 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4949         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4950         return tuple->a;
4951 }
4952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4953         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4954         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4955         return (uint64_t)b_ref;
4956 }
4957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4958         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4959         ret->datalen = (*env)->GetArrayLength(env, elems);
4960         if (ret->datalen == 0) {
4961                 ret->data = NULL;
4962         } else {
4963                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4964                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4965                 for (size_t i = 0; i < ret->datalen; i++) {
4966                         int64_t arr_elem = java_elems[i];
4967                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4968                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4969                         ret->data[i] = arr_elem_conv;
4970                 }
4971                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4972         }
4973         return (uint64_t)ret;
4974 }
4975 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4976         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4977         for (size_t i = 0; i < ret.datalen; i++) {
4978                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4979         }
4980         return ret;
4981 }
4982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4983         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4984         LDKThirtyTwoBytes a_ref;
4985         CHECK((*env)->GetArrayLength(env, a) == 32);
4986         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4987         ret->a = a_ref;
4988         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4989         b_constr.datalen = (*env)->GetArrayLength(env, b);
4990         if (b_constr.datalen > 0)
4991                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4992         else
4993                 b_constr.data = NULL;
4994         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4995         for (size_t a = 0; a < b_constr.datalen; a++) {
4996                 int64_t b_conv_26 = b_vals[a];
4997                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4998                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4999                 b_constr.data[a] = b_conv_26_conv;
5000         }
5001         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
5002         ret->b = b_constr;
5003         return (uint64_t)ret;
5004 }
5005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
5006         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
5007         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
5008         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
5009         return a_arr;
5010 }
5011 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
5012         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
5013         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
5014         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
5015         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
5016         for (size_t a = 0; a < b_var.datalen; a++) {
5017                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
5018                 b_arr_ptr[a] = b_conv_26_ref;
5019         }
5020         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
5021         return b_arr;
5022 }
5023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5024         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
5025         ret->datalen = (*env)->GetArrayLength(env, elems);
5026         if (ret->datalen == 0) {
5027                 ret->data = NULL;
5028         } else {
5029                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
5030                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5031                 for (size_t i = 0; i < ret->datalen; i++) {
5032                         int64_t arr_elem = java_elems[i];
5033                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
5034                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
5035                         ret->data[i] = arr_elem_conv;
5036                 }
5037                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5038         }
5039         return (uint64_t)ret;
5040 }
5041 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5042         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 };
5043         for (size_t i = 0; i < ret.datalen; i++) {
5044                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5045         }
5046         return ret;
5047 }
5048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5049         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
5050 }
5051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5052         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5053         CHECK(val->result_ok);
5054         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
5055         return res_ref;
5056 }
5057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5058         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5059         CHECK(!val->result_ok);
5060         LDKDecodeError err_var = (*val->contents.err);
5061         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5062         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5063         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5064         return err_ref;
5065 }
5066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5067         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
5068 }
5069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5070         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5071         CHECK(val->result_ok);
5072         return *val->contents.result;
5073 }
5074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5075         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5076         CHECK(!val->result_ok);
5077         LDKLightningError err_var = (*val->contents.err);
5078         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5079         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5080         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5081         return err_ref;
5082 }
5083 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) {
5084         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5085         LDKChannelAnnouncement a_conv;
5086         a_conv.inner = (void*)(a & (~1));
5087         a_conv.is_owned = (a & 1) || (a == 0);
5088         a_conv = ChannelAnnouncement_clone(&a_conv);
5089         ret->a = a_conv;
5090         LDKChannelUpdate b_conv;
5091         b_conv.inner = (void*)(b & (~1));
5092         b_conv.is_owned = (b & 1) || (b == 0);
5093         b_conv = ChannelUpdate_clone(&b_conv);
5094         ret->b = b_conv;
5095         LDKChannelUpdate c_conv;
5096         c_conv.inner = (void*)(c & (~1));
5097         c_conv.is_owned = (c & 1) || (c == 0);
5098         c_conv = ChannelUpdate_clone(&c_conv);
5099         ret->c = c_conv;
5100         return (uint64_t)ret;
5101 }
5102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
5103         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5104         LDKChannelAnnouncement a_var = tuple->a;
5105         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5106         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5107         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
5108         return a_ref;
5109 }
5110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
5111         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5112         LDKChannelUpdate b_var = tuple->b;
5113         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5114         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5115         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
5116         return b_ref;
5117 }
5118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
5119         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5120         LDKChannelUpdate c_var = tuple->c;
5121         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5122         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5123         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
5124         return c_ref;
5125 }
5126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5127         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
5128         ret->datalen = (*env)->GetArrayLength(env, elems);
5129         if (ret->datalen == 0) {
5130                 ret->data = NULL;
5131         } else {
5132                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
5133                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5134                 for (size_t i = 0; i < ret->datalen; i++) {
5135                         int64_t arr_elem = java_elems[i];
5136                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
5137                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
5138                         ret->data[i] = arr_elem_conv;
5139                 }
5140                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5141         }
5142         return (uint64_t)ret;
5143 }
5144 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5145         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5146         for (size_t i = 0; i < ret.datalen; i++) {
5147                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5148         }
5149         return ret;
5150 }
5151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5152         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
5153         ret->datalen = (*env)->GetArrayLength(env, elems);
5154         if (ret->datalen == 0) {
5155                 ret->data = NULL;
5156         } else {
5157                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
5158                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5159                 for (size_t i = 0; i < ret->datalen; i++) {
5160                         int64_t arr_elem = java_elems[i];
5161                         LDKNodeAnnouncement arr_elem_conv;
5162                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5163                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5164                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5165                         ret->data[i] = arr_elem_conv;
5166                 }
5167                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5168         }
5169         return (uint64_t)ret;
5170 }
5171 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5172         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5173         for (size_t i = 0; i < ret.datalen; i++) {
5174                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5175         }
5176         return ret;
5177 }
5178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5179         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5180 }
5181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5182         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5183         CHECK(val->result_ok);
5184         return *val->contents.result;
5185 }
5186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5187         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5188         CHECK(!val->result_ok);
5189         LDKLightningError err_var = (*val->contents.err);
5190         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5191         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5192         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5193         return err_ref;
5194 }
5195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5196         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5197 }
5198 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5199         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5200         CHECK(val->result_ok);
5201         LDKCVec_u8Z res_var = (*val->contents.result);
5202         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5203         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5204         return res_arr;
5205 }
5206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5207         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5208         CHECK(!val->result_ok);
5209         LDKPeerHandleError err_var = (*val->contents.err);
5210         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5211         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5212         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5213         return err_ref;
5214 }
5215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5216         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5217 }
5218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5219         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5220         CHECK(val->result_ok);
5221         return *val->contents.result;
5222 }
5223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5224         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5225         CHECK(!val->result_ok);
5226         LDKPeerHandleError err_var = (*val->contents.err);
5227         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5228         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5229         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5230         return err_ref;
5231 }
5232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5233         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5234 }
5235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5236         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5237         CHECK(val->result_ok);
5238         return *val->contents.result;
5239 }
5240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5241         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5242         CHECK(!val->result_ok);
5243         LDKPeerHandleError err_var = (*val->contents.err);
5244         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5245         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5246         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5247         return err_ref;
5248 }
5249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5250         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
5251 }
5252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5253         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5254         CHECK(val->result_ok);
5255         LDKDirectionalChannelInfo res_var = (*val->contents.result);
5256         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5257         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5258         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5259         return res_ref;
5260 }
5261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5262         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5263         CHECK(!val->result_ok);
5264         LDKDecodeError err_var = (*val->contents.err);
5265         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5266         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5267         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5268         return err_ref;
5269 }
5270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5271         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
5272 }
5273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5274         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5275         CHECK(val->result_ok);
5276         LDKChannelInfo res_var = (*val->contents.result);
5277         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5278         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5279         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5280         return res_ref;
5281 }
5282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5283         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5284         CHECK(!val->result_ok);
5285         LDKDecodeError err_var = (*val->contents.err);
5286         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5287         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5288         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5289         return err_ref;
5290 }
5291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5292         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
5293 }
5294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5295         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5296         CHECK(val->result_ok);
5297         LDKRoutingFees res_var = (*val->contents.result);
5298         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5299         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5300         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5301         return res_ref;
5302 }
5303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5304         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5305         CHECK(!val->result_ok);
5306         LDKDecodeError err_var = (*val->contents.err);
5307         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5308         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5309         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5310         return err_ref;
5311 }
5312 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5313         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
5314 }
5315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5316         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5317         CHECK(val->result_ok);
5318         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5319         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5320         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5321         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5322         return res_ref;
5323 }
5324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5325         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5326         CHECK(!val->result_ok);
5327         LDKDecodeError err_var = (*val->contents.err);
5328         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5329         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5330         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5331         return err_ref;
5332 }
5333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5334         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5335         ret->datalen = (*env)->GetArrayLength(env, elems);
5336         if (ret->datalen == 0) {
5337                 ret->data = NULL;
5338         } else {
5339                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5340                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5341                 for (size_t i = 0; i < ret->datalen; i++) {
5342                         ret->data[i] = java_elems[i];
5343                 }
5344                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5345         }
5346         return (uint64_t)ret;
5347 }
5348 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5349         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5350         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5351         return ret;
5352 }
5353 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5354         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5355 }
5356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5357         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5358         CHECK(val->result_ok);
5359         LDKNodeInfo res_var = (*val->contents.result);
5360         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5361         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5362         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5363         return res_ref;
5364 }
5365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5366         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5367         CHECK(!val->result_ok);
5368         LDKDecodeError err_var = (*val->contents.err);
5369         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5370         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5371         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5372         return err_ref;
5373 }
5374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5375         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5376 }
5377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5378         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5379         CHECK(val->result_ok);
5380         LDKNetworkGraph res_var = (*val->contents.result);
5381         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5382         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5383         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5384         return res_ref;
5385 }
5386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5387         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5388         CHECK(!val->result_ok);
5389         LDKDecodeError err_var = (*val->contents.err);
5390         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5391         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5392         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5393         return err_ref;
5394 }
5395 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5396         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5397 }
5398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5399         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5400         CHECK(val->result_ok);
5401         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5402         return res_ref;
5403 }
5404 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5405         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5406         CHECK(!val->result_ok);
5407         return *val->contents.err;
5408 }
5409 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5410         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5411 }
5412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5413         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5414         CHECK(val->result_ok);
5415         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5416         *res_conv = (*val->contents.result);
5417         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5418         return (uint64_t)res_conv;
5419 }
5420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5421         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5422         CHECK(!val->result_ok);
5423         LDKDecodeError err_var = (*val->contents.err);
5424         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5425         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5426         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5427         return err_ref;
5428 }
5429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5430         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5431 }
5432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5433         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5434         CHECK(val->result_ok);
5435         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5436         return res_ref;
5437 }
5438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5439         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5440         CHECK(!val->result_ok);
5441         LDKDecodeError err_var = (*val->contents.err);
5442         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5443         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5444         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5445         return err_ref;
5446 }
5447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5448         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5449         ret->datalen = (*env)->GetArrayLength(env, elems);
5450         if (ret->datalen == 0) {
5451                 ret->data = NULL;
5452         } else {
5453                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5454                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5455                 for (size_t i = 0; i < ret->datalen; i++) {
5456                         int64_t arr_elem = java_elems[i];
5457                         LDKUpdateAddHTLC arr_elem_conv;
5458                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5459                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5460                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5461                         ret->data[i] = arr_elem_conv;
5462                 }
5463                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5464         }
5465         return (uint64_t)ret;
5466 }
5467 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5468         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5469         for (size_t i = 0; i < ret.datalen; i++) {
5470                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5471         }
5472         return ret;
5473 }
5474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5475         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5476         ret->datalen = (*env)->GetArrayLength(env, elems);
5477         if (ret->datalen == 0) {
5478                 ret->data = NULL;
5479         } else {
5480                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5481                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5482                 for (size_t i = 0; i < ret->datalen; i++) {
5483                         int64_t arr_elem = java_elems[i];
5484                         LDKUpdateFulfillHTLC arr_elem_conv;
5485                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5486                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5487                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5488                         ret->data[i] = arr_elem_conv;
5489                 }
5490                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5491         }
5492         return (uint64_t)ret;
5493 }
5494 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5495         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5496         for (size_t i = 0; i < ret.datalen; i++) {
5497                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5498         }
5499         return ret;
5500 }
5501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5502         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5503         ret->datalen = (*env)->GetArrayLength(env, elems);
5504         if (ret->datalen == 0) {
5505                 ret->data = NULL;
5506         } else {
5507                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5508                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5509                 for (size_t i = 0; i < ret->datalen; i++) {
5510                         int64_t arr_elem = java_elems[i];
5511                         LDKUpdateFailHTLC arr_elem_conv;
5512                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5513                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5514                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5515                         ret->data[i] = arr_elem_conv;
5516                 }
5517                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5518         }
5519         return (uint64_t)ret;
5520 }
5521 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5522         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5523         for (size_t i = 0; i < ret.datalen; i++) {
5524                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5525         }
5526         return ret;
5527 }
5528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5529         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5530         ret->datalen = (*env)->GetArrayLength(env, elems);
5531         if (ret->datalen == 0) {
5532                 ret->data = NULL;
5533         } else {
5534                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5535                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5536                 for (size_t i = 0; i < ret->datalen; i++) {
5537                         int64_t arr_elem = java_elems[i];
5538                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5539                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5540                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5541                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5542                         ret->data[i] = arr_elem_conv;
5543                 }
5544                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5545         }
5546         return (uint64_t)ret;
5547 }
5548 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5549         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5550         for (size_t i = 0; i < ret.datalen; i++) {
5551                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5552         }
5553         return ret;
5554 }
5555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5556         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5557 }
5558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5559         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5560         CHECK(val->result_ok);
5561         LDKAcceptChannel res_var = (*val->contents.result);
5562         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5563         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5564         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5565         return res_ref;
5566 }
5567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5568         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5569         CHECK(!val->result_ok);
5570         LDKDecodeError err_var = (*val->contents.err);
5571         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5572         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5573         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5574         return err_ref;
5575 }
5576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5577         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5578 }
5579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5580         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5581         CHECK(val->result_ok);
5582         LDKAnnouncementSignatures res_var = (*val->contents.result);
5583         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5584         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5585         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5586         return res_ref;
5587 }
5588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5589         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5590         CHECK(!val->result_ok);
5591         LDKDecodeError err_var = (*val->contents.err);
5592         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5593         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5594         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5595         return err_ref;
5596 }
5597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5598         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5599 }
5600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5601         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5602         CHECK(val->result_ok);
5603         LDKChannelReestablish res_var = (*val->contents.result);
5604         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5605         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5606         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5607         return res_ref;
5608 }
5609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5610         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5611         CHECK(!val->result_ok);
5612         LDKDecodeError err_var = (*val->contents.err);
5613         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5614         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5615         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5616         return err_ref;
5617 }
5618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5619         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5620 }
5621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5622         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5623         CHECK(val->result_ok);
5624         LDKClosingSigned res_var = (*val->contents.result);
5625         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5626         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5627         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5628         return res_ref;
5629 }
5630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5631         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5632         CHECK(!val->result_ok);
5633         LDKDecodeError err_var = (*val->contents.err);
5634         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5635         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5636         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5637         return err_ref;
5638 }
5639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5640         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5641 }
5642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5643         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5644         CHECK(val->result_ok);
5645         LDKCommitmentSigned res_var = (*val->contents.result);
5646         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5647         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5648         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5649         return res_ref;
5650 }
5651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5652         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5653         CHECK(!val->result_ok);
5654         LDKDecodeError err_var = (*val->contents.err);
5655         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5656         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5657         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5658         return err_ref;
5659 }
5660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5661         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5662 }
5663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5664         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5665         CHECK(val->result_ok);
5666         LDKFundingCreated res_var = (*val->contents.result);
5667         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5668         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5669         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5670         return res_ref;
5671 }
5672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5673         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5674         CHECK(!val->result_ok);
5675         LDKDecodeError err_var = (*val->contents.err);
5676         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5677         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5678         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5679         return err_ref;
5680 }
5681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5682         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5683 }
5684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5685         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5686         CHECK(val->result_ok);
5687         LDKFundingSigned res_var = (*val->contents.result);
5688         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5689         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5690         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5691         return res_ref;
5692 }
5693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5694         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5695         CHECK(!val->result_ok);
5696         LDKDecodeError err_var = (*val->contents.err);
5697         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5698         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5699         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5700         return err_ref;
5701 }
5702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5703         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5704 }
5705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5706         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5707         CHECK(val->result_ok);
5708         LDKFundingLocked res_var = (*val->contents.result);
5709         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5710         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5711         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5712         return res_ref;
5713 }
5714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5715         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5716         CHECK(!val->result_ok);
5717         LDKDecodeError err_var = (*val->contents.err);
5718         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5719         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5720         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5721         return err_ref;
5722 }
5723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5724         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5725 }
5726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5727         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5728         CHECK(val->result_ok);
5729         LDKInit res_var = (*val->contents.result);
5730         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5731         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5732         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5733         return res_ref;
5734 }
5735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5736         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5737         CHECK(!val->result_ok);
5738         LDKDecodeError err_var = (*val->contents.err);
5739         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5740         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5741         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5742         return err_ref;
5743 }
5744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5745         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5746 }
5747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5748         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5749         CHECK(val->result_ok);
5750         LDKOpenChannel res_var = (*val->contents.result);
5751         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5752         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5753         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5754         return res_ref;
5755 }
5756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5757         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5758         CHECK(!val->result_ok);
5759         LDKDecodeError err_var = (*val->contents.err);
5760         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5761         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5762         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5763         return err_ref;
5764 }
5765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5766         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5767 }
5768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5769         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5770         CHECK(val->result_ok);
5771         LDKRevokeAndACK res_var = (*val->contents.result);
5772         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5773         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5774         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5775         return res_ref;
5776 }
5777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5778         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5779         CHECK(!val->result_ok);
5780         LDKDecodeError err_var = (*val->contents.err);
5781         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5782         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5783         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5784         return err_ref;
5785 }
5786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5787         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5788 }
5789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5790         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5791         CHECK(val->result_ok);
5792         LDKShutdown res_var = (*val->contents.result);
5793         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5794         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5795         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5796         return res_ref;
5797 }
5798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5799         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5800         CHECK(!val->result_ok);
5801         LDKDecodeError err_var = (*val->contents.err);
5802         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5803         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5804         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5805         return err_ref;
5806 }
5807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5808         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5809 }
5810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5811         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5812         CHECK(val->result_ok);
5813         LDKUpdateFailHTLC res_var = (*val->contents.result);
5814         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5815         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5816         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5817         return res_ref;
5818 }
5819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5820         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5821         CHECK(!val->result_ok);
5822         LDKDecodeError err_var = (*val->contents.err);
5823         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5824         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5825         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5826         return err_ref;
5827 }
5828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5829         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5830 }
5831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5832         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5833         CHECK(val->result_ok);
5834         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5835         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5836         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5837         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5838         return res_ref;
5839 }
5840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5841         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5842         CHECK(!val->result_ok);
5843         LDKDecodeError err_var = (*val->contents.err);
5844         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5845         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5846         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5847         return err_ref;
5848 }
5849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5850         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5851 }
5852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5853         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5854         CHECK(val->result_ok);
5855         LDKUpdateFee res_var = (*val->contents.result);
5856         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5857         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5858         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5859         return res_ref;
5860 }
5861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5862         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5863         CHECK(!val->result_ok);
5864         LDKDecodeError err_var = (*val->contents.err);
5865         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5866         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5867         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5868         return err_ref;
5869 }
5870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5871         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5872 }
5873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5874         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5875         CHECK(val->result_ok);
5876         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5877         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5878         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5879         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5880         return res_ref;
5881 }
5882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5883         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5884         CHECK(!val->result_ok);
5885         LDKDecodeError err_var = (*val->contents.err);
5886         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5887         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5888         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5889         return err_ref;
5890 }
5891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5892         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5893 }
5894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5895         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5896         CHECK(val->result_ok);
5897         LDKUpdateAddHTLC res_var = (*val->contents.result);
5898         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5899         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5900         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5901         return res_ref;
5902 }
5903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5904         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5905         CHECK(!val->result_ok);
5906         LDKDecodeError err_var = (*val->contents.err);
5907         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5908         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5909         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5910         return err_ref;
5911 }
5912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5913         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5914 }
5915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5916         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5917         CHECK(val->result_ok);
5918         LDKPing res_var = (*val->contents.result);
5919         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5920         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5921         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5922         return res_ref;
5923 }
5924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5925         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5926         CHECK(!val->result_ok);
5927         LDKDecodeError err_var = (*val->contents.err);
5928         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5929         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5930         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5931         return err_ref;
5932 }
5933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5934         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5935 }
5936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5937         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5938         CHECK(val->result_ok);
5939         LDKPong res_var = (*val->contents.result);
5940         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5941         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5942         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5943         return res_ref;
5944 }
5945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5946         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5947         CHECK(!val->result_ok);
5948         LDKDecodeError err_var = (*val->contents.err);
5949         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5950         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5951         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5952         return err_ref;
5953 }
5954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5955         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5956 }
5957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5958         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5959         CHECK(val->result_ok);
5960         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5961         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5962         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5963         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5964         return res_ref;
5965 }
5966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5967         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5968         CHECK(!val->result_ok);
5969         LDKDecodeError err_var = (*val->contents.err);
5970         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5971         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5972         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5973         return err_ref;
5974 }
5975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5976         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5977 }
5978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5979         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5980         CHECK(val->result_ok);
5981         LDKChannelAnnouncement res_var = (*val->contents.result);
5982         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5983         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5984         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5985         return res_ref;
5986 }
5987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5988         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5989         CHECK(!val->result_ok);
5990         LDKDecodeError err_var = (*val->contents.err);
5991         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5992         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5993         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5994         return err_ref;
5995 }
5996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5997         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5998 }
5999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6000         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6001         CHECK(val->result_ok);
6002         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
6003         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6004         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6005         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6006         return res_ref;
6007 }
6008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6009         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6010         CHECK(!val->result_ok);
6011         LDKDecodeError err_var = (*val->contents.err);
6012         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6013         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6014         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6015         return err_ref;
6016 }
6017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6018         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
6019 }
6020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6021         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6022         CHECK(val->result_ok);
6023         LDKChannelUpdate res_var = (*val->contents.result);
6024         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6025         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6026         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6027         return res_ref;
6028 }
6029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6030         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6031         CHECK(!val->result_ok);
6032         LDKDecodeError err_var = (*val->contents.err);
6033         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6034         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6035         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6036         return err_ref;
6037 }
6038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6039         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
6040 }
6041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6042         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6043         CHECK(val->result_ok);
6044         LDKErrorMessage res_var = (*val->contents.result);
6045         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6046         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6047         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6048         return res_ref;
6049 }
6050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6051         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6052         CHECK(!val->result_ok);
6053         LDKDecodeError err_var = (*val->contents.err);
6054         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6055         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6056         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6057         return err_ref;
6058 }
6059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6060         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6061 }
6062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6063         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6064         CHECK(val->result_ok);
6065         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
6066         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6067         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6068         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6069         return res_ref;
6070 }
6071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6072         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6073         CHECK(!val->result_ok);
6074         LDKDecodeError err_var = (*val->contents.err);
6075         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6076         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6077         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6078         return err_ref;
6079 }
6080 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6081         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6082 }
6083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6084         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6085         CHECK(val->result_ok);
6086         LDKNodeAnnouncement res_var = (*val->contents.result);
6087         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6088         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6089         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6090         return res_ref;
6091 }
6092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6093         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6094         CHECK(!val->result_ok);
6095         LDKDecodeError err_var = (*val->contents.err);
6096         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6097         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6098         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6099         return err_ref;
6100 }
6101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6102         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
6103 }
6104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6105         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6106         CHECK(val->result_ok);
6107         LDKQueryShortChannelIds res_var = (*val->contents.result);
6108         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6109         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6110         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6111         return res_ref;
6112 }
6113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6114         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6115         CHECK(!val->result_ok);
6116         LDKDecodeError err_var = (*val->contents.err);
6117         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6118         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6119         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6120         return err_ref;
6121 }
6122 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6123         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
6124 }
6125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6126         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6127         CHECK(val->result_ok);
6128         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
6129         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6130         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6131         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6132         return res_ref;
6133 }
6134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6135         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6136         CHECK(!val->result_ok);
6137         LDKDecodeError err_var = (*val->contents.err);
6138         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6139         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6140         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6141         return err_ref;
6142 }
6143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6144         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
6145 }
6146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6147         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6148         CHECK(val->result_ok);
6149         LDKQueryChannelRange res_var = (*val->contents.result);
6150         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6151         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6152         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6153         return res_ref;
6154 }
6155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6156         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6157         CHECK(!val->result_ok);
6158         LDKDecodeError err_var = (*val->contents.err);
6159         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6160         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6161         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6162         return err_ref;
6163 }
6164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6165         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
6166 }
6167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6168         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6169         CHECK(val->result_ok);
6170         LDKReplyChannelRange res_var = (*val->contents.result);
6171         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6172         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6173         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6174         return res_ref;
6175 }
6176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6177         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6178         CHECK(!val->result_ok);
6179         LDKDecodeError err_var = (*val->contents.err);
6180         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6181         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6182         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6183         return err_ref;
6184 }
6185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6186         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
6187 }
6188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6189         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6190         CHECK(val->result_ok);
6191         LDKGossipTimestampFilter res_var = (*val->contents.result);
6192         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6193         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6194         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6195         return res_ref;
6196 }
6197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6198         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6199         CHECK(!val->result_ok);
6200         LDKDecodeError err_var = (*val->contents.err);
6201         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6202         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6203         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6204         return err_ref;
6205 }
6206 static jclass LDKSignOrCreationError_SignError_class = NULL;
6207 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
6208 static jclass LDKSignOrCreationError_CreationError_class = NULL;
6209 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
6210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
6211         LDKSignOrCreationError_SignError_class =
6212                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
6213         CHECK(LDKSignOrCreationError_SignError_class != NULL);
6214         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
6215         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
6216         LDKSignOrCreationError_CreationError_class =
6217                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
6218         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
6219         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
6220         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
6221 }
6222 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6223         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
6224         switch(obj->tag) {
6225                 case LDKSignOrCreationError_SignError: {
6226                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
6227                 }
6228                 case LDKSignOrCreationError_CreationError: {
6229                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
6230                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
6231                 }
6232                 default: abort();
6233         }
6234 }
6235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6236         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
6237 }
6238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6239         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6240         CHECK(val->result_ok);
6241         LDKInvoice res_var = (*val->contents.result);
6242         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6243         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6244         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6245         return res_ref;
6246 }
6247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6248         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6249         CHECK(!val->result_ok);
6250         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
6251         return err_ref;
6252 }
6253 typedef struct LDKMessageSendEventsProvider_JCalls {
6254         atomic_size_t refcnt;
6255         JavaVM *vm;
6256         jweak o;
6257         jmethodID get_and_clear_pending_msg_events_meth;
6258 } LDKMessageSendEventsProvider_JCalls;
6259 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6260         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6261         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6262                 JNIEnv *env;
6263                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6264                 if (get_jenv_res == JNI_EDETACHED) {
6265                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6266                 } else {
6267                         DO_ASSERT(get_jenv_res == JNI_OK);
6268                 }
6269                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6270                 if (get_jenv_res == JNI_EDETACHED) {
6271                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6272                 }
6273                 FREE(j_calls);
6274         }
6275 }
6276 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6277         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6278         JNIEnv *env;
6279         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6280         if (get_jenv_res == JNI_EDETACHED) {
6281                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6282         } else {
6283                 DO_ASSERT(get_jenv_res == JNI_OK);
6284         }
6285         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6286         CHECK(obj != NULL);
6287         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
6288         if ((*env)->ExceptionCheck(env)) {
6289                 (*env)->ExceptionDescribe(env);
6290                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
6291         }
6292         LDKCVec_MessageSendEventZ ret_constr;
6293         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6294         if (ret_constr.datalen > 0)
6295                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6296         else
6297                 ret_constr.data = NULL;
6298         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6299         for (size_t s = 0; s < ret_constr.datalen; s++) {
6300                 int64_t ret_conv_18 = ret_vals[s];
6301                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
6302                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
6303                 ret_constr.data[s] = ret_conv_18_conv;
6304         }
6305         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6306         if (get_jenv_res == JNI_EDETACHED) {
6307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6308         }
6309         return ret_constr;
6310 }
6311 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6312         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6313         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6314 }
6315 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6316         jclass c = (*env)->GetObjectClass(env, o);
6317         CHECK(c != NULL);
6318         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6319         atomic_init(&calls->refcnt, 1);
6320         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6321         calls->o = (*env)->NewWeakGlobalRef(env, o);
6322         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6323         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6324
6325         LDKMessageSendEventsProvider ret = {
6326                 .this_arg = (void*) calls,
6327                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6328                 .free = LDKMessageSendEventsProvider_JCalls_free,
6329         };
6330         return ret;
6331 }
6332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6333         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6334         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6335         return (uint64_t)res_ptr;
6336 }
6337 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6338         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6339         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6340         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6341         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6342         for (size_t s = 0; s < ret_var.datalen; s++) {
6343                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6344                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6345                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6346                 ret_arr_ptr[s] = ret_conv_18_ref;
6347         }
6348         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6349         FREE(ret_var.data);
6350         return ret_arr;
6351 }
6352
6353 typedef struct LDKEventHandler_JCalls {
6354         atomic_size_t refcnt;
6355         JavaVM *vm;
6356         jweak o;
6357         jmethodID handle_event_meth;
6358 } LDKEventHandler_JCalls;
6359 static void LDKEventHandler_JCalls_free(void* this_arg) {
6360         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6361         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6362                 JNIEnv *env;
6363                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6364                 if (get_jenv_res == JNI_EDETACHED) {
6365                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6366                 } else {
6367                         DO_ASSERT(get_jenv_res == JNI_OK);
6368                 }
6369                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6370                 if (get_jenv_res == JNI_EDETACHED) {
6371                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6372                 }
6373                 FREE(j_calls);
6374         }
6375 }
6376 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6377         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6378         JNIEnv *env;
6379         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6380         if (get_jenv_res == JNI_EDETACHED) {
6381                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6382         } else {
6383                 DO_ASSERT(get_jenv_res == JNI_OK);
6384         }
6385         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6386         *event_copy = event;
6387         uint64_t event_ref = (uint64_t)event_copy;
6388         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6389         CHECK(obj != NULL);
6390         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6391         if ((*env)->ExceptionCheck(env)) {
6392                 (*env)->ExceptionDescribe(env);
6393                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
6394         }
6395         if (get_jenv_res == JNI_EDETACHED) {
6396                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6397         }
6398 }
6399 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6400         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6401         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6402 }
6403 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6404         jclass c = (*env)->GetObjectClass(env, o);
6405         CHECK(c != NULL);
6406         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6407         atomic_init(&calls->refcnt, 1);
6408         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6409         calls->o = (*env)->NewWeakGlobalRef(env, o);
6410         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6411         CHECK(calls->handle_event_meth != NULL);
6412
6413         LDKEventHandler ret = {
6414                 .this_arg = (void*) calls,
6415                 .handle_event = handle_event_LDKEventHandler_jcall,
6416                 .free = LDKEventHandler_JCalls_free,
6417         };
6418         return ret;
6419 }
6420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6421         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6422         *res_ptr = LDKEventHandler_init(env, clz, o);
6423         return (uint64_t)res_ptr;
6424 }
6425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6426         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6427         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6428         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6429 }
6430
6431 typedef struct LDKEventsProvider_JCalls {
6432         atomic_size_t refcnt;
6433         JavaVM *vm;
6434         jweak o;
6435         jmethodID process_pending_events_meth;
6436 } LDKEventsProvider_JCalls;
6437 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6438         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6439         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6440                 JNIEnv *env;
6441                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6442                 if (get_jenv_res == JNI_EDETACHED) {
6443                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6444                 } else {
6445                         DO_ASSERT(get_jenv_res == JNI_OK);
6446                 }
6447                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6448                 if (get_jenv_res == JNI_EDETACHED) {
6449                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6450                 }
6451                 FREE(j_calls);
6452         }
6453 }
6454 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6455         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6456         JNIEnv *env;
6457         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6458         if (get_jenv_res == JNI_EDETACHED) {
6459                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6460         } else {
6461                 DO_ASSERT(get_jenv_res == JNI_OK);
6462         }
6463         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6464         *ret = handler;
6465         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6466         CHECK(obj != NULL);
6467         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6468         if ((*env)->ExceptionCheck(env)) {
6469                 (*env)->ExceptionDescribe(env);
6470                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
6471         }
6472         if (get_jenv_res == JNI_EDETACHED) {
6473                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6474         }
6475 }
6476 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6477         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6478         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6479 }
6480 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6481         jclass c = (*env)->GetObjectClass(env, o);
6482         CHECK(c != NULL);
6483         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6484         atomic_init(&calls->refcnt, 1);
6485         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6486         calls->o = (*env)->NewWeakGlobalRef(env, o);
6487         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6488         CHECK(calls->process_pending_events_meth != NULL);
6489
6490         LDKEventsProvider ret = {
6491                 .this_arg = (void*) calls,
6492                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6493                 .free = LDKEventsProvider_JCalls_free,
6494         };
6495         return ret;
6496 }
6497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6498         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6499         *res_ptr = LDKEventsProvider_init(env, clz, o);
6500         return (uint64_t)res_ptr;
6501 }
6502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6503         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6504         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6505         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6506                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6507                 LDKEventHandler_JCalls_cloned(&handler_conv);
6508         }
6509         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6510 }
6511
6512 typedef struct LDKAccess_JCalls {
6513         atomic_size_t refcnt;
6514         JavaVM *vm;
6515         jweak o;
6516         jmethodID get_utxo_meth;
6517 } LDKAccess_JCalls;
6518 static void LDKAccess_JCalls_free(void* this_arg) {
6519         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6520         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6521                 JNIEnv *env;
6522                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6523                 if (get_jenv_res == JNI_EDETACHED) {
6524                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6525                 } else {
6526                         DO_ASSERT(get_jenv_res == JNI_OK);
6527                 }
6528                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6529                 if (get_jenv_res == JNI_EDETACHED) {
6530                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6531                 }
6532                 FREE(j_calls);
6533         }
6534 }
6535 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6536         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6537         JNIEnv *env;
6538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6539         if (get_jenv_res == JNI_EDETACHED) {
6540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6541         } else {
6542                 DO_ASSERT(get_jenv_res == JNI_OK);
6543         }
6544         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6545         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6546         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6547         CHECK(obj != NULL);
6548         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6549         if ((*env)->ExceptionCheck(env)) {
6550                 (*env)->ExceptionDescribe(env);
6551                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6552         }
6553         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6554         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6555         if (get_jenv_res == JNI_EDETACHED) {
6556                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6557         }
6558         return ret_conv;
6559 }
6560 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6561         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6562         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6563 }
6564 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6565         jclass c = (*env)->GetObjectClass(env, o);
6566         CHECK(c != NULL);
6567         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6568         atomic_init(&calls->refcnt, 1);
6569         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6570         calls->o = (*env)->NewWeakGlobalRef(env, o);
6571         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6572         CHECK(calls->get_utxo_meth != NULL);
6573
6574         LDKAccess ret = {
6575                 .this_arg = (void*) calls,
6576                 .get_utxo = get_utxo_LDKAccess_jcall,
6577                 .free = LDKAccess_JCalls_free,
6578         };
6579         return ret;
6580 }
6581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6582         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6583         *res_ptr = LDKAccess_init(env, clz, o);
6584         return (uint64_t)res_ptr;
6585 }
6586 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) {
6587         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6588         unsigned char genesis_hash_arr[32];
6589         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6590         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6591         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6592         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6593         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6594         return (uint64_t)ret_conv;
6595 }
6596
6597 typedef struct LDKListen_JCalls {
6598         atomic_size_t refcnt;
6599         JavaVM *vm;
6600         jweak o;
6601         jmethodID block_connected_meth;
6602         jmethodID block_disconnected_meth;
6603 } LDKListen_JCalls;
6604 static void LDKListen_JCalls_free(void* this_arg) {
6605         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6606         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6607                 JNIEnv *env;
6608                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6609                 if (get_jenv_res == JNI_EDETACHED) {
6610                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6611                 } else {
6612                         DO_ASSERT(get_jenv_res == JNI_OK);
6613                 }
6614                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6615                 if (get_jenv_res == JNI_EDETACHED) {
6616                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6617                 }
6618                 FREE(j_calls);
6619         }
6620 }
6621 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6622         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6623         JNIEnv *env;
6624         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6625         if (get_jenv_res == JNI_EDETACHED) {
6626                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6627         } else {
6628                 DO_ASSERT(get_jenv_res == JNI_OK);
6629         }
6630         LDKu8slice block_var = block;
6631         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6632         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6633         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6634         CHECK(obj != NULL);
6635         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6636         if ((*env)->ExceptionCheck(env)) {
6637                 (*env)->ExceptionDescribe(env);
6638                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
6639         }
6640         if (get_jenv_res == JNI_EDETACHED) {
6641                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6642         }
6643 }
6644 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6645         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6646         JNIEnv *env;
6647         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6648         if (get_jenv_res == JNI_EDETACHED) {
6649                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6650         } else {
6651                 DO_ASSERT(get_jenv_res == JNI_OK);
6652         }
6653         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6654         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6655         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6656         CHECK(obj != NULL);
6657         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6658         if ((*env)->ExceptionCheck(env)) {
6659                 (*env)->ExceptionDescribe(env);
6660                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
6661         }
6662         if (get_jenv_res == JNI_EDETACHED) {
6663                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6664         }
6665 }
6666 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
6667         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
6668         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6669 }
6670 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6671         jclass c = (*env)->GetObjectClass(env, o);
6672         CHECK(c != NULL);
6673         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6674         atomic_init(&calls->refcnt, 1);
6675         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6676         calls->o = (*env)->NewWeakGlobalRef(env, o);
6677         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6678         CHECK(calls->block_connected_meth != NULL);
6679         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6680         CHECK(calls->block_disconnected_meth != NULL);
6681
6682         LDKListen ret = {
6683                 .this_arg = (void*) calls,
6684                 .block_connected = block_connected_LDKListen_jcall,
6685                 .block_disconnected = block_disconnected_LDKListen_jcall,
6686                 .free = LDKListen_JCalls_free,
6687         };
6688         return ret;
6689 }
6690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6691         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6692         *res_ptr = LDKListen_init(env, clz, o);
6693         return (uint64_t)res_ptr;
6694 }
6695 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) {
6696         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6697         LDKu8slice block_ref;
6698         block_ref.datalen = (*env)->GetArrayLength(env, block);
6699         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6700         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6701         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6702 }
6703
6704 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) {
6705         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6706         unsigned char header_arr[80];
6707         CHECK((*env)->GetArrayLength(env, header) == 80);
6708         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6709         unsigned char (*header_ref)[80] = &header_arr;
6710         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6711 }
6712
6713 typedef struct LDKConfirm_JCalls {
6714         atomic_size_t refcnt;
6715         JavaVM *vm;
6716         jweak o;
6717         jmethodID transactions_confirmed_meth;
6718         jmethodID transaction_unconfirmed_meth;
6719         jmethodID best_block_updated_meth;
6720         jmethodID get_relevant_txids_meth;
6721 } LDKConfirm_JCalls;
6722 static void LDKConfirm_JCalls_free(void* this_arg) {
6723         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6724         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6725                 JNIEnv *env;
6726                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6727                 if (get_jenv_res == JNI_EDETACHED) {
6728                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6729                 } else {
6730                         DO_ASSERT(get_jenv_res == JNI_OK);
6731                 }
6732                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6733                 if (get_jenv_res == JNI_EDETACHED) {
6734                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6735                 }
6736                 FREE(j_calls);
6737         }
6738 }
6739 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6740         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6741         JNIEnv *env;
6742         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6743         if (get_jenv_res == JNI_EDETACHED) {
6744                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6745         } else {
6746                 DO_ASSERT(get_jenv_res == JNI_OK);
6747         }
6748         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6749         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6750         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6751         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6752         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6753         for (size_t y = 0; y < txdata_var.datalen; y++) {
6754                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6755                 *txdata_conv_24_ref = txdata_var.data[y];
6756                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6757         }
6758         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6759         FREE(txdata_var.data);
6760         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6761         CHECK(obj != NULL);
6762         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6763         if ((*env)->ExceptionCheck(env)) {
6764                 (*env)->ExceptionDescribe(env);
6765                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
6766         }
6767         if (get_jenv_res == JNI_EDETACHED) {
6768                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6769         }
6770 }
6771 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6772         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6773         JNIEnv *env;
6774         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6775         if (get_jenv_res == JNI_EDETACHED) {
6776                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6777         } else {
6778                 DO_ASSERT(get_jenv_res == JNI_OK);
6779         }
6780         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6781         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6782         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6783         CHECK(obj != NULL);
6784         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6785         if ((*env)->ExceptionCheck(env)) {
6786                 (*env)->ExceptionDescribe(env);
6787                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
6788         }
6789         if (get_jenv_res == JNI_EDETACHED) {
6790                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6791         }
6792 }
6793 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6794         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6795         JNIEnv *env;
6796         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6797         if (get_jenv_res == JNI_EDETACHED) {
6798                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6799         } else {
6800                 DO_ASSERT(get_jenv_res == JNI_OK);
6801         }
6802         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6803         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6804         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6805         CHECK(obj != NULL);
6806         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6807         if ((*env)->ExceptionCheck(env)) {
6808                 (*env)->ExceptionDescribe(env);
6809                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
6810         }
6811         if (get_jenv_res == JNI_EDETACHED) {
6812                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6813         }
6814 }
6815 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6816         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6817         JNIEnv *env;
6818         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6819         if (get_jenv_res == JNI_EDETACHED) {
6820                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6821         } else {
6822                 DO_ASSERT(get_jenv_res == JNI_OK);
6823         }
6824         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6825         CHECK(obj != NULL);
6826         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6827         if ((*env)->ExceptionCheck(env)) {
6828                 (*env)->ExceptionDescribe(env);
6829                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
6830         }
6831         LDKCVec_TxidZ ret_constr;
6832         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6833         if (ret_constr.datalen > 0)
6834                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6835         else
6836                 ret_constr.data = NULL;
6837         for (size_t i = 0; i < ret_constr.datalen; i++) {
6838                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6839                 LDKThirtyTwoBytes ret_conv_8_ref;
6840                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6841                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6842                 ret_constr.data[i] = ret_conv_8_ref;
6843         }
6844         if (get_jenv_res == JNI_EDETACHED) {
6845                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6846         }
6847         return ret_constr;
6848 }
6849 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
6850         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
6851         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6852 }
6853 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6854         jclass c = (*env)->GetObjectClass(env, o);
6855         CHECK(c != NULL);
6856         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6857         atomic_init(&calls->refcnt, 1);
6858         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6859         calls->o = (*env)->NewWeakGlobalRef(env, o);
6860         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6861         CHECK(calls->transactions_confirmed_meth != NULL);
6862         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6863         CHECK(calls->transaction_unconfirmed_meth != NULL);
6864         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6865         CHECK(calls->best_block_updated_meth != NULL);
6866         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6867         CHECK(calls->get_relevant_txids_meth != NULL);
6868
6869         LDKConfirm ret = {
6870                 .this_arg = (void*) calls,
6871                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6872                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6873                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6874                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6875                 .free = LDKConfirm_JCalls_free,
6876         };
6877         return ret;
6878 }
6879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6880         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6881         *res_ptr = LDKConfirm_init(env, clz, o);
6882         return (uint64_t)res_ptr;
6883 }
6884 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) {
6885         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6886         unsigned char header_arr[80];
6887         CHECK((*env)->GetArrayLength(env, header) == 80);
6888         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6889         unsigned char (*header_ref)[80] = &header_arr;
6890         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6891         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6892         if (txdata_constr.datalen > 0)
6893                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6894         else
6895                 txdata_constr.data = NULL;
6896         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6897         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6898                 int64_t txdata_conv_24 = txdata_vals[y];
6899                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6900                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6901                 txdata_constr.data[y] = txdata_conv_24_conv;
6902         }
6903         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6904         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6905 }
6906
6907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6908         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6909         unsigned char txid_arr[32];
6910         CHECK((*env)->GetArrayLength(env, txid) == 32);
6911         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6912         unsigned char (*txid_ref)[32] = &txid_arr;
6913         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6914 }
6915
6916 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) {
6917         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6918         unsigned char header_arr[80];
6919         CHECK((*env)->GetArrayLength(env, header) == 80);
6920         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6921         unsigned char (*header_ref)[80] = &header_arr;
6922         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6923 }
6924
6925 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6926         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6927         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6928         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6929         ;
6930         for (size_t i = 0; i < ret_var.datalen; i++) {
6931                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6932                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6933                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6934         }
6935         FREE(ret_var.data);
6936         return ret_arr;
6937 }
6938
6939 typedef struct LDKFilter_JCalls {
6940         atomic_size_t refcnt;
6941         JavaVM *vm;
6942         jweak o;
6943         jmethodID register_tx_meth;
6944         jmethodID register_output_meth;
6945 } LDKFilter_JCalls;
6946 static void LDKFilter_JCalls_free(void* this_arg) {
6947         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6948         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6949                 JNIEnv *env;
6950                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6951                 if (get_jenv_res == JNI_EDETACHED) {
6952                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6953                 } else {
6954                         DO_ASSERT(get_jenv_res == JNI_OK);
6955                 }
6956                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6957                 if (get_jenv_res == JNI_EDETACHED) {
6958                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6959                 }
6960                 FREE(j_calls);
6961         }
6962 }
6963 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6964         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6965         JNIEnv *env;
6966         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6967         if (get_jenv_res == JNI_EDETACHED) {
6968                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6969         } else {
6970                 DO_ASSERT(get_jenv_res == JNI_OK);
6971         }
6972         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6973         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6974         LDKu8slice script_pubkey_var = script_pubkey;
6975         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6976         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6977         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6978         CHECK(obj != NULL);
6979         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6980         if ((*env)->ExceptionCheck(env)) {
6981                 (*env)->ExceptionDescribe(env);
6982                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
6983         }
6984         if (get_jenv_res == JNI_EDETACHED) {
6985                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6986         }
6987 }
6988 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6989         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6990         JNIEnv *env;
6991         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6992         if (get_jenv_res == JNI_EDETACHED) {
6993                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6994         } else {
6995                 DO_ASSERT(get_jenv_res == JNI_OK);
6996         }
6997         LDKWatchedOutput output_var = output;
6998         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6999         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7000         uint64_t output_ref = (uint64_t)output_var.inner;
7001         if (output_var.is_owned) {
7002                 output_ref |= 1;
7003         }
7004         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7005         CHECK(obj != NULL);
7006         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7007         if ((*env)->ExceptionCheck(env)) {
7008                 (*env)->ExceptionDescribe(env);
7009                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7010         }
7011         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
7012         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
7013         if (get_jenv_res == JNI_EDETACHED) {
7014                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7015         }
7016         return ret_conv;
7017 }
7018 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7019         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7020         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7021 }
7022 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7023         jclass c = (*env)->GetObjectClass(env, o);
7024         CHECK(c != NULL);
7025         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7026         atomic_init(&calls->refcnt, 1);
7027         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7028         calls->o = (*env)->NewWeakGlobalRef(env, o);
7029         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7030         CHECK(calls->register_tx_meth != NULL);
7031         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7032         CHECK(calls->register_output_meth != NULL);
7033
7034         LDKFilter ret = {
7035                 .this_arg = (void*) calls,
7036                 .register_tx = register_tx_LDKFilter_jcall,
7037                 .register_output = register_output_LDKFilter_jcall,
7038                 .free = LDKFilter_JCalls_free,
7039         };
7040         return ret;
7041 }
7042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7043         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7044         *res_ptr = LDKFilter_init(env, clz, o);
7045         return (uint64_t)res_ptr;
7046 }
7047 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) {
7048         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7049         unsigned char txid_arr[32];
7050         CHECK((*env)->GetArrayLength(env, txid) == 32);
7051         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7052         unsigned char (*txid_ref)[32] = &txid_arr;
7053         LDKu8slice script_pubkey_ref;
7054         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7055         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7056         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7057         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7058 }
7059
7060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7061         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7062         LDKWatchedOutput output_conv;
7063         output_conv.inner = (void*)(output & (~1));
7064         output_conv.is_owned = (output & 1) || (output == 0);
7065         output_conv = WatchedOutput_clone(&output_conv);
7066         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7067         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7068         uint64_t ret_ref = (uint64_t)ret_copy;
7069         return ret_ref;
7070 }
7071
7072 typedef struct LDKPersist_JCalls {
7073         atomic_size_t refcnt;
7074         JavaVM *vm;
7075         jweak o;
7076         jmethodID persist_new_channel_meth;
7077         jmethodID update_persisted_channel_meth;
7078 } LDKPersist_JCalls;
7079 static void LDKPersist_JCalls_free(void* this_arg) {
7080         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7081         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7082                 JNIEnv *env;
7083                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7084                 if (get_jenv_res == JNI_EDETACHED) {
7085                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7086                 } else {
7087                         DO_ASSERT(get_jenv_res == JNI_OK);
7088                 }
7089                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7090                 if (get_jenv_res == JNI_EDETACHED) {
7091                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7092                 }
7093                 FREE(j_calls);
7094         }
7095 }
7096 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
7097         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7098         JNIEnv *env;
7099         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7100         if (get_jenv_res == JNI_EDETACHED) {
7101                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7102         } else {
7103                 DO_ASSERT(get_jenv_res == JNI_OK);
7104         }
7105         LDKOutPoint id_var = id;
7106         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7107         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7108         uint64_t id_ref = (uint64_t)id_var.inner;
7109         if (id_var.is_owned) {
7110                 id_ref |= 1;
7111         }
7112         LDKChannelMonitor data_var = *data;
7113         data_var = ChannelMonitor_clone(data);
7114         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7115         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7116         uint64_t data_ref = (uint64_t)data_var.inner;
7117         if (data_var.is_owned) {
7118                 data_ref |= 1;
7119         }
7120         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7121         CHECK(obj != NULL);
7122         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
7123         if ((*env)->ExceptionCheck(env)) {
7124                 (*env)->ExceptionDescribe(env);
7125                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
7126         }
7127         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7128         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7129         if (get_jenv_res == JNI_EDETACHED) {
7130                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7131         }
7132         return ret_conv;
7133 }
7134 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
7135         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7136         JNIEnv *env;
7137         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7138         if (get_jenv_res == JNI_EDETACHED) {
7139                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7140         } else {
7141                 DO_ASSERT(get_jenv_res == JNI_OK);
7142         }
7143         LDKOutPoint id_var = id;
7144         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7145         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7146         uint64_t id_ref = (uint64_t)id_var.inner;
7147         if (id_var.is_owned) {
7148                 id_ref |= 1;
7149         }
7150         LDKChannelMonitorUpdate update_var = *update;
7151         update_var = ChannelMonitorUpdate_clone(update);
7152         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7153         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7154         uint64_t update_ref = (uint64_t)update_var.inner;
7155         if (update_var.is_owned) {
7156                 update_ref |= 1;
7157         }
7158         LDKChannelMonitor data_var = *data;
7159         data_var = ChannelMonitor_clone(data);
7160         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7161         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7162         uint64_t data_ref = (uint64_t)data_var.inner;
7163         if (data_var.is_owned) {
7164                 data_ref |= 1;
7165         }
7166         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7167         CHECK(obj != NULL);
7168         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7169         if ((*env)->ExceptionCheck(env)) {
7170                 (*env)->ExceptionDescribe(env);
7171                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7172         }
7173         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7174         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7175         if (get_jenv_res == JNI_EDETACHED) {
7176                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7177         }
7178         return ret_conv;
7179 }
7180 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7181         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7182         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7183 }
7184 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7185         jclass c = (*env)->GetObjectClass(env, o);
7186         CHECK(c != NULL);
7187         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7188         atomic_init(&calls->refcnt, 1);
7189         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7190         calls->o = (*env)->NewWeakGlobalRef(env, o);
7191         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7192         CHECK(calls->persist_new_channel_meth != NULL);
7193         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7194         CHECK(calls->update_persisted_channel_meth != NULL);
7195
7196         LDKPersist ret = {
7197                 .this_arg = (void*) calls,
7198                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7199                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7200                 .free = LDKPersist_JCalls_free,
7201         };
7202         return ret;
7203 }
7204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7205         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7206         *res_ptr = LDKPersist_init(env, clz, o);
7207         return (uint64_t)res_ptr;
7208 }
7209 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) {
7210         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7211         LDKOutPoint id_conv;
7212         id_conv.inner = (void*)(id & (~1));
7213         id_conv.is_owned = (id & 1) || (id == 0);
7214         id_conv = OutPoint_clone(&id_conv);
7215         LDKChannelMonitor data_conv;
7216         data_conv.inner = (void*)(data & (~1));
7217         data_conv.is_owned = false;
7218         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7219         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
7220         return (uint64_t)ret_conv;
7221 }
7222
7223 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) {
7224         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7225         LDKOutPoint id_conv;
7226         id_conv.inner = (void*)(id & (~1));
7227         id_conv.is_owned = (id & 1) || (id == 0);
7228         id_conv = OutPoint_clone(&id_conv);
7229         LDKChannelMonitorUpdate update_conv;
7230         update_conv.inner = (void*)(update & (~1));
7231         update_conv.is_owned = false;
7232         LDKChannelMonitor data_conv;
7233         data_conv.inner = (void*)(data & (~1));
7234         data_conv.is_owned = false;
7235         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7236         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
7237         return (uint64_t)ret_conv;
7238 }
7239
7240 typedef struct LDKChannelMessageHandler_JCalls {
7241         atomic_size_t refcnt;
7242         JavaVM *vm;
7243         jweak o;
7244         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7245         jmethodID handle_open_channel_meth;
7246         jmethodID handle_accept_channel_meth;
7247         jmethodID handle_funding_created_meth;
7248         jmethodID handle_funding_signed_meth;
7249         jmethodID handle_funding_locked_meth;
7250         jmethodID handle_shutdown_meth;
7251         jmethodID handle_closing_signed_meth;
7252         jmethodID handle_update_add_htlc_meth;
7253         jmethodID handle_update_fulfill_htlc_meth;
7254         jmethodID handle_update_fail_htlc_meth;
7255         jmethodID handle_update_fail_malformed_htlc_meth;
7256         jmethodID handle_commitment_signed_meth;
7257         jmethodID handle_revoke_and_ack_meth;
7258         jmethodID handle_update_fee_meth;
7259         jmethodID handle_announcement_signatures_meth;
7260         jmethodID peer_disconnected_meth;
7261         jmethodID peer_connected_meth;
7262         jmethodID handle_channel_reestablish_meth;
7263         jmethodID handle_channel_update_meth;
7264         jmethodID handle_error_meth;
7265 } LDKChannelMessageHandler_JCalls;
7266 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7267         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7268         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7269                 JNIEnv *env;
7270                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7271                 if (get_jenv_res == JNI_EDETACHED) {
7272                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7273                 } else {
7274                         DO_ASSERT(get_jenv_res == JNI_OK);
7275                 }
7276                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7277                 if (get_jenv_res == JNI_EDETACHED) {
7278                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7279                 }
7280                 FREE(j_calls);
7281         }
7282 }
7283 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7284         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7285         JNIEnv *env;
7286         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7287         if (get_jenv_res == JNI_EDETACHED) {
7288                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7289         } else {
7290                 DO_ASSERT(get_jenv_res == JNI_OK);
7291         }
7292         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7293         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7294         LDKInitFeatures their_features_var = their_features;
7295         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7296         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7297         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7298         if (their_features_var.is_owned) {
7299                 their_features_ref |= 1;
7300         }
7301         LDKOpenChannel msg_var = *msg;
7302         msg_var = OpenChannel_clone(msg);
7303         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7304         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7305         uint64_t msg_ref = (uint64_t)msg_var.inner;
7306         if (msg_var.is_owned) {
7307                 msg_ref |= 1;
7308         }
7309         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7310         CHECK(obj != NULL);
7311         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7312         if ((*env)->ExceptionCheck(env)) {
7313                 (*env)->ExceptionDescribe(env);
7314                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
7315         }
7316         if (get_jenv_res == JNI_EDETACHED) {
7317                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7318         }
7319 }
7320 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7321         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7322         JNIEnv *env;
7323         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7324         if (get_jenv_res == JNI_EDETACHED) {
7325                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7326         } else {
7327                 DO_ASSERT(get_jenv_res == JNI_OK);
7328         }
7329         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7330         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7331         LDKInitFeatures their_features_var = their_features;
7332         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7333         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7334         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7335         if (their_features_var.is_owned) {
7336                 their_features_ref |= 1;
7337         }
7338         LDKAcceptChannel msg_var = *msg;
7339         msg_var = AcceptChannel_clone(msg);
7340         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7341         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7342         uint64_t msg_ref = (uint64_t)msg_var.inner;
7343         if (msg_var.is_owned) {
7344                 msg_ref |= 1;
7345         }
7346         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7347         CHECK(obj != NULL);
7348         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7349         if ((*env)->ExceptionCheck(env)) {
7350                 (*env)->ExceptionDescribe(env);
7351                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
7352         }
7353         if (get_jenv_res == JNI_EDETACHED) {
7354                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7355         }
7356 }
7357 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7358         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7359         JNIEnv *env;
7360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7361         if (get_jenv_res == JNI_EDETACHED) {
7362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7363         } else {
7364                 DO_ASSERT(get_jenv_res == JNI_OK);
7365         }
7366         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7367         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7368         LDKFundingCreated msg_var = *msg;
7369         msg_var = FundingCreated_clone(msg);
7370         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7371         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7372         uint64_t msg_ref = (uint64_t)msg_var.inner;
7373         if (msg_var.is_owned) {
7374                 msg_ref |= 1;
7375         }
7376         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7377         CHECK(obj != NULL);
7378         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7379         if ((*env)->ExceptionCheck(env)) {
7380                 (*env)->ExceptionDescribe(env);
7381                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
7382         }
7383         if (get_jenv_res == JNI_EDETACHED) {
7384                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7385         }
7386 }
7387 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7388         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7389         JNIEnv *env;
7390         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7391         if (get_jenv_res == JNI_EDETACHED) {
7392                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7393         } else {
7394                 DO_ASSERT(get_jenv_res == JNI_OK);
7395         }
7396         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7397         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7398         LDKFundingSigned msg_var = *msg;
7399         msg_var = FundingSigned_clone(msg);
7400         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7401         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7402         uint64_t msg_ref = (uint64_t)msg_var.inner;
7403         if (msg_var.is_owned) {
7404                 msg_ref |= 1;
7405         }
7406         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7407         CHECK(obj != NULL);
7408         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7409         if ((*env)->ExceptionCheck(env)) {
7410                 (*env)->ExceptionDescribe(env);
7411                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
7412         }
7413         if (get_jenv_res == JNI_EDETACHED) {
7414                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7415         }
7416 }
7417 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7418         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7419         JNIEnv *env;
7420         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7421         if (get_jenv_res == JNI_EDETACHED) {
7422                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7423         } else {
7424                 DO_ASSERT(get_jenv_res == JNI_OK);
7425         }
7426         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7427         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7428         LDKFundingLocked msg_var = *msg;
7429         msg_var = FundingLocked_clone(msg);
7430         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7431         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7432         uint64_t msg_ref = (uint64_t)msg_var.inner;
7433         if (msg_var.is_owned) {
7434                 msg_ref |= 1;
7435         }
7436         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7437         CHECK(obj != NULL);
7438         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7439         if ((*env)->ExceptionCheck(env)) {
7440                 (*env)->ExceptionDescribe(env);
7441                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
7442         }
7443         if (get_jenv_res == JNI_EDETACHED) {
7444                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7445         }
7446 }
7447 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7448         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7449         JNIEnv *env;
7450         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7451         if (get_jenv_res == JNI_EDETACHED) {
7452                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7453         } else {
7454                 DO_ASSERT(get_jenv_res == JNI_OK);
7455         }
7456         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7457         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7458         LDKInitFeatures their_features_var = *their_features;
7459         their_features_var = InitFeatures_clone(their_features);
7460         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7461         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7462         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7463         if (their_features_var.is_owned) {
7464                 their_features_ref |= 1;
7465         }
7466         LDKShutdown msg_var = *msg;
7467         msg_var = Shutdown_clone(msg);
7468         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7469         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7470         uint64_t msg_ref = (uint64_t)msg_var.inner;
7471         if (msg_var.is_owned) {
7472                 msg_ref |= 1;
7473         }
7474         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7475         CHECK(obj != NULL);
7476         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7477         if ((*env)->ExceptionCheck(env)) {
7478                 (*env)->ExceptionDescribe(env);
7479                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
7480         }
7481         if (get_jenv_res == JNI_EDETACHED) {
7482                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7483         }
7484 }
7485 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7486         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7487         JNIEnv *env;
7488         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7489         if (get_jenv_res == JNI_EDETACHED) {
7490                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7491         } else {
7492                 DO_ASSERT(get_jenv_res == JNI_OK);
7493         }
7494         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7495         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7496         LDKClosingSigned msg_var = *msg;
7497         msg_var = ClosingSigned_clone(msg);
7498         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7499         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7500         uint64_t msg_ref = (uint64_t)msg_var.inner;
7501         if (msg_var.is_owned) {
7502                 msg_ref |= 1;
7503         }
7504         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7505         CHECK(obj != NULL);
7506         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7507         if ((*env)->ExceptionCheck(env)) {
7508                 (*env)->ExceptionDescribe(env);
7509                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
7510         }
7511         if (get_jenv_res == JNI_EDETACHED) {
7512                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7513         }
7514 }
7515 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7516         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7517         JNIEnv *env;
7518         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7519         if (get_jenv_res == JNI_EDETACHED) {
7520                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7521         } else {
7522                 DO_ASSERT(get_jenv_res == JNI_OK);
7523         }
7524         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7525         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7526         LDKUpdateAddHTLC msg_var = *msg;
7527         msg_var = UpdateAddHTLC_clone(msg);
7528         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7529         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7530         uint64_t msg_ref = (uint64_t)msg_var.inner;
7531         if (msg_var.is_owned) {
7532                 msg_ref |= 1;
7533         }
7534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7535         CHECK(obj != NULL);
7536         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7537         if ((*env)->ExceptionCheck(env)) {
7538                 (*env)->ExceptionDescribe(env);
7539                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
7540         }
7541         if (get_jenv_res == JNI_EDETACHED) {
7542                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7543         }
7544 }
7545 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7546         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7547         JNIEnv *env;
7548         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7549         if (get_jenv_res == JNI_EDETACHED) {
7550                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7551         } else {
7552                 DO_ASSERT(get_jenv_res == JNI_OK);
7553         }
7554         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7555         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7556         LDKUpdateFulfillHTLC msg_var = *msg;
7557         msg_var = UpdateFulfillHTLC_clone(msg);
7558         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7559         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7560         uint64_t msg_ref = (uint64_t)msg_var.inner;
7561         if (msg_var.is_owned) {
7562                 msg_ref |= 1;
7563         }
7564         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7565         CHECK(obj != NULL);
7566         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7567         if ((*env)->ExceptionCheck(env)) {
7568                 (*env)->ExceptionDescribe(env);
7569                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
7570         }
7571         if (get_jenv_res == JNI_EDETACHED) {
7572                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7573         }
7574 }
7575 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7576         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7577         JNIEnv *env;
7578         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7579         if (get_jenv_res == JNI_EDETACHED) {
7580                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7581         } else {
7582                 DO_ASSERT(get_jenv_res == JNI_OK);
7583         }
7584         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7585         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7586         LDKUpdateFailHTLC msg_var = *msg;
7587         msg_var = UpdateFailHTLC_clone(msg);
7588         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7589         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7590         uint64_t msg_ref = (uint64_t)msg_var.inner;
7591         if (msg_var.is_owned) {
7592                 msg_ref |= 1;
7593         }
7594         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7595         CHECK(obj != NULL);
7596         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7597         if ((*env)->ExceptionCheck(env)) {
7598                 (*env)->ExceptionDescribe(env);
7599                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
7600         }
7601         if (get_jenv_res == JNI_EDETACHED) {
7602                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7603         }
7604 }
7605 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7606         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7607         JNIEnv *env;
7608         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7609         if (get_jenv_res == JNI_EDETACHED) {
7610                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7611         } else {
7612                 DO_ASSERT(get_jenv_res == JNI_OK);
7613         }
7614         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7615         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7616         LDKUpdateFailMalformedHTLC msg_var = *msg;
7617         msg_var = UpdateFailMalformedHTLC_clone(msg);
7618         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7619         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7620         uint64_t msg_ref = (uint64_t)msg_var.inner;
7621         if (msg_var.is_owned) {
7622                 msg_ref |= 1;
7623         }
7624         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7625         CHECK(obj != NULL);
7626         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7627         if ((*env)->ExceptionCheck(env)) {
7628                 (*env)->ExceptionDescribe(env);
7629                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
7630         }
7631         if (get_jenv_res == JNI_EDETACHED) {
7632                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7633         }
7634 }
7635 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7636         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7637         JNIEnv *env;
7638         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7639         if (get_jenv_res == JNI_EDETACHED) {
7640                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7641         } else {
7642                 DO_ASSERT(get_jenv_res == JNI_OK);
7643         }
7644         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7645         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7646         LDKCommitmentSigned msg_var = *msg;
7647         msg_var = CommitmentSigned_clone(msg);
7648         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7649         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7650         uint64_t msg_ref = (uint64_t)msg_var.inner;
7651         if (msg_var.is_owned) {
7652                 msg_ref |= 1;
7653         }
7654         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7655         CHECK(obj != NULL);
7656         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7657         if ((*env)->ExceptionCheck(env)) {
7658                 (*env)->ExceptionDescribe(env);
7659                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
7660         }
7661         if (get_jenv_res == JNI_EDETACHED) {
7662                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7663         }
7664 }
7665 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7666         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7667         JNIEnv *env;
7668         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7669         if (get_jenv_res == JNI_EDETACHED) {
7670                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7671         } else {
7672                 DO_ASSERT(get_jenv_res == JNI_OK);
7673         }
7674         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7675         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7676         LDKRevokeAndACK msg_var = *msg;
7677         msg_var = RevokeAndACK_clone(msg);
7678         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7679         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7680         uint64_t msg_ref = (uint64_t)msg_var.inner;
7681         if (msg_var.is_owned) {
7682                 msg_ref |= 1;
7683         }
7684         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7685         CHECK(obj != NULL);
7686         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7687         if ((*env)->ExceptionCheck(env)) {
7688                 (*env)->ExceptionDescribe(env);
7689                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
7690         }
7691         if (get_jenv_res == JNI_EDETACHED) {
7692                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7693         }
7694 }
7695 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7696         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7697         JNIEnv *env;
7698         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7699         if (get_jenv_res == JNI_EDETACHED) {
7700                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7701         } else {
7702                 DO_ASSERT(get_jenv_res == JNI_OK);
7703         }
7704         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7705         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7706         LDKUpdateFee msg_var = *msg;
7707         msg_var = UpdateFee_clone(msg);
7708         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7709         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7710         uint64_t msg_ref = (uint64_t)msg_var.inner;
7711         if (msg_var.is_owned) {
7712                 msg_ref |= 1;
7713         }
7714         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7715         CHECK(obj != NULL);
7716         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7717         if ((*env)->ExceptionCheck(env)) {
7718                 (*env)->ExceptionDescribe(env);
7719                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
7720         }
7721         if (get_jenv_res == JNI_EDETACHED) {
7722                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7723         }
7724 }
7725 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7726         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7727         JNIEnv *env;
7728         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7729         if (get_jenv_res == JNI_EDETACHED) {
7730                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7731         } else {
7732                 DO_ASSERT(get_jenv_res == JNI_OK);
7733         }
7734         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7735         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7736         LDKAnnouncementSignatures msg_var = *msg;
7737         msg_var = AnnouncementSignatures_clone(msg);
7738         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7739         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7740         uint64_t msg_ref = (uint64_t)msg_var.inner;
7741         if (msg_var.is_owned) {
7742                 msg_ref |= 1;
7743         }
7744         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7745         CHECK(obj != NULL);
7746         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7747         if ((*env)->ExceptionCheck(env)) {
7748                 (*env)->ExceptionDescribe(env);
7749                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
7750         }
7751         if (get_jenv_res == JNI_EDETACHED) {
7752                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7753         }
7754 }
7755 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7756         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7757         JNIEnv *env;
7758         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7759         if (get_jenv_res == JNI_EDETACHED) {
7760                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7761         } else {
7762                 DO_ASSERT(get_jenv_res == JNI_OK);
7763         }
7764         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7765         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7766         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7767         CHECK(obj != NULL);
7768         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7769         if ((*env)->ExceptionCheck(env)) {
7770                 (*env)->ExceptionDescribe(env);
7771                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
7772         }
7773         if (get_jenv_res == JNI_EDETACHED) {
7774                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7775         }
7776 }
7777 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7778         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7779         JNIEnv *env;
7780         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7781         if (get_jenv_res == JNI_EDETACHED) {
7782                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7783         } else {
7784                 DO_ASSERT(get_jenv_res == JNI_OK);
7785         }
7786         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7787         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7788         LDKInit msg_var = *msg;
7789         msg_var = Init_clone(msg);
7790         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7791         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7792         uint64_t msg_ref = (uint64_t)msg_var.inner;
7793         if (msg_var.is_owned) {
7794                 msg_ref |= 1;
7795         }
7796         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7797         CHECK(obj != NULL);
7798         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7799         if ((*env)->ExceptionCheck(env)) {
7800                 (*env)->ExceptionDescribe(env);
7801                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
7802         }
7803         if (get_jenv_res == JNI_EDETACHED) {
7804                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7805         }
7806 }
7807 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7808         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7809         JNIEnv *env;
7810         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7811         if (get_jenv_res == JNI_EDETACHED) {
7812                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7813         } else {
7814                 DO_ASSERT(get_jenv_res == JNI_OK);
7815         }
7816         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7817         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7818         LDKChannelReestablish msg_var = *msg;
7819         msg_var = ChannelReestablish_clone(msg);
7820         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7821         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7822         uint64_t msg_ref = (uint64_t)msg_var.inner;
7823         if (msg_var.is_owned) {
7824                 msg_ref |= 1;
7825         }
7826         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7827         CHECK(obj != NULL);
7828         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7829         if ((*env)->ExceptionCheck(env)) {
7830                 (*env)->ExceptionDescribe(env);
7831                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
7832         }
7833         if (get_jenv_res == JNI_EDETACHED) {
7834                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7835         }
7836 }
7837 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7838         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7839         JNIEnv *env;
7840         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7841         if (get_jenv_res == JNI_EDETACHED) {
7842                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7843         } else {
7844                 DO_ASSERT(get_jenv_res == JNI_OK);
7845         }
7846         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7847         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7848         LDKChannelUpdate msg_var = *msg;
7849         msg_var = ChannelUpdate_clone(msg);
7850         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7851         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7852         uint64_t msg_ref = (uint64_t)msg_var.inner;
7853         if (msg_var.is_owned) {
7854                 msg_ref |= 1;
7855         }
7856         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7857         CHECK(obj != NULL);
7858         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7859         if ((*env)->ExceptionCheck(env)) {
7860                 (*env)->ExceptionDescribe(env);
7861                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
7862         }
7863         if (get_jenv_res == JNI_EDETACHED) {
7864                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7865         }
7866 }
7867 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7868         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7869         JNIEnv *env;
7870         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7871         if (get_jenv_res == JNI_EDETACHED) {
7872                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7873         } else {
7874                 DO_ASSERT(get_jenv_res == JNI_OK);
7875         }
7876         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7877         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7878         LDKErrorMessage msg_var = *msg;
7879         msg_var = ErrorMessage_clone(msg);
7880         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7881         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7882         uint64_t msg_ref = (uint64_t)msg_var.inner;
7883         if (msg_var.is_owned) {
7884                 msg_ref |= 1;
7885         }
7886         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7887         CHECK(obj != NULL);
7888         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7889         if ((*env)->ExceptionCheck(env)) {
7890                 (*env)->ExceptionDescribe(env);
7891                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
7892         }
7893         if (get_jenv_res == JNI_EDETACHED) {
7894                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7895         }
7896 }
7897 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7898         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7899         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7900         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7901 }
7902 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7903         jclass c = (*env)->GetObjectClass(env, o);
7904         CHECK(c != NULL);
7905         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7906         atomic_init(&calls->refcnt, 1);
7907         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7908         calls->o = (*env)->NewWeakGlobalRef(env, o);
7909         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7910         CHECK(calls->handle_open_channel_meth != NULL);
7911         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7912         CHECK(calls->handle_accept_channel_meth != NULL);
7913         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7914         CHECK(calls->handle_funding_created_meth != NULL);
7915         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7916         CHECK(calls->handle_funding_signed_meth != NULL);
7917         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7918         CHECK(calls->handle_funding_locked_meth != NULL);
7919         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7920         CHECK(calls->handle_shutdown_meth != NULL);
7921         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7922         CHECK(calls->handle_closing_signed_meth != NULL);
7923         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7924         CHECK(calls->handle_update_add_htlc_meth != NULL);
7925         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7926         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7927         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7928         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7929         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7930         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7931         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7932         CHECK(calls->handle_commitment_signed_meth != NULL);
7933         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7934         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7935         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7936         CHECK(calls->handle_update_fee_meth != NULL);
7937         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7938         CHECK(calls->handle_announcement_signatures_meth != NULL);
7939         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7940         CHECK(calls->peer_disconnected_meth != NULL);
7941         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7942         CHECK(calls->peer_connected_meth != NULL);
7943         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7944         CHECK(calls->handle_channel_reestablish_meth != NULL);
7945         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7946         CHECK(calls->handle_channel_update_meth != NULL);
7947         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7948         CHECK(calls->handle_error_meth != NULL);
7949
7950         LDKChannelMessageHandler ret = {
7951                 .this_arg = (void*) calls,
7952                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7953                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7954                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7955                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7956                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7957                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7958                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7959                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7960                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7961                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7962                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7963                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7964                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7965                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7966                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7967                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7968                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7969                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7970                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7971                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7972                 .free = LDKChannelMessageHandler_JCalls_free,
7973                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7974         };
7975         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7976         return ret;
7977 }
7978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7979         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7980         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7981         return (uint64_t)res_ptr;
7982 }
7983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
7984         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
7985         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
7986         DO_ASSERT((res_ptr & 1) == 0);
7987         return (int64_t)(res_ptr | 1);
7988 }
7989 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) {
7990         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7991         LDKPublicKey their_node_id_ref;
7992         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7993         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7994         LDKInitFeatures their_features_conv;
7995         their_features_conv.inner = (void*)(their_features & (~1));
7996         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7997         their_features_conv = InitFeatures_clone(&their_features_conv);
7998         LDKOpenChannel msg_conv;
7999         msg_conv.inner = (void*)(msg & (~1));
8000         msg_conv.is_owned = false;
8001         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8002 }
8003
8004 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) {
8005         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8006         LDKPublicKey their_node_id_ref;
8007         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8008         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8009         LDKInitFeatures their_features_conv;
8010         their_features_conv.inner = (void*)(their_features & (~1));
8011         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8012         their_features_conv = InitFeatures_clone(&their_features_conv);
8013         LDKAcceptChannel msg_conv;
8014         msg_conv.inner = (void*)(msg & (~1));
8015         msg_conv.is_owned = false;
8016         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8017 }
8018
8019 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) {
8020         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8021         LDKPublicKey their_node_id_ref;
8022         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8023         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8024         LDKFundingCreated msg_conv;
8025         msg_conv.inner = (void*)(msg & (~1));
8026         msg_conv.is_owned = false;
8027         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8028 }
8029
8030 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) {
8031         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8032         LDKPublicKey their_node_id_ref;
8033         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8034         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8035         LDKFundingSigned msg_conv;
8036         msg_conv.inner = (void*)(msg & (~1));
8037         msg_conv.is_owned = false;
8038         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8039 }
8040
8041 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) {
8042         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8043         LDKPublicKey their_node_id_ref;
8044         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8045         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8046         LDKFundingLocked msg_conv;
8047         msg_conv.inner = (void*)(msg & (~1));
8048         msg_conv.is_owned = false;
8049         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8050 }
8051
8052 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) {
8053         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8054         LDKPublicKey their_node_id_ref;
8055         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8056         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8057         LDKInitFeatures their_features_conv;
8058         their_features_conv.inner = (void*)(their_features & (~1));
8059         their_features_conv.is_owned = false;
8060         LDKShutdown msg_conv;
8061         msg_conv.inner = (void*)(msg & (~1));
8062         msg_conv.is_owned = false;
8063         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
8064 }
8065
8066 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) {
8067         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8068         LDKPublicKey their_node_id_ref;
8069         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8070         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8071         LDKClosingSigned msg_conv;
8072         msg_conv.inner = (void*)(msg & (~1));
8073         msg_conv.is_owned = false;
8074         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8075 }
8076
8077 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) {
8078         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8079         LDKPublicKey their_node_id_ref;
8080         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8081         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8082         LDKUpdateAddHTLC msg_conv;
8083         msg_conv.inner = (void*)(msg & (~1));
8084         msg_conv.is_owned = false;
8085         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8086 }
8087
8088 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) {
8089         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8090         LDKPublicKey their_node_id_ref;
8091         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8092         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8093         LDKUpdateFulfillHTLC msg_conv;
8094         msg_conv.inner = (void*)(msg & (~1));
8095         msg_conv.is_owned = false;
8096         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8097 }
8098
8099 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) {
8100         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8101         LDKPublicKey their_node_id_ref;
8102         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8103         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8104         LDKUpdateFailHTLC msg_conv;
8105         msg_conv.inner = (void*)(msg & (~1));
8106         msg_conv.is_owned = false;
8107         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8108 }
8109
8110 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) {
8111         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8112         LDKPublicKey their_node_id_ref;
8113         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8114         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8115         LDKUpdateFailMalformedHTLC msg_conv;
8116         msg_conv.inner = (void*)(msg & (~1));
8117         msg_conv.is_owned = false;
8118         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8119 }
8120
8121 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) {
8122         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8123         LDKPublicKey their_node_id_ref;
8124         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8125         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8126         LDKCommitmentSigned msg_conv;
8127         msg_conv.inner = (void*)(msg & (~1));
8128         msg_conv.is_owned = false;
8129         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8130 }
8131
8132 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) {
8133         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8134         LDKPublicKey their_node_id_ref;
8135         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8136         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8137         LDKRevokeAndACK msg_conv;
8138         msg_conv.inner = (void*)(msg & (~1));
8139         msg_conv.is_owned = false;
8140         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8141 }
8142
8143 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) {
8144         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8145         LDKPublicKey their_node_id_ref;
8146         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8147         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8148         LDKUpdateFee msg_conv;
8149         msg_conv.inner = (void*)(msg & (~1));
8150         msg_conv.is_owned = false;
8151         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8152 }
8153
8154 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) {
8155         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8156         LDKPublicKey their_node_id_ref;
8157         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8158         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8159         LDKAnnouncementSignatures msg_conv;
8160         msg_conv.inner = (void*)(msg & (~1));
8161         msg_conv.is_owned = false;
8162         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8163 }
8164
8165 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) {
8166         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8167         LDKPublicKey their_node_id_ref;
8168         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8169         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8170         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8171 }
8172
8173 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) {
8174         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8175         LDKPublicKey their_node_id_ref;
8176         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8177         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8178         LDKInit msg_conv;
8179         msg_conv.inner = (void*)(msg & (~1));
8180         msg_conv.is_owned = false;
8181         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8182 }
8183
8184 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) {
8185         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8186         LDKPublicKey their_node_id_ref;
8187         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8188         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8189         LDKChannelReestablish msg_conv;
8190         msg_conv.inner = (void*)(msg & (~1));
8191         msg_conv.is_owned = false;
8192         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8193 }
8194
8195 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) {
8196         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8197         LDKPublicKey their_node_id_ref;
8198         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8199         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8200         LDKChannelUpdate msg_conv;
8201         msg_conv.inner = (void*)(msg & (~1));
8202         msg_conv.is_owned = false;
8203         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8204 }
8205
8206 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) {
8207         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8208         LDKPublicKey their_node_id_ref;
8209         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8210         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8211         LDKErrorMessage msg_conv;
8212         msg_conv.inner = (void*)(msg & (~1));
8213         msg_conv.is_owned = false;
8214         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8215 }
8216
8217 typedef struct LDKRoutingMessageHandler_JCalls {
8218         atomic_size_t refcnt;
8219         JavaVM *vm;
8220         jweak o;
8221         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8222         jmethodID handle_node_announcement_meth;
8223         jmethodID handle_channel_announcement_meth;
8224         jmethodID handle_channel_update_meth;
8225         jmethodID handle_htlc_fail_channel_update_meth;
8226         jmethodID get_next_channel_announcements_meth;
8227         jmethodID get_next_node_announcements_meth;
8228         jmethodID sync_routing_table_meth;
8229         jmethodID handle_reply_channel_range_meth;
8230         jmethodID handle_reply_short_channel_ids_end_meth;
8231         jmethodID handle_query_channel_range_meth;
8232         jmethodID handle_query_short_channel_ids_meth;
8233 } LDKRoutingMessageHandler_JCalls;
8234 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8235         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8236         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8237                 JNIEnv *env;
8238                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8239                 if (get_jenv_res == JNI_EDETACHED) {
8240                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8241                 } else {
8242                         DO_ASSERT(get_jenv_res == JNI_OK);
8243                 }
8244                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8245                 if (get_jenv_res == JNI_EDETACHED) {
8246                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8247                 }
8248                 FREE(j_calls);
8249         }
8250 }
8251 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8252         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8253         JNIEnv *env;
8254         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8255         if (get_jenv_res == JNI_EDETACHED) {
8256                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8257         } else {
8258                 DO_ASSERT(get_jenv_res == JNI_OK);
8259         }
8260         LDKNodeAnnouncement msg_var = *msg;
8261         msg_var = NodeAnnouncement_clone(msg);
8262         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8263         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8264         uint64_t msg_ref = (uint64_t)msg_var.inner;
8265         if (msg_var.is_owned) {
8266                 msg_ref |= 1;
8267         }
8268         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8269         CHECK(obj != NULL);
8270         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
8271         if ((*env)->ExceptionCheck(env)) {
8272                 (*env)->ExceptionDescribe(env);
8273                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8274         }
8275         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8276         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8277         if (get_jenv_res == JNI_EDETACHED) {
8278                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8279         }
8280         return ret_conv;
8281 }
8282 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8283         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8284         JNIEnv *env;
8285         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8286         if (get_jenv_res == JNI_EDETACHED) {
8287                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8288         } else {
8289                 DO_ASSERT(get_jenv_res == JNI_OK);
8290         }
8291         LDKChannelAnnouncement msg_var = *msg;
8292         msg_var = ChannelAnnouncement_clone(msg);
8293         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8294         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8295         uint64_t msg_ref = (uint64_t)msg_var.inner;
8296         if (msg_var.is_owned) {
8297                 msg_ref |= 1;
8298         }
8299         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8300         CHECK(obj != NULL);
8301         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
8302         if ((*env)->ExceptionCheck(env)) {
8303                 (*env)->ExceptionDescribe(env);
8304                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8305         }
8306         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8307         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8308         if (get_jenv_res == JNI_EDETACHED) {
8309                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8310         }
8311         return ret_conv;
8312 }
8313 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8314         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8315         JNIEnv *env;
8316         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8317         if (get_jenv_res == JNI_EDETACHED) {
8318                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8319         } else {
8320                 DO_ASSERT(get_jenv_res == JNI_OK);
8321         }
8322         LDKChannelUpdate msg_var = *msg;
8323         msg_var = ChannelUpdate_clone(msg);
8324         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8325         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8326         uint64_t msg_ref = (uint64_t)msg_var.inner;
8327         if (msg_var.is_owned) {
8328                 msg_ref |= 1;
8329         }
8330         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8331         CHECK(obj != NULL);
8332         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
8333         if ((*env)->ExceptionCheck(env)) {
8334                 (*env)->ExceptionDescribe(env);
8335                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8336         }
8337         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8338         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8339         if (get_jenv_res == JNI_EDETACHED) {
8340                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8341         }
8342         return ret_conv;
8343 }
8344 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
8345         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8346         JNIEnv *env;
8347         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8348         if (get_jenv_res == JNI_EDETACHED) {
8349                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8350         } else {
8351                 DO_ASSERT(get_jenv_res == JNI_OK);
8352         }
8353         uint64_t ret_update = (uint64_t)update;
8354         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8355         CHECK(obj != NULL);
8356         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
8357         if ((*env)->ExceptionCheck(env)) {
8358                 (*env)->ExceptionDescribe(env);
8359                 (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8360         }
8361         if (get_jenv_res == JNI_EDETACHED) {
8362                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8363         }
8364 }
8365 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8366         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8367         JNIEnv *env;
8368         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8369         if (get_jenv_res == JNI_EDETACHED) {
8370                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8371         } else {
8372                 DO_ASSERT(get_jenv_res == JNI_OK);
8373         }
8374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8375         CHECK(obj != NULL);
8376         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
8377         if ((*env)->ExceptionCheck(env)) {
8378                 (*env)->ExceptionDescribe(env);
8379                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8380         }
8381         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8382         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8383         if (ret_constr.datalen > 0)
8384                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8385         else
8386                 ret_constr.data = NULL;
8387         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8388         for (size_t l = 0; l < ret_constr.datalen; l++) {
8389                 int64_t ret_conv_63 = ret_vals[l];
8390                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
8391                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
8392                 ret_constr.data[l] = ret_conv_63_conv;
8393         }
8394         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8395         if (get_jenv_res == JNI_EDETACHED) {
8396                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8397         }
8398         return ret_constr;
8399 }
8400 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8401         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8402         JNIEnv *env;
8403         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8404         if (get_jenv_res == JNI_EDETACHED) {
8405                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8406         } else {
8407                 DO_ASSERT(get_jenv_res == JNI_OK);
8408         }
8409         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
8410         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
8411         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8412         CHECK(obj != NULL);
8413         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
8414         if ((*env)->ExceptionCheck(env)) {
8415                 (*env)->ExceptionDescribe(env);
8416                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8417         }
8418         LDKCVec_NodeAnnouncementZ ret_constr;
8419         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8420         if (ret_constr.datalen > 0)
8421                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8422         else
8423                 ret_constr.data = NULL;
8424         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8425         for (size_t s = 0; s < ret_constr.datalen; s++) {
8426                 int64_t ret_conv_18 = ret_vals[s];
8427                 LDKNodeAnnouncement ret_conv_18_conv;
8428                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8429                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8430                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
8431                 ret_constr.data[s] = ret_conv_18_conv;
8432         }
8433         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8434         if (get_jenv_res == JNI_EDETACHED) {
8435                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8436         }
8437         return ret_constr;
8438 }
8439 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8440         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8441         JNIEnv *env;
8442         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8443         if (get_jenv_res == JNI_EDETACHED) {
8444                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8445         } else {
8446                 DO_ASSERT(get_jenv_res == JNI_OK);
8447         }
8448         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8449         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8450         LDKInit init_var = *init;
8451         init_var = Init_clone(init);
8452         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8453         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8454         uint64_t init_ref = (uint64_t)init_var.inner;
8455         if (init_var.is_owned) {
8456                 init_ref |= 1;
8457         }
8458         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8459         CHECK(obj != NULL);
8460         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
8461         if ((*env)->ExceptionCheck(env)) {
8462                 (*env)->ExceptionDescribe(env);
8463                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
8464         }
8465         if (get_jenv_res == JNI_EDETACHED) {
8466                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8467         }
8468 }
8469 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8470         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8471         JNIEnv *env;
8472         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8473         if (get_jenv_res == JNI_EDETACHED) {
8474                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8475         } else {
8476                 DO_ASSERT(get_jenv_res == JNI_OK);
8477         }
8478         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8479         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8480         LDKReplyChannelRange msg_var = msg;
8481         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8482         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8483         uint64_t msg_ref = (uint64_t)msg_var.inner;
8484         if (msg_var.is_owned) {
8485                 msg_ref |= 1;
8486         }
8487         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8488         CHECK(obj != NULL);
8489         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8490         if ((*env)->ExceptionCheck(env)) {
8491                 (*env)->ExceptionDescribe(env);
8492                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8493         }
8494         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8495         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8496         if (get_jenv_res == JNI_EDETACHED) {
8497                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8498         }
8499         return ret_conv;
8500 }
8501 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8502         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8503         JNIEnv *env;
8504         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8505         if (get_jenv_res == JNI_EDETACHED) {
8506                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8507         } else {
8508                 DO_ASSERT(get_jenv_res == JNI_OK);
8509         }
8510         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8511         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8512         LDKReplyShortChannelIdsEnd msg_var = msg;
8513         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8514         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8515         uint64_t msg_ref = (uint64_t)msg_var.inner;
8516         if (msg_var.is_owned) {
8517                 msg_ref |= 1;
8518         }
8519         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8520         CHECK(obj != NULL);
8521         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8522         if ((*env)->ExceptionCheck(env)) {
8523                 (*env)->ExceptionDescribe(env);
8524                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
8525         }
8526         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8527         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8528         if (get_jenv_res == JNI_EDETACHED) {
8529                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8530         }
8531         return ret_conv;
8532 }
8533 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8534         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8535         JNIEnv *env;
8536         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8537         if (get_jenv_res == JNI_EDETACHED) {
8538                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8539         } else {
8540                 DO_ASSERT(get_jenv_res == JNI_OK);
8541         }
8542         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8543         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8544         LDKQueryChannelRange msg_var = msg;
8545         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8546         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8547         uint64_t msg_ref = (uint64_t)msg_var.inner;
8548         if (msg_var.is_owned) {
8549                 msg_ref |= 1;
8550         }
8551         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8552         CHECK(obj != NULL);
8553         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8554         if ((*env)->ExceptionCheck(env)) {
8555                 (*env)->ExceptionDescribe(env);
8556                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8557         }
8558         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8559         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8560         if (get_jenv_res == JNI_EDETACHED) {
8561                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8562         }
8563         return ret_conv;
8564 }
8565 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8566         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8567         JNIEnv *env;
8568         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8569         if (get_jenv_res == JNI_EDETACHED) {
8570                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8571         } else {
8572                 DO_ASSERT(get_jenv_res == JNI_OK);
8573         }
8574         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8575         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8576         LDKQueryShortChannelIds msg_var = msg;
8577         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8578         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8579         uint64_t msg_ref = (uint64_t)msg_var.inner;
8580         if (msg_var.is_owned) {
8581                 msg_ref |= 1;
8582         }
8583         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8584         CHECK(obj != NULL);
8585         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8586         if ((*env)->ExceptionCheck(env)) {
8587                 (*env)->ExceptionDescribe(env);
8588                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
8589         }
8590         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8591         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8592         if (get_jenv_res == JNI_EDETACHED) {
8593                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8594         }
8595         return ret_conv;
8596 }
8597 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8598         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8599         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8600         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8601 }
8602 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8603         jclass c = (*env)->GetObjectClass(env, o);
8604         CHECK(c != NULL);
8605         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8606         atomic_init(&calls->refcnt, 1);
8607         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8608         calls->o = (*env)->NewWeakGlobalRef(env, o);
8609         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8610         CHECK(calls->handle_node_announcement_meth != NULL);
8611         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8612         CHECK(calls->handle_channel_announcement_meth != NULL);
8613         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8614         CHECK(calls->handle_channel_update_meth != NULL);
8615         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8616         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8617         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8618         CHECK(calls->get_next_channel_announcements_meth != NULL);
8619         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8620         CHECK(calls->get_next_node_announcements_meth != NULL);
8621         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8622         CHECK(calls->sync_routing_table_meth != NULL);
8623         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8624         CHECK(calls->handle_reply_channel_range_meth != NULL);
8625         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8626         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8627         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8628         CHECK(calls->handle_query_channel_range_meth != NULL);
8629         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8630         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8631
8632         LDKRoutingMessageHandler ret = {
8633                 .this_arg = (void*) calls,
8634                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8635                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8636                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8637                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8638                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8639                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8640                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8641                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8642                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8643                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8644                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8645                 .free = LDKRoutingMessageHandler_JCalls_free,
8646                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8647         };
8648         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8649         return ret;
8650 }
8651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8652         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8653         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8654         return (uint64_t)res_ptr;
8655 }
8656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8657         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
8658         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8659         DO_ASSERT((res_ptr & 1) == 0);
8660         return (int64_t)(res_ptr | 1);
8661 }
8662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8663         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8664         LDKNodeAnnouncement msg_conv;
8665         msg_conv.inner = (void*)(msg & (~1));
8666         msg_conv.is_owned = false;
8667         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8668         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8669         return (uint64_t)ret_conv;
8670 }
8671
8672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8673         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8674         LDKChannelAnnouncement msg_conv;
8675         msg_conv.inner = (void*)(msg & (~1));
8676         msg_conv.is_owned = false;
8677         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8678         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8679         return (uint64_t)ret_conv;
8680 }
8681
8682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8683         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8684         LDKChannelUpdate msg_conv;
8685         msg_conv.inner = (void*)(msg & (~1));
8686         msg_conv.is_owned = false;
8687         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8688         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8689         return (uint64_t)ret_conv;
8690 }
8691
8692 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) {
8693         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8694         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8695         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8696 }
8697
8698 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) {
8699         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8700         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8701         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8702         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8703         for (size_t l = 0; l < ret_var.datalen; l++) {
8704                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8705                 *ret_conv_63_ref = ret_var.data[l];
8706                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8707         }
8708         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8709         FREE(ret_var.data);
8710         return ret_arr;
8711 }
8712
8713 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) {
8714         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8715         LDKPublicKey starting_point_ref;
8716         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8717         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8718         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8719         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8720         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8721         for (size_t s = 0; s < ret_var.datalen; s++) {
8722                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8723                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8724                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8725                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8726                 if (ret_conv_18_var.is_owned) {
8727                         ret_conv_18_ref |= 1;
8728                 }
8729                 ret_arr_ptr[s] = ret_conv_18_ref;
8730         }
8731         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8732         FREE(ret_var.data);
8733         return ret_arr;
8734 }
8735
8736 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) {
8737         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8738         LDKPublicKey their_node_id_ref;
8739         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8740         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8741         LDKInit init_conv;
8742         init_conv.inner = (void*)(init & (~1));
8743         init_conv.is_owned = false;
8744         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8745 }
8746
8747 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) {
8748         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8749         LDKPublicKey their_node_id_ref;
8750         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8751         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8752         LDKReplyChannelRange msg_conv;
8753         msg_conv.inner = (void*)(msg & (~1));
8754         msg_conv.is_owned = (msg & 1) || (msg == 0);
8755         msg_conv = ReplyChannelRange_clone(&msg_conv);
8756         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8757         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8758         return (uint64_t)ret_conv;
8759 }
8760
8761 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) {
8762         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8763         LDKPublicKey their_node_id_ref;
8764         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8765         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8766         LDKReplyShortChannelIdsEnd msg_conv;
8767         msg_conv.inner = (void*)(msg & (~1));
8768         msg_conv.is_owned = (msg & 1) || (msg == 0);
8769         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8770         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8771         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8772         return (uint64_t)ret_conv;
8773 }
8774
8775 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) {
8776         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8777         LDKPublicKey their_node_id_ref;
8778         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8779         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8780         LDKQueryChannelRange msg_conv;
8781         msg_conv.inner = (void*)(msg & (~1));
8782         msg_conv.is_owned = (msg & 1) || (msg == 0);
8783         msg_conv = QueryChannelRange_clone(&msg_conv);
8784         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8785         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8786         return (uint64_t)ret_conv;
8787 }
8788
8789 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) {
8790         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8791         LDKPublicKey their_node_id_ref;
8792         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8793         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8794         LDKQueryShortChannelIds msg_conv;
8795         msg_conv.inner = (void*)(msg & (~1));
8796         msg_conv.is_owned = (msg & 1) || (msg == 0);
8797         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8798         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8799         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8800         return (uint64_t)ret_conv;
8801 }
8802
8803 typedef struct LDKSocketDescriptor_JCalls {
8804         atomic_size_t refcnt;
8805         JavaVM *vm;
8806         jweak o;
8807         jmethodID send_data_meth;
8808         jmethodID disconnect_socket_meth;
8809         jmethodID eq_meth;
8810         jmethodID hash_meth;
8811 } LDKSocketDescriptor_JCalls;
8812 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8813         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8814         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8815                 JNIEnv *env;
8816                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8817                 if (get_jenv_res == JNI_EDETACHED) {
8818                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8819                 } else {
8820                         DO_ASSERT(get_jenv_res == JNI_OK);
8821                 }
8822                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8823                 if (get_jenv_res == JNI_EDETACHED) {
8824                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8825                 }
8826                 FREE(j_calls);
8827         }
8828 }
8829 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8830         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8831         JNIEnv *env;
8832         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8833         if (get_jenv_res == JNI_EDETACHED) {
8834                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8835         } else {
8836                 DO_ASSERT(get_jenv_res == JNI_OK);
8837         }
8838         LDKu8slice data_var = data;
8839         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8840         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8841         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8842         CHECK(obj != NULL);
8843         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8844         if ((*env)->ExceptionCheck(env)) {
8845                 (*env)->ExceptionDescribe(env);
8846                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
8847         }
8848         if (get_jenv_res == JNI_EDETACHED) {
8849                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8850         }
8851         return ret;
8852 }
8853 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8854         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8855         JNIEnv *env;
8856         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8857         if (get_jenv_res == JNI_EDETACHED) {
8858                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8859         } else {
8860                 DO_ASSERT(get_jenv_res == JNI_OK);
8861         }
8862         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8863         CHECK(obj != NULL);
8864         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8865         if ((*env)->ExceptionCheck(env)) {
8866                 (*env)->ExceptionDescribe(env);
8867                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
8868         }
8869         if (get_jenv_res == JNI_EDETACHED) {
8870                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8871         }
8872 }
8873 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8874         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8875         JNIEnv *env;
8876         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8877         if (get_jenv_res == JNI_EDETACHED) {
8878                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8879         } else {
8880                 DO_ASSERT(get_jenv_res == JNI_OK);
8881         }
8882         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8883         *other_arg_clone = SocketDescriptor_clone(other_arg);
8884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8885         CHECK(obj != NULL);
8886         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8887         if ((*env)->ExceptionCheck(env)) {
8888                 (*env)->ExceptionDescribe(env);
8889                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
8890         }
8891         if (get_jenv_res == JNI_EDETACHED) {
8892                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8893         }
8894         return ret;
8895 }
8896 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8897         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8898         JNIEnv *env;
8899         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8900         if (get_jenv_res == JNI_EDETACHED) {
8901                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8902         } else {
8903                 DO_ASSERT(get_jenv_res == JNI_OK);
8904         }
8905         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8906         CHECK(obj != NULL);
8907         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8908         if ((*env)->ExceptionCheck(env)) {
8909                 (*env)->ExceptionDescribe(env);
8910                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
8911         }
8912         if (get_jenv_res == JNI_EDETACHED) {
8913                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8914         }
8915         return ret;
8916 }
8917 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8918         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8919         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8920 }
8921 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8922         jclass c = (*env)->GetObjectClass(env, o);
8923         CHECK(c != NULL);
8924         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8925         atomic_init(&calls->refcnt, 1);
8926         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8927         calls->o = (*env)->NewWeakGlobalRef(env, o);
8928         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8929         CHECK(calls->send_data_meth != NULL);
8930         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8931         CHECK(calls->disconnect_socket_meth != NULL);
8932         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8933         CHECK(calls->eq_meth != NULL);
8934         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8935         CHECK(calls->hash_meth != NULL);
8936
8937         LDKSocketDescriptor ret = {
8938                 .this_arg = (void*) calls,
8939                 .send_data = send_data_LDKSocketDescriptor_jcall,
8940                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8941                 .eq = eq_LDKSocketDescriptor_jcall,
8942                 .hash = hash_LDKSocketDescriptor_jcall,
8943                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8944                 .free = LDKSocketDescriptor_JCalls_free,
8945         };
8946         return ret;
8947 }
8948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8949         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8950         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8951         return (uint64_t)res_ptr;
8952 }
8953 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) {
8954         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8955         LDKu8slice data_ref;
8956         data_ref.datalen = (*env)->GetArrayLength(env, data);
8957         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8958         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8959         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8960         return ret_val;
8961 }
8962
8963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8964         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8965         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8966 }
8967
8968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8969         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8970         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8971         return ret_val;
8972 }
8973
8974 typedef struct LDKChannelManagerPersister_JCalls {
8975         atomic_size_t refcnt;
8976         JavaVM *vm;
8977         jweak o;
8978         jmethodID persist_manager_meth;
8979 } LDKChannelManagerPersister_JCalls;
8980 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8981         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8982         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8983                 JNIEnv *env;
8984                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8985                 if (get_jenv_res == JNI_EDETACHED) {
8986                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8987                 } else {
8988                         DO_ASSERT(get_jenv_res == JNI_OK);
8989                 }
8990                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8991                 if (get_jenv_res == JNI_EDETACHED) {
8992                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8993                 }
8994                 FREE(j_calls);
8995         }
8996 }
8997 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8998         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8999         JNIEnv *env;
9000         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9001         if (get_jenv_res == JNI_EDETACHED) {
9002                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9003         } else {
9004                 DO_ASSERT(get_jenv_res == JNI_OK);
9005         }
9006         LDKChannelManager channel_manager_var = *channel_manager;
9007         // Warning: we may need a move here but no clone is available for LDKChannelManager
9008         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9009         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9010         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
9011         if (channel_manager_var.is_owned) {
9012                 channel_manager_ref |= 1;
9013         }
9014         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9015         CHECK(obj != NULL);
9016         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
9017         if ((*env)->ExceptionCheck(env)) {
9018                 (*env)->ExceptionDescribe(env);
9019                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
9020         }
9021         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
9022         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
9023         if (get_jenv_res == JNI_EDETACHED) {
9024                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9025         }
9026         return ret_conv;
9027 }
9028 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
9029         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
9030         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9031 }
9032 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
9033         jclass c = (*env)->GetObjectClass(env, o);
9034         CHECK(c != NULL);
9035         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
9036         atomic_init(&calls->refcnt, 1);
9037         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9038         calls->o = (*env)->NewWeakGlobalRef(env, o);
9039         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
9040         CHECK(calls->persist_manager_meth != NULL);
9041
9042         LDKChannelManagerPersister ret = {
9043                 .this_arg = (void*) calls,
9044                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
9045                 .free = LDKChannelManagerPersister_JCalls_free,
9046         };
9047         return ret;
9048 }
9049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
9050         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
9051         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
9052         return (uint64_t)res_ptr;
9053 }
9054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
9055         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
9056         LDKChannelManager channel_manager_conv;
9057         channel_manager_conv.inner = (void*)(channel_manager & (~1));
9058         channel_manager_conv.is_owned = false;
9059         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9060         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
9061         return (uint64_t)ret_conv;
9062 }
9063
9064 static jclass LDKFallback_SegWitProgram_class = NULL;
9065 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
9066 static jclass LDKFallback_PubKeyHash_class = NULL;
9067 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
9068 static jclass LDKFallback_ScriptHash_class = NULL;
9069 static jmethodID LDKFallback_ScriptHash_meth = NULL;
9070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
9071         LDKFallback_SegWitProgram_class =
9072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
9073         CHECK(LDKFallback_SegWitProgram_class != NULL);
9074         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
9075         CHECK(LDKFallback_SegWitProgram_meth != NULL);
9076         LDKFallback_PubKeyHash_class =
9077                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
9078         CHECK(LDKFallback_PubKeyHash_class != NULL);
9079         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
9080         CHECK(LDKFallback_PubKeyHash_meth != NULL);
9081         LDKFallback_ScriptHash_class =
9082                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
9083         CHECK(LDKFallback_ScriptHash_class != NULL);
9084         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
9085         CHECK(LDKFallback_ScriptHash_meth != NULL);
9086 }
9087 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9088         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9089         switch(obj->tag) {
9090                 case LDKFallback_SegWitProgram: {
9091                         uint8_t version_val = obj->seg_wit_program.version._0;
9092                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
9093                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
9094                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
9095                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
9096                 }
9097                 case LDKFallback_PubKeyHash: {
9098                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
9099                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
9100                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
9101                 }
9102                 case LDKFallback_ScriptHash: {
9103                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
9104                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
9105                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
9106                 }
9107                 default: abort();
9108         }
9109 }
9110 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
9111         LDKStr ret_str = _ldk_get_compiled_version();
9112         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9113         Str_free(ret_str);
9114         return ret_conv;
9115 }
9116
9117 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
9118         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
9119         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9120         Str_free(ret_str);
9121         return ret_conv;
9122 }
9123
9124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
9125         LDKTransaction _res_ref;
9126         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
9127         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
9128         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
9129         _res_ref.data_is_owned = true;
9130         Transaction_free(_res_ref);
9131 }
9132
9133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
9134         if ((_res & 1) != 0) return;
9135         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
9136         FREE((void*)_res);
9137         TxOut_free(_res_conv);
9138 }
9139
9140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9141         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
9142         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9143         *ret_ref = TxOut_clone(orig_conv);
9144         return (uint64_t)ret_ref;
9145 }
9146
9147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
9148         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
9149         Str_free(dummy);
9150 }
9151
9152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9153         LDKSecretKey o_ref;
9154         CHECK((*env)->GetArrayLength(env, o) == 32);
9155         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
9156         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9157         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9158         return (uint64_t)ret_conv;
9159 }
9160
9161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9162         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9163         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9164         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9165         return (uint64_t)ret_conv;
9166 }
9167
9168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9169         if ((_res & 1) != 0) return;
9170         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
9171         FREE((void*)_res);
9172         CResult_SecretKeyErrorZ_free(_res_conv);
9173 }
9174
9175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9176         LDKPublicKey o_ref;
9177         CHECK((*env)->GetArrayLength(env, o) == 33);
9178         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
9179         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9180         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9181         return (uint64_t)ret_conv;
9182 }
9183
9184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9185         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9186         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9187         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9188         return (uint64_t)ret_conv;
9189 }
9190
9191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9192         if ((_res & 1) != 0) return;
9193         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
9194         FREE((void*)_res);
9195         CResult_PublicKeyErrorZ_free(_res_conv);
9196 }
9197
9198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9199         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9200         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9201         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9202         return (uint64_t)ret_conv;
9203 }
9204
9205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9206         LDKTxCreationKeys o_conv;
9207         o_conv.inner = (void*)(o & (~1));
9208         o_conv.is_owned = (o & 1) || (o == 0);
9209         o_conv = TxCreationKeys_clone(&o_conv);
9210         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9211         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9212         return (uint64_t)ret_conv;
9213 }
9214
9215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9216         LDKDecodeError e_conv;
9217         e_conv.inner = (void*)(e & (~1));
9218         e_conv.is_owned = (e & 1) || (e == 0);
9219         e_conv = DecodeError_clone(&e_conv);
9220         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9221         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9222         return (uint64_t)ret_conv;
9223 }
9224
9225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9226         if ((_res & 1) != 0) return;
9227         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9228         FREE((void*)_res);
9229         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9230 }
9231
9232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9233         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9234         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9235         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9236         return (uint64_t)ret_conv;
9237 }
9238
9239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9240         LDKChannelPublicKeys o_conv;
9241         o_conv.inner = (void*)(o & (~1));
9242         o_conv.is_owned = (o & 1) || (o == 0);
9243         o_conv = ChannelPublicKeys_clone(&o_conv);
9244         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9245         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9246         return (uint64_t)ret_conv;
9247 }
9248
9249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9250         LDKDecodeError e_conv;
9251         e_conv.inner = (void*)(e & (~1));
9252         e_conv.is_owned = (e & 1) || (e == 0);
9253         e_conv = DecodeError_clone(&e_conv);
9254         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9255         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9256         return (uint64_t)ret_conv;
9257 }
9258
9259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9260         if ((_res & 1) != 0) return;
9261         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9262         FREE((void*)_res);
9263         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9264 }
9265
9266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9267         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9268         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9269         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9270         return (uint64_t)ret_conv;
9271 }
9272
9273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9274         LDKTxCreationKeys o_conv;
9275         o_conv.inner = (void*)(o & (~1));
9276         o_conv.is_owned = (o & 1) || (o == 0);
9277         o_conv = TxCreationKeys_clone(&o_conv);
9278         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9279         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9280         return (uint64_t)ret_conv;
9281 }
9282
9283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9284         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9285         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9286         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9287         return (uint64_t)ret_conv;
9288 }
9289
9290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9291         if ((_res & 1) != 0) return;
9292         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
9293         FREE((void*)_res);
9294         CResult_TxCreationKeysErrorZ_free(_res_conv);
9295 }
9296
9297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9298         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9299         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9300         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9301         return (uint64_t)ret_conv;
9302 }
9303
9304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
9305         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9306         *ret_copy = COption_u32Z_some(o);
9307         uint64_t ret_ref = (uint64_t)ret_copy;
9308         return ret_ref;
9309 }
9310
9311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
9312         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9313         *ret_copy = COption_u32Z_none();
9314         uint64_t ret_ref = (uint64_t)ret_copy;
9315         return ret_ref;
9316 }
9317
9318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9319         if ((_res & 1) != 0) return;
9320         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
9321         FREE((void*)_res);
9322         COption_u32Z_free(_res_conv);
9323 }
9324
9325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9326         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9327         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9328         *ret_copy = COption_u32Z_clone(orig_conv);
9329         uint64_t ret_ref = (uint64_t)ret_copy;
9330         return ret_ref;
9331 }
9332
9333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9334         LDKHTLCOutputInCommitment o_conv;
9335         o_conv.inner = (void*)(o & (~1));
9336         o_conv.is_owned = (o & 1) || (o == 0);
9337         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9338         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9339         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9340         return (uint64_t)ret_conv;
9341 }
9342
9343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9344         LDKDecodeError e_conv;
9345         e_conv.inner = (void*)(e & (~1));
9346         e_conv.is_owned = (e & 1) || (e == 0);
9347         e_conv = DecodeError_clone(&e_conv);
9348         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9349         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9350         return (uint64_t)ret_conv;
9351 }
9352
9353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9354         if ((_res & 1) != 0) return;
9355         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
9356         FREE((void*)_res);
9357         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9358 }
9359
9360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9361         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9362         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9363         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9364         return (uint64_t)ret_conv;
9365 }
9366
9367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9368         LDKCounterpartyChannelTransactionParameters o_conv;
9369         o_conv.inner = (void*)(o & (~1));
9370         o_conv.is_owned = (o & 1) || (o == 0);
9371         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9372         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9373         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9374         return (uint64_t)ret_conv;
9375 }
9376
9377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9378         LDKDecodeError e_conv;
9379         e_conv.inner = (void*)(e & (~1));
9380         e_conv.is_owned = (e & 1) || (e == 0);
9381         e_conv = DecodeError_clone(&e_conv);
9382         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9383         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9384         return (uint64_t)ret_conv;
9385 }
9386
9387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9388         if ((_res & 1) != 0) return;
9389         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9390         FREE((void*)_res);
9391         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9392 }
9393
9394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9395         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9396         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9397         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9398         return (uint64_t)ret_conv;
9399 }
9400
9401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9402         LDKChannelTransactionParameters o_conv;
9403         o_conv.inner = (void*)(o & (~1));
9404         o_conv.is_owned = (o & 1) || (o == 0);
9405         o_conv = ChannelTransactionParameters_clone(&o_conv);
9406         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9407         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9408         return (uint64_t)ret_conv;
9409 }
9410
9411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9412         LDKDecodeError e_conv;
9413         e_conv.inner = (void*)(e & (~1));
9414         e_conv.is_owned = (e & 1) || (e == 0);
9415         e_conv = DecodeError_clone(&e_conv);
9416         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9417         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9418         return (uint64_t)ret_conv;
9419 }
9420
9421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9422         if ((_res & 1) != 0) return;
9423         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9424         FREE((void*)_res);
9425         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9426 }
9427
9428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9429         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9430         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9431         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9432         return (uint64_t)ret_conv;
9433 }
9434
9435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9436         LDKCVec_SignatureZ _res_constr;
9437         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9438         if (_res_constr.datalen > 0)
9439                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9440         else
9441                 _res_constr.data = NULL;
9442         for (size_t i = 0; i < _res_constr.datalen; i++) {
9443                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9444                 LDKSignature _res_conv_8_ref;
9445                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
9446                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
9447                 _res_constr.data[i] = _res_conv_8_ref;
9448         }
9449         CVec_SignatureZ_free(_res_constr);
9450 }
9451
9452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9453         LDKHolderCommitmentTransaction o_conv;
9454         o_conv.inner = (void*)(o & (~1));
9455         o_conv.is_owned = (o & 1) || (o == 0);
9456         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9457         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9458         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9459         return (uint64_t)ret_conv;
9460 }
9461
9462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9463         LDKDecodeError e_conv;
9464         e_conv.inner = (void*)(e & (~1));
9465         e_conv.is_owned = (e & 1) || (e == 0);
9466         e_conv = DecodeError_clone(&e_conv);
9467         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9468         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9469         return (uint64_t)ret_conv;
9470 }
9471
9472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9473         if ((_res & 1) != 0) return;
9474         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9475         FREE((void*)_res);
9476         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9477 }
9478
9479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9480         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9481         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9482         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9483         return (uint64_t)ret_conv;
9484 }
9485
9486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9487         LDKBuiltCommitmentTransaction o_conv;
9488         o_conv.inner = (void*)(o & (~1));
9489         o_conv.is_owned = (o & 1) || (o == 0);
9490         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9491         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9492         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9493         return (uint64_t)ret_conv;
9494 }
9495
9496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9497         LDKDecodeError e_conv;
9498         e_conv.inner = (void*)(e & (~1));
9499         e_conv.is_owned = (e & 1) || (e == 0);
9500         e_conv = DecodeError_clone(&e_conv);
9501         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9502         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9503         return (uint64_t)ret_conv;
9504 }
9505
9506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9507         if ((_res & 1) != 0) return;
9508         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9509         FREE((void*)_res);
9510         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9511 }
9512
9513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9514         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9515         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9516         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9517         return (uint64_t)ret_conv;
9518 }
9519
9520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9521         LDKCommitmentTransaction o_conv;
9522         o_conv.inner = (void*)(o & (~1));
9523         o_conv.is_owned = (o & 1) || (o == 0);
9524         o_conv = CommitmentTransaction_clone(&o_conv);
9525         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9526         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9527         return (uint64_t)ret_conv;
9528 }
9529
9530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9531         LDKDecodeError e_conv;
9532         e_conv.inner = (void*)(e & (~1));
9533         e_conv.is_owned = (e & 1) || (e == 0);
9534         e_conv = DecodeError_clone(&e_conv);
9535         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9536         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9537         return (uint64_t)ret_conv;
9538 }
9539
9540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9541         if ((_res & 1) != 0) return;
9542         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9543         FREE((void*)_res);
9544         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9545 }
9546
9547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9548         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9549         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9550         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9551         return (uint64_t)ret_conv;
9552 }
9553
9554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9555         LDKTrustedCommitmentTransaction o_conv;
9556         o_conv.inner = (void*)(o & (~1));
9557         o_conv.is_owned = (o & 1) || (o == 0);
9558         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9559         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9560         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9561         return (uint64_t)ret_conv;
9562 }
9563
9564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9565         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9566         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9567         return (uint64_t)ret_conv;
9568 }
9569
9570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9571         if ((_res & 1) != 0) return;
9572         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9573         FREE((void*)_res);
9574         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9575 }
9576
9577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9578         LDKCVec_SignatureZ o_constr;
9579         o_constr.datalen = (*env)->GetArrayLength(env, o);
9580         if (o_constr.datalen > 0)
9581                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9582         else
9583                 o_constr.data = NULL;
9584         for (size_t i = 0; i < o_constr.datalen; i++) {
9585                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9586                 LDKSignature o_conv_8_ref;
9587                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9588                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9589                 o_constr.data[i] = o_conv_8_ref;
9590         }
9591         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9592         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9593         return (uint64_t)ret_conv;
9594 }
9595
9596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9597         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9598         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9599         return (uint64_t)ret_conv;
9600 }
9601
9602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9603         if ((_res & 1) != 0) return;
9604         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9605         FREE((void*)_res);
9606         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9607 }
9608
9609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9610         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9611         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9612         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9613         return (uint64_t)ret_conv;
9614 }
9615
9616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9617         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9618         *ret_conv = CResult_NoneErrorZ_ok();
9619         return (uint64_t)ret_conv;
9620 }
9621
9622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9623         LDKIOError e_conv = LDKIOError_from_java(env, e);
9624         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9625         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9626         return (uint64_t)ret_conv;
9627 }
9628
9629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9630         if ((_res & 1) != 0) return;
9631         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9632         FREE((void*)_res);
9633         CResult_NoneErrorZ_free(_res_conv);
9634 }
9635
9636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9637         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9638         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9639         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9640         return (uint64_t)ret_conv;
9641 }
9642
9643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9644         LDKRouteHop o_conv;
9645         o_conv.inner = (void*)(o & (~1));
9646         o_conv.is_owned = (o & 1) || (o == 0);
9647         o_conv = RouteHop_clone(&o_conv);
9648         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9649         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9650         return (uint64_t)ret_conv;
9651 }
9652
9653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9654         LDKDecodeError e_conv;
9655         e_conv.inner = (void*)(e & (~1));
9656         e_conv.is_owned = (e & 1) || (e == 0);
9657         e_conv = DecodeError_clone(&e_conv);
9658         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9659         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9660         return (uint64_t)ret_conv;
9661 }
9662
9663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9664         if ((_res & 1) != 0) return;
9665         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9666         FREE((void*)_res);
9667         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9668 }
9669
9670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9671         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9672         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9673         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9674         return (uint64_t)ret_conv;
9675 }
9676
9677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9678         LDKCVec_RouteHopZ _res_constr;
9679         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9680         if (_res_constr.datalen > 0)
9681                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9682         else
9683                 _res_constr.data = NULL;
9684         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9685         for (size_t k = 0; k < _res_constr.datalen; k++) {
9686                 int64_t _res_conv_10 = _res_vals[k];
9687                 LDKRouteHop _res_conv_10_conv;
9688                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9689                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9690                 _res_constr.data[k] = _res_conv_10_conv;
9691         }
9692         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9693         CVec_RouteHopZ_free(_res_constr);
9694 }
9695
9696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9697         LDKCVec_CVec_RouteHopZZ _res_constr;
9698         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9699         if (_res_constr.datalen > 0)
9700                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9701         else
9702                 _res_constr.data = NULL;
9703         for (size_t m = 0; m < _res_constr.datalen; m++) {
9704                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9705                 LDKCVec_RouteHopZ _res_conv_12_constr;
9706                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9707                 if (_res_conv_12_constr.datalen > 0)
9708                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9709                 else
9710                         _res_conv_12_constr.data = NULL;
9711                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9712                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9713                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9714                         LDKRouteHop _res_conv_12_conv_10_conv;
9715                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9716                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9717                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9718                 }
9719                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9720                 _res_constr.data[m] = _res_conv_12_constr;
9721         }
9722         CVec_CVec_RouteHopZZ_free(_res_constr);
9723 }
9724
9725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9726         LDKRoute o_conv;
9727         o_conv.inner = (void*)(o & (~1));
9728         o_conv.is_owned = (o & 1) || (o == 0);
9729         o_conv = Route_clone(&o_conv);
9730         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9731         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9732         return (uint64_t)ret_conv;
9733 }
9734
9735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9736         LDKDecodeError e_conv;
9737         e_conv.inner = (void*)(e & (~1));
9738         e_conv.is_owned = (e & 1) || (e == 0);
9739         e_conv = DecodeError_clone(&e_conv);
9740         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9741         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9742         return (uint64_t)ret_conv;
9743 }
9744
9745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9746         if ((_res & 1) != 0) return;
9747         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9748         FREE((void*)_res);
9749         CResult_RouteDecodeErrorZ_free(_res_conv);
9750 }
9751
9752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9753         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9754         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9755         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9756         return (uint64_t)ret_conv;
9757 }
9758
9759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9760         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9761         *ret_copy = COption_u64Z_some(o);
9762         uint64_t ret_ref = (uint64_t)ret_copy;
9763         return ret_ref;
9764 }
9765
9766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9767         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9768         *ret_copy = COption_u64Z_none();
9769         uint64_t ret_ref = (uint64_t)ret_copy;
9770         return ret_ref;
9771 }
9772
9773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9774         if ((_res & 1) != 0) return;
9775         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9776         FREE((void*)_res);
9777         COption_u64Z_free(_res_conv);
9778 }
9779
9780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9781         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9782         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9783         *ret_copy = COption_u64Z_clone(orig_conv);
9784         uint64_t ret_ref = (uint64_t)ret_copy;
9785         return ret_ref;
9786 }
9787
9788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9789         LDKCVec_ChannelDetailsZ _res_constr;
9790         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9791         if (_res_constr.datalen > 0)
9792                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9793         else
9794                 _res_constr.data = NULL;
9795         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9796         for (size_t q = 0; q < _res_constr.datalen; q++) {
9797                 int64_t _res_conv_16 = _res_vals[q];
9798                 LDKChannelDetails _res_conv_16_conv;
9799                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9800                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9801                 _res_constr.data[q] = _res_conv_16_conv;
9802         }
9803         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9804         CVec_ChannelDetailsZ_free(_res_constr);
9805 }
9806
9807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9808         LDKCVec_RouteHintZ _res_constr;
9809         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9810         if (_res_constr.datalen > 0)
9811                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9812         else
9813                 _res_constr.data = NULL;
9814         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9815         for (size_t l = 0; l < _res_constr.datalen; l++) {
9816                 int64_t _res_conv_11 = _res_vals[l];
9817                 LDKRouteHint _res_conv_11_conv;
9818                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9819                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9820                 _res_constr.data[l] = _res_conv_11_conv;
9821         }
9822         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9823         CVec_RouteHintZ_free(_res_constr);
9824 }
9825
9826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9827         LDKRoute o_conv;
9828         o_conv.inner = (void*)(o & (~1));
9829         o_conv.is_owned = (o & 1) || (o == 0);
9830         o_conv = Route_clone(&o_conv);
9831         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9832         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9833         return (uint64_t)ret_conv;
9834 }
9835
9836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9837         LDKLightningError e_conv;
9838         e_conv.inner = (void*)(e & (~1));
9839         e_conv.is_owned = (e & 1) || (e == 0);
9840         e_conv = LightningError_clone(&e_conv);
9841         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9842         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9843         return (uint64_t)ret_conv;
9844 }
9845
9846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9847         if ((_res & 1) != 0) return;
9848         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9849         FREE((void*)_res);
9850         CResult_RouteLightningErrorZ_free(_res_conv);
9851 }
9852
9853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9854         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9855         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9856         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9857         return (uint64_t)ret_conv;
9858 }
9859
9860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9861         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9862         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9863         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9864         return (uint64_t)ret_conv;
9865 }
9866
9867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9868         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9869         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9870         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9871         return (uint64_t)ret_conv;
9872 }
9873
9874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9875         if ((_res & 1) != 0) return;
9876         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9877         FREE((void*)_res);
9878         CResult_TxOutAccessErrorZ_free(_res_conv);
9879 }
9880
9881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9882         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9883         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9884         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9885         return (uint64_t)ret_conv;
9886 }
9887
9888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9889         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9890         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9891         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9892         return (uint64_t)ret_ref;
9893 }
9894
9895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9896         LDKTransaction b_ref;
9897         b_ref.datalen = (*env)->GetArrayLength(env, b);
9898         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9899         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9900         b_ref.data_is_owned = true;
9901         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9902         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9903         return (uint64_t)ret_ref;
9904 }
9905
9906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9907         if ((_res & 1) != 0) return;
9908         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9909         FREE((void*)_res);
9910         C2Tuple_usizeTransactionZ_free(_res_conv);
9911 }
9912
9913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9914         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9915         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9916         if (_res_constr.datalen > 0)
9917                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9918         else
9919                 _res_constr.data = NULL;
9920         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9921         for (size_t y = 0; y < _res_constr.datalen; y++) {
9922                 int64_t _res_conv_24 = _res_vals[y];
9923                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9924                 FREE((void*)_res_conv_24);
9925                 _res_constr.data[y] = _res_conv_24_conv;
9926         }
9927         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9928         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9929 }
9930
9931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9932         LDKCVec_TxidZ _res_constr;
9933         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9934         if (_res_constr.datalen > 0)
9935                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9936         else
9937                 _res_constr.data = NULL;
9938         for (size_t i = 0; i < _res_constr.datalen; i++) {
9939                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9940                 LDKThirtyTwoBytes _res_conv_8_ref;
9941                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9942                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9943                 _res_constr.data[i] = _res_conv_8_ref;
9944         }
9945         CVec_TxidZ_free(_res_constr);
9946 }
9947
9948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9949         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9950         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9951         return (uint64_t)ret_conv;
9952 }
9953
9954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9955         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9956         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9957         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9958         return (uint64_t)ret_conv;
9959 }
9960
9961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9962         if ((_res & 1) != 0) return;
9963         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9964         FREE((void*)_res);
9965         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9966 }
9967
9968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9969         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9970         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9971         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9972         return (uint64_t)ret_conv;
9973 }
9974
9975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9976         LDKCVec_MonitorEventZ _res_constr;
9977         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9978         if (_res_constr.datalen > 0)
9979                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9980         else
9981                 _res_constr.data = NULL;
9982         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9983         for (size_t o = 0; o < _res_constr.datalen; o++) {
9984                 int64_t _res_conv_14 = _res_vals[o];
9985                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9986                 FREE((void*)_res_conv_14);
9987                 _res_constr.data[o] = _res_conv_14_conv;
9988         }
9989         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9990         CVec_MonitorEventZ_free(_res_constr);
9991 }
9992
9993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9994         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9995         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9996         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9997         uint64_t ret_ref = (uint64_t)ret_copy;
9998         return ret_ref;
9999 }
10000
10001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
10002         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10003         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
10004         uint64_t ret_ref = (uint64_t)ret_copy;
10005         return ret_ref;
10006 }
10007
10008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10009         if ((_res & 1) != 0) return;
10010         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
10011         FREE((void*)_res);
10012         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
10013 }
10014
10015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10016         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
10017         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10018         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
10019         uint64_t ret_ref = (uint64_t)ret_copy;
10020         return ret_ref;
10021 }
10022
10023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10024         LDKCVec_SpendableOutputDescriptorZ _res_constr;
10025         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10026         if (_res_constr.datalen > 0)
10027                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
10028         else
10029                 _res_constr.data = NULL;
10030         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10031         for (size_t b = 0; b < _res_constr.datalen; b++) {
10032                 int64_t _res_conv_27 = _res_vals[b];
10033                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
10034                 FREE((void*)_res_conv_27);
10035                 _res_constr.data[b] = _res_conv_27_conv;
10036         }
10037         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10038         CVec_SpendableOutputDescriptorZ_free(_res_constr);
10039 }
10040
10041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10042         LDKCVec_MessageSendEventZ _res_constr;
10043         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10044         if (_res_constr.datalen > 0)
10045                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10046         else
10047                 _res_constr.data = NULL;
10048         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10049         for (size_t s = 0; s < _res_constr.datalen; s++) {
10050                 int64_t _res_conv_18 = _res_vals[s];
10051                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
10052                 FREE((void*)_res_conv_18);
10053                 _res_constr.data[s] = _res_conv_18_conv;
10054         }
10055         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10056         CVec_MessageSendEventZ_free(_res_constr);
10057 }
10058
10059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10060         LDKInitFeatures o_conv;
10061         o_conv.inner = (void*)(o & (~1));
10062         o_conv.is_owned = (o & 1) || (o == 0);
10063         o_conv = InitFeatures_clone(&o_conv);
10064         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10065         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
10066         return (uint64_t)ret_conv;
10067 }
10068
10069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10070         LDKDecodeError e_conv;
10071         e_conv.inner = (void*)(e & (~1));
10072         e_conv.is_owned = (e & 1) || (e == 0);
10073         e_conv = DecodeError_clone(&e_conv);
10074         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10075         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
10076         return (uint64_t)ret_conv;
10077 }
10078
10079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10080         if ((_res & 1) != 0) return;
10081         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10082         FREE((void*)_res);
10083         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
10084 }
10085
10086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10087         LDKNodeFeatures o_conv;
10088         o_conv.inner = (void*)(o & (~1));
10089         o_conv.is_owned = (o & 1) || (o == 0);
10090         o_conv = NodeFeatures_clone(&o_conv);
10091         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10092         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
10093         return (uint64_t)ret_conv;
10094 }
10095
10096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10097         LDKDecodeError e_conv;
10098         e_conv.inner = (void*)(e & (~1));
10099         e_conv.is_owned = (e & 1) || (e == 0);
10100         e_conv = DecodeError_clone(&e_conv);
10101         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10102         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
10103         return (uint64_t)ret_conv;
10104 }
10105
10106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10107         if ((_res & 1) != 0) return;
10108         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10109         FREE((void*)_res);
10110         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
10111 }
10112
10113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10114         LDKChannelFeatures o_conv;
10115         o_conv.inner = (void*)(o & (~1));
10116         o_conv.is_owned = (o & 1) || (o == 0);
10117         o_conv = ChannelFeatures_clone(&o_conv);
10118         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10119         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
10120         return (uint64_t)ret_conv;
10121 }
10122
10123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10124         LDKDecodeError e_conv;
10125         e_conv.inner = (void*)(e & (~1));
10126         e_conv.is_owned = (e & 1) || (e == 0);
10127         e_conv = DecodeError_clone(&e_conv);
10128         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10129         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
10130         return (uint64_t)ret_conv;
10131 }
10132
10133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10134         if ((_res & 1) != 0) return;
10135         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10136         FREE((void*)_res);
10137         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
10138 }
10139
10140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10141         LDKInvoiceFeatures o_conv;
10142         o_conv.inner = (void*)(o & (~1));
10143         o_conv.is_owned = (o & 1) || (o == 0);
10144         o_conv = InvoiceFeatures_clone(&o_conv);
10145         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10146         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
10147         return (uint64_t)ret_conv;
10148 }
10149
10150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10151         LDKDecodeError e_conv;
10152         e_conv.inner = (void*)(e & (~1));
10153         e_conv.is_owned = (e & 1) || (e == 0);
10154         e_conv = DecodeError_clone(&e_conv);
10155         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10156         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
10157         return (uint64_t)ret_conv;
10158 }
10159
10160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10161         if ((_res & 1) != 0) return;
10162         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10163         FREE((void*)_res);
10164         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
10165 }
10166
10167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10168         LDKDelayedPaymentOutputDescriptor o_conv;
10169         o_conv.inner = (void*)(o & (~1));
10170         o_conv.is_owned = (o & 1) || (o == 0);
10171         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10172         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10173         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10174         return (uint64_t)ret_conv;
10175 }
10176
10177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10178         LDKDecodeError e_conv;
10179         e_conv.inner = (void*)(e & (~1));
10180         e_conv.is_owned = (e & 1) || (e == 0);
10181         e_conv = DecodeError_clone(&e_conv);
10182         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10183         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10184         return (uint64_t)ret_conv;
10185 }
10186
10187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10188         if ((_res & 1) != 0) return;
10189         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10190         FREE((void*)_res);
10191         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10192 }
10193
10194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10195         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10196         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10197         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10198         return (uint64_t)ret_conv;
10199 }
10200
10201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10202         LDKStaticPaymentOutputDescriptor o_conv;
10203         o_conv.inner = (void*)(o & (~1));
10204         o_conv.is_owned = (o & 1) || (o == 0);
10205         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10206         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10207         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10208         return (uint64_t)ret_conv;
10209 }
10210
10211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10212         LDKDecodeError e_conv;
10213         e_conv.inner = (void*)(e & (~1));
10214         e_conv.is_owned = (e & 1) || (e == 0);
10215         e_conv = DecodeError_clone(&e_conv);
10216         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10217         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10218         return (uint64_t)ret_conv;
10219 }
10220
10221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10222         if ((_res & 1) != 0) return;
10223         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10224         FREE((void*)_res);
10225         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10226 }
10227
10228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10229         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10230         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10231         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10232         return (uint64_t)ret_conv;
10233 }
10234
10235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10236         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
10237         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10238         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10239         return (uint64_t)ret_conv;
10240 }
10241
10242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10243         LDKDecodeError e_conv;
10244         e_conv.inner = (void*)(e & (~1));
10245         e_conv.is_owned = (e & 1) || (e == 0);
10246         e_conv = DecodeError_clone(&e_conv);
10247         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10248         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10249         return (uint64_t)ret_conv;
10250 }
10251
10252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10253         if ((_res & 1) != 0) return;
10254         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10255         FREE((void*)_res);
10256         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10257 }
10258
10259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10260         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10261         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10262         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10263         return (uint64_t)ret_conv;
10264 }
10265
10266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10267         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10268         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10269         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10270         return (uint64_t)ret_ref;
10271 }
10272
10273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
10274         LDKSignature a_ref;
10275         CHECK((*env)->GetArrayLength(env, a) == 64);
10276         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
10277         LDKCVec_SignatureZ b_constr;
10278         b_constr.datalen = (*env)->GetArrayLength(env, b);
10279         if (b_constr.datalen > 0)
10280                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10281         else
10282                 b_constr.data = NULL;
10283         for (size_t i = 0; i < b_constr.datalen; i++) {
10284                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
10285                 LDKSignature b_conv_8_ref;
10286                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
10287                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
10288                 b_constr.data[i] = b_conv_8_ref;
10289         }
10290         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10291         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10292         return (uint64_t)ret_ref;
10293 }
10294
10295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10296         if ((_res & 1) != 0) return;
10297         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
10298         FREE((void*)_res);
10299         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10300 }
10301
10302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10303         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
10304         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10305         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10306         return (uint64_t)ret_conv;
10307 }
10308
10309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
10310         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10311         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10312         return (uint64_t)ret_conv;
10313 }
10314
10315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10316         if ((_res & 1) != 0) return;
10317         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
10318         FREE((void*)_res);
10319         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10320 }
10321
10322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10323         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10324         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10325         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10326         return (uint64_t)ret_conv;
10327 }
10328
10329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10330         LDKSignature o_ref;
10331         CHECK((*env)->GetArrayLength(env, o) == 64);
10332         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
10333         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10334         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10335         return (uint64_t)ret_conv;
10336 }
10337
10338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10339         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10340         *ret_conv = CResult_SignatureNoneZ_err();
10341         return (uint64_t)ret_conv;
10342 }
10343
10344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10345         if ((_res & 1) != 0) return;
10346         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
10347         FREE((void*)_res);
10348         CResult_SignatureNoneZ_free(_res_conv);
10349 }
10350
10351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10352         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10353         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10354         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10355         return (uint64_t)ret_conv;
10356 }
10357
10358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10359         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
10360         if (o_conv.free == LDKSign_JCalls_free) {
10361                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10362                 LDKSign_JCalls_cloned(&o_conv);
10363         }
10364         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10365         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10366         return (uint64_t)ret_conv;
10367 }
10368
10369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10370         LDKDecodeError e_conv;
10371         e_conv.inner = (void*)(e & (~1));
10372         e_conv.is_owned = (e & 1) || (e == 0);
10373         e_conv = DecodeError_clone(&e_conv);
10374         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10375         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10376         return (uint64_t)ret_conv;
10377 }
10378
10379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10380         if ((_res & 1) != 0) return;
10381         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
10382         FREE((void*)_res);
10383         CResult_SignDecodeErrorZ_free(_res_conv);
10384 }
10385
10386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10387         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10388         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10389         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10390         return (uint64_t)ret_conv;
10391 }
10392
10393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10394         LDKCVec_u8Z _res_ref;
10395         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10396         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10397         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10398         CVec_u8Z_free(_res_ref);
10399 }
10400
10401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
10402         LDKRecoverableSignature arg_ref;
10403         CHECK((*env)->GetArrayLength(env, arg) == 68);
10404         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
10405         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10406         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10407         return (uint64_t)ret_conv;
10408 }
10409
10410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10411         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10412         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10413         return (uint64_t)ret_conv;
10414 }
10415
10416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10417         if ((_res & 1) != 0) return;
10418         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
10419         FREE((void*)_res);
10420         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10421 }
10422
10423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10424         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10425         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10426         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10427         return (uint64_t)ret_conv;
10428 }
10429
10430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10431         LDKCVec_CVec_u8ZZ _res_constr;
10432         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10433         if (_res_constr.datalen > 0)
10434                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10435         else
10436                 _res_constr.data = NULL;
10437         for (size_t i = 0; i < _res_constr.datalen; i++) {
10438                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10439                 LDKCVec_u8Z _res_conv_8_ref;
10440                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
10441                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10442                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10443                 _res_constr.data[i] = _res_conv_8_ref;
10444         }
10445         CVec_CVec_u8ZZ_free(_res_constr);
10446 }
10447
10448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10449         LDKCVec_CVec_u8ZZ o_constr;
10450         o_constr.datalen = (*env)->GetArrayLength(env, o);
10451         if (o_constr.datalen > 0)
10452                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10453         else
10454                 o_constr.data = NULL;
10455         for (size_t i = 0; i < o_constr.datalen; i++) {
10456                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10457                 LDKCVec_u8Z o_conv_8_ref;
10458                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10459                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10460                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10461                 o_constr.data[i] = o_conv_8_ref;
10462         }
10463         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10464         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10465         return (uint64_t)ret_conv;
10466 }
10467
10468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10469         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10470         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10471         return (uint64_t)ret_conv;
10472 }
10473
10474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10475         if ((_res & 1) != 0) return;
10476         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10477         FREE((void*)_res);
10478         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10479 }
10480
10481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10482         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10483         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10484         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10485         return (uint64_t)ret_conv;
10486 }
10487
10488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10489         LDKInMemorySigner o_conv;
10490         o_conv.inner = (void*)(o & (~1));
10491         o_conv.is_owned = (o & 1) || (o == 0);
10492         o_conv = InMemorySigner_clone(&o_conv);
10493         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10494         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10495         return (uint64_t)ret_conv;
10496 }
10497
10498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10499         LDKDecodeError e_conv;
10500         e_conv.inner = (void*)(e & (~1));
10501         e_conv.is_owned = (e & 1) || (e == 0);
10502         e_conv = DecodeError_clone(&e_conv);
10503         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10504         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10505         return (uint64_t)ret_conv;
10506 }
10507
10508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10509         if ((_res & 1) != 0) return;
10510         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10511         FREE((void*)_res);
10512         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10513 }
10514
10515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10516         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10517         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10518         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10519         return (uint64_t)ret_conv;
10520 }
10521
10522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10523         LDKCVec_TxOutZ _res_constr;
10524         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10525         if (_res_constr.datalen > 0)
10526                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10527         else
10528                 _res_constr.data = NULL;
10529         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10530         for (size_t h = 0; h < _res_constr.datalen; h++) {
10531                 int64_t _res_conv_7 = _res_vals[h];
10532                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10533                 FREE((void*)_res_conv_7);
10534                 _res_constr.data[h] = _res_conv_7_conv;
10535         }
10536         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10537         CVec_TxOutZ_free(_res_constr);
10538 }
10539
10540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10541         LDKTransaction o_ref;
10542         o_ref.datalen = (*env)->GetArrayLength(env, o);
10543         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10544         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10545         o_ref.data_is_owned = true;
10546         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10547         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10548         return (uint64_t)ret_conv;
10549 }
10550
10551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10552         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10553         *ret_conv = CResult_TransactionNoneZ_err();
10554         return (uint64_t)ret_conv;
10555 }
10556
10557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10558         if ((_res & 1) != 0) return;
10559         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10560         FREE((void*)_res);
10561         CResult_TransactionNoneZ_free(_res_conv);
10562 }
10563
10564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10565         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10566         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10567         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10568         return (uint64_t)ret_conv;
10569 }
10570
10571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10572         LDKThirtyTwoBytes a_ref;
10573         CHECK((*env)->GetArrayLength(env, a) == 32);
10574         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10575         LDKChannelMonitor b_conv;
10576         b_conv.inner = (void*)(b & (~1));
10577         b_conv.is_owned = (b & 1) || (b == 0);
10578         b_conv = ChannelMonitor_clone(&b_conv);
10579         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10580         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10581         return (uint64_t)ret_ref;
10582 }
10583
10584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10585         if ((_res & 1) != 0) return;
10586         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10587         FREE((void*)_res);
10588         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10589 }
10590
10591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10592         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10593         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10594         if (_res_constr.datalen > 0)
10595                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10596         else
10597                 _res_constr.data = NULL;
10598         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10599         for (size_t i = 0; i < _res_constr.datalen; i++) {
10600                 int64_t _res_conv_34 = _res_vals[i];
10601                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10602                 FREE((void*)_res_conv_34);
10603                 _res_constr.data[i] = _res_conv_34_conv;
10604         }
10605         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10606         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10607 }
10608
10609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10610         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10611         o_constr.datalen = (*env)->GetArrayLength(env, o);
10612         if (o_constr.datalen > 0)
10613                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10614         else
10615                 o_constr.data = NULL;
10616         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10617         for (size_t i = 0; i < o_constr.datalen; i++) {
10618                 int64_t o_conv_34 = o_vals[i];
10619                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10620                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10621                 o_constr.data[i] = o_conv_34_conv;
10622         }
10623         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10624         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10625         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10626         return (uint64_t)ret_conv;
10627 }
10628
10629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10630         LDKIOError e_conv = LDKIOError_from_java(env, e);
10631         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10632         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10633         return (uint64_t)ret_conv;
10634 }
10635
10636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10637         if ((_res & 1) != 0) return;
10638         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10639         FREE((void*)_res);
10640         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10641 }
10642
10643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
10644         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10645         *ret_copy = COption_u16Z_some(o);
10646         uint64_t ret_ref = (uint64_t)ret_copy;
10647         return ret_ref;
10648 }
10649
10650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
10651         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10652         *ret_copy = COption_u16Z_none();
10653         uint64_t ret_ref = (uint64_t)ret_copy;
10654         return ret_ref;
10655 }
10656
10657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10658         if ((_res & 1) != 0) return;
10659         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
10660         FREE((void*)_res);
10661         COption_u16Z_free(_res_conv);
10662 }
10663
10664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10665         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10666         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10667         *ret_copy = COption_u16Z_clone(orig_conv);
10668         uint64_t ret_ref = (uint64_t)ret_copy;
10669         return ret_ref;
10670 }
10671
10672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10673         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10674         *ret_conv = CResult_NoneAPIErrorZ_ok();
10675         return (uint64_t)ret_conv;
10676 }
10677
10678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10679         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10680         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10681         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10682         return (uint64_t)ret_conv;
10683 }
10684
10685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10686         if ((_res & 1) != 0) return;
10687         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10688         FREE((void*)_res);
10689         CResult_NoneAPIErrorZ_free(_res_conv);
10690 }
10691
10692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10693         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10694         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10695         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10696         return (uint64_t)ret_conv;
10697 }
10698
10699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10700         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10701         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10702         if (_res_constr.datalen > 0)
10703                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10704         else
10705                 _res_constr.data = NULL;
10706         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10707         for (size_t w = 0; w < _res_constr.datalen; w++) {
10708                 int64_t _res_conv_22 = _res_vals[w];
10709                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10710                 FREE((void*)_res_conv_22);
10711                 _res_constr.data[w] = _res_conv_22_conv;
10712         }
10713         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10714         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10715 }
10716
10717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10718         LDKCVec_APIErrorZ _res_constr;
10719         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10720         if (_res_constr.datalen > 0)
10721                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10722         else
10723                 _res_constr.data = NULL;
10724         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10725         for (size_t k = 0; k < _res_constr.datalen; k++) {
10726                 int64_t _res_conv_10 = _res_vals[k];
10727                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10728                 FREE((void*)_res_conv_10);
10729                 _res_constr.data[k] = _res_conv_10_conv;
10730         }
10731         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10732         CVec_APIErrorZ_free(_res_constr);
10733 }
10734
10735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10736         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10737         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10738         return (uint64_t)ret_conv;
10739 }
10740
10741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10742         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10743         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10744         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10745         return (uint64_t)ret_conv;
10746 }
10747
10748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10749         if ((_res & 1) != 0) return;
10750         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10751         FREE((void*)_res);
10752         CResult_NonePaymentSendFailureZ_free(_res_conv);
10753 }
10754
10755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10756         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10757         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10758         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10759         return (uint64_t)ret_conv;
10760 }
10761
10762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10763         LDKThirtyTwoBytes o_ref;
10764         CHECK((*env)->GetArrayLength(env, o) == 32);
10765         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10766         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10767         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
10768         return (uint64_t)ret_conv;
10769 }
10770
10771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10772         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10773         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10774         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
10775         return (uint64_t)ret_conv;
10776 }
10777
10778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10779         if ((_res & 1) != 0) return;
10780         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10781         FREE((void*)_res);
10782         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
10783 }
10784
10785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10786         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1);
10787         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10788         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
10789         return (uint64_t)ret_conv;
10790 }
10791
10792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10793         LDKCVec_NetAddressZ _res_constr;
10794         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10795         if (_res_constr.datalen > 0)
10796                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10797         else
10798                 _res_constr.data = NULL;
10799         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10800         for (size_t m = 0; m < _res_constr.datalen; m++) {
10801                 int64_t _res_conv_12 = _res_vals[m];
10802                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10803                 FREE((void*)_res_conv_12);
10804                 _res_constr.data[m] = _res_conv_12_conv;
10805         }
10806         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10807         CVec_NetAddressZ_free(_res_constr);
10808 }
10809
10810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10811         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10812         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10813         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10814         return (uint64_t)ret_ref;
10815 }
10816
10817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10818         LDKThirtyTwoBytes a_ref;
10819         CHECK((*env)->GetArrayLength(env, a) == 32);
10820         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10821         LDKThirtyTwoBytes b_ref;
10822         CHECK((*env)->GetArrayLength(env, b) == 32);
10823         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10824         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10825         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10826         return (uint64_t)ret_ref;
10827 }
10828
10829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10830         if ((_res & 1) != 0) return;
10831         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10832         FREE((void*)_res);
10833         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10834 }
10835
10836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10837         LDKThirtyTwoBytes o_ref;
10838         CHECK((*env)->GetArrayLength(env, o) == 32);
10839         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10840         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10841         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10842         return (uint64_t)ret_conv;
10843 }
10844
10845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10846         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10847         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10848         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10849         return (uint64_t)ret_conv;
10850 }
10851
10852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10853         if ((_res & 1) != 0) return;
10854         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10855         FREE((void*)_res);
10856         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10857 }
10858
10859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10860         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10861         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10862         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10863         return (uint64_t)ret_conv;
10864 }
10865
10866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10867         LDKCVec_ChannelMonitorZ _res_constr;
10868         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10869         if (_res_constr.datalen > 0)
10870                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10871         else
10872                 _res_constr.data = NULL;
10873         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10874         for (size_t q = 0; q < _res_constr.datalen; q++) {
10875                 int64_t _res_conv_16 = _res_vals[q];
10876                 LDKChannelMonitor _res_conv_16_conv;
10877                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10878                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10879                 _res_constr.data[q] = _res_conv_16_conv;
10880         }
10881         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10882         CVec_ChannelMonitorZ_free(_res_constr);
10883 }
10884
10885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10886         LDKThirtyTwoBytes a_ref;
10887         CHECK((*env)->GetArrayLength(env, a) == 32);
10888         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10889         LDKChannelManager b_conv;
10890         b_conv.inner = (void*)(b & (~1));
10891         b_conv.is_owned = (b & 1) || (b == 0);
10892         // Warning: we need a move here but no clone is available for LDKChannelManager
10893         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10894         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10895         return (uint64_t)ret_ref;
10896 }
10897
10898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10899         if ((_res & 1) != 0) return;
10900         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10901         FREE((void*)_res);
10902         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10903 }
10904
10905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10906         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10907         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10908         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10909         return (uint64_t)ret_conv;
10910 }
10911
10912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10913         LDKDecodeError e_conv;
10914         e_conv.inner = (void*)(e & (~1));
10915         e_conv.is_owned = (e & 1) || (e == 0);
10916         e_conv = DecodeError_clone(&e_conv);
10917         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10918         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10919         return (uint64_t)ret_conv;
10920 }
10921
10922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10923         if ((_res & 1) != 0) return;
10924         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10925         FREE((void*)_res);
10926         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10927 }
10928
10929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10930         LDKChannelConfig o_conv;
10931         o_conv.inner = (void*)(o & (~1));
10932         o_conv.is_owned = (o & 1) || (o == 0);
10933         o_conv = ChannelConfig_clone(&o_conv);
10934         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10935         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10936         return (uint64_t)ret_conv;
10937 }
10938
10939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10940         LDKDecodeError e_conv;
10941         e_conv.inner = (void*)(e & (~1));
10942         e_conv.is_owned = (e & 1) || (e == 0);
10943         e_conv = DecodeError_clone(&e_conv);
10944         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10945         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10946         return (uint64_t)ret_conv;
10947 }
10948
10949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10950         if ((_res & 1) != 0) return;
10951         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10952         FREE((void*)_res);
10953         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10954 }
10955
10956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10957         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10958         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10959         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10960         return (uint64_t)ret_conv;
10961 }
10962
10963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10964         LDKOutPoint o_conv;
10965         o_conv.inner = (void*)(o & (~1));
10966         o_conv.is_owned = (o & 1) || (o == 0);
10967         o_conv = OutPoint_clone(&o_conv);
10968         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10969         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10970         return (uint64_t)ret_conv;
10971 }
10972
10973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10974         LDKDecodeError e_conv;
10975         e_conv.inner = (void*)(e & (~1));
10976         e_conv.is_owned = (e & 1) || (e == 0);
10977         e_conv = DecodeError_clone(&e_conv);
10978         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10979         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10980         return (uint64_t)ret_conv;
10981 }
10982
10983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10984         if ((_res & 1) != 0) return;
10985         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10986         FREE((void*)_res);
10987         CResult_OutPointDecodeErrorZ_free(_res_conv);
10988 }
10989
10990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10991         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10992         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10993         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10994         return (uint64_t)ret_conv;
10995 }
10996
10997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10998         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10999         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11000         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
11001         return (uint64_t)ret_conv;
11002 }
11003
11004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
11005         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11006         *ret_conv = CResult_SiPrefixNoneZ_err();
11007         return (uint64_t)ret_conv;
11008 }
11009
11010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11011         if ((_res & 1) != 0) return;
11012         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
11013         FREE((void*)_res);
11014         CResult_SiPrefixNoneZ_free(_res_conv);
11015 }
11016
11017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11018         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
11019         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11020         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
11021         return (uint64_t)ret_conv;
11022 }
11023
11024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11025         LDKInvoice o_conv;
11026         o_conv.inner = (void*)(o & (~1));
11027         o_conv.is_owned = (o & 1) || (o == 0);
11028         o_conv = Invoice_clone(&o_conv);
11029         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11030         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
11031         return (uint64_t)ret_conv;
11032 }
11033
11034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
11035         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11036         *ret_conv = CResult_InvoiceNoneZ_err();
11037         return (uint64_t)ret_conv;
11038 }
11039
11040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11041         if ((_res & 1) != 0) return;
11042         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
11043         FREE((void*)_res);
11044         CResult_InvoiceNoneZ_free(_res_conv);
11045 }
11046
11047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11048         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
11049         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11050         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
11051         return (uint64_t)ret_conv;
11052 }
11053
11054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11055         LDKSignedRawInvoice o_conv;
11056         o_conv.inner = (void*)(o & (~1));
11057         o_conv.is_owned = (o & 1) || (o == 0);
11058         o_conv = SignedRawInvoice_clone(&o_conv);
11059         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11060         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
11061         return (uint64_t)ret_conv;
11062 }
11063
11064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
11065         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11066         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
11067         return (uint64_t)ret_conv;
11068 }
11069
11070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11071         if ((_res & 1) != 0) return;
11072         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
11073         FREE((void*)_res);
11074         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
11075 }
11076
11077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11078         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
11079         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11080         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
11081         return (uint64_t)ret_conv;
11082 }
11083
11084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11085         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
11086         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11087         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
11088         return (uint64_t)ret_ref;
11089 }
11090
11091 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) {
11092         LDKRawInvoice a_conv;
11093         a_conv.inner = (void*)(a & (~1));
11094         a_conv.is_owned = (a & 1) || (a == 0);
11095         a_conv = RawInvoice_clone(&a_conv);
11096         LDKThirtyTwoBytes b_ref;
11097         CHECK((*env)->GetArrayLength(env, b) == 32);
11098         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
11099         LDKInvoiceSignature c_conv;
11100         c_conv.inner = (void*)(c & (~1));
11101         c_conv.is_owned = (c & 1) || (c == 0);
11102         c_conv = InvoiceSignature_clone(&c_conv);
11103         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11104         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
11105         return (uint64_t)ret_ref;
11106 }
11107
11108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11109         if ((_res & 1) != 0) return;
11110         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
11111         FREE((void*)_res);
11112         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
11113 }
11114
11115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11116         LDKPayeePubKey o_conv;
11117         o_conv.inner = (void*)(o & (~1));
11118         o_conv.is_owned = (o & 1) || (o == 0);
11119         o_conv = PayeePubKey_clone(&o_conv);
11120         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11121         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
11122         return (uint64_t)ret_conv;
11123 }
11124
11125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11126         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11127         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11128         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
11129         return (uint64_t)ret_conv;
11130 }
11131
11132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11133         if ((_res & 1) != 0) return;
11134         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
11135         FREE((void*)_res);
11136         CResult_PayeePubKeyErrorZ_free(_res_conv);
11137 }
11138
11139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11140         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
11141         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11142         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
11143         return (uint64_t)ret_conv;
11144 }
11145
11146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11147         LDKCVec_PrivateRouteZ _res_constr;
11148         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11149         if (_res_constr.datalen > 0)
11150                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
11151         else
11152                 _res_constr.data = NULL;
11153         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11154         for (size_t o = 0; o < _res_constr.datalen; o++) {
11155                 int64_t _res_conv_14 = _res_vals[o];
11156                 LDKPrivateRoute _res_conv_14_conv;
11157                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11158                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11159                 _res_constr.data[o] = _res_conv_14_conv;
11160         }
11161         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11162         CVec_PrivateRouteZ_free(_res_constr);
11163 }
11164
11165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11166         LDKPositiveTimestamp o_conv;
11167         o_conv.inner = (void*)(o & (~1));
11168         o_conv.is_owned = (o & 1) || (o == 0);
11169         o_conv = PositiveTimestamp_clone(&o_conv);
11170         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11171         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
11172         return (uint64_t)ret_conv;
11173 }
11174
11175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11176         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11177         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11178         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
11179         return (uint64_t)ret_conv;
11180 }
11181
11182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11183         if ((_res & 1) != 0) return;
11184         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
11185         FREE((void*)_res);
11186         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
11187 }
11188
11189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11190         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
11191         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11192         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
11193         return (uint64_t)ret_conv;
11194 }
11195
11196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
11197         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11198         *ret_conv = CResult_NoneSemanticErrorZ_ok();
11199         return (uint64_t)ret_conv;
11200 }
11201
11202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11203         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11204         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11205         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11206         return (uint64_t)ret_conv;
11207 }
11208
11209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11210         if ((_res & 1) != 0) return;
11211         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
11212         FREE((void*)_res);
11213         CResult_NoneSemanticErrorZ_free(_res_conv);
11214 }
11215
11216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11217         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11218         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11219         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11220         return (uint64_t)ret_conv;
11221 }
11222
11223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11224         LDKInvoice o_conv;
11225         o_conv.inner = (void*)(o & (~1));
11226         o_conv.is_owned = (o & 1) || (o == 0);
11227         o_conv = Invoice_clone(&o_conv);
11228         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11229         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11230         return (uint64_t)ret_conv;
11231 }
11232
11233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11234         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11235         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11236         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11237         return (uint64_t)ret_conv;
11238 }
11239
11240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11241         if ((_res & 1) != 0) return;
11242         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
11243         FREE((void*)_res);
11244         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11245 }
11246
11247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11248         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11249         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11250         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11251         return (uint64_t)ret_conv;
11252 }
11253
11254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11255         LDKDescription o_conv;
11256         o_conv.inner = (void*)(o & (~1));
11257         o_conv.is_owned = (o & 1) || (o == 0);
11258         o_conv = Description_clone(&o_conv);
11259         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11260         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11261         return (uint64_t)ret_conv;
11262 }
11263
11264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11265         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11266         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11267         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11268         return (uint64_t)ret_conv;
11269 }
11270
11271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11272         if ((_res & 1) != 0) return;
11273         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
11274         FREE((void*)_res);
11275         CResult_DescriptionCreationErrorZ_free(_res_conv);
11276 }
11277
11278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11279         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11280         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11281         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11282         return (uint64_t)ret_conv;
11283 }
11284
11285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11286         LDKExpiryTime o_conv;
11287         o_conv.inner = (void*)(o & (~1));
11288         o_conv.is_owned = (o & 1) || (o == 0);
11289         o_conv = ExpiryTime_clone(&o_conv);
11290         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11291         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11292         return (uint64_t)ret_conv;
11293 }
11294
11295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11296         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11297         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11298         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11299         return (uint64_t)ret_conv;
11300 }
11301
11302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11303         if ((_res & 1) != 0) return;
11304         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
11305         FREE((void*)_res);
11306         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11307 }
11308
11309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11310         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11311         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11312         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11313         return (uint64_t)ret_conv;
11314 }
11315
11316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11317         LDKPrivateRoute o_conv;
11318         o_conv.inner = (void*)(o & (~1));
11319         o_conv.is_owned = (o & 1) || (o == 0);
11320         o_conv = PrivateRoute_clone(&o_conv);
11321         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11322         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11323         return (uint64_t)ret_conv;
11324 }
11325
11326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11327         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11328         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11329         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11330         return (uint64_t)ret_conv;
11331 }
11332
11333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11334         if ((_res & 1) != 0) return;
11335         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
11336         FREE((void*)_res);
11337         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11338 }
11339
11340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11341         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11342         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11343         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11344         return (uint64_t)ret_conv;
11345 }
11346
11347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
11348         LDKStr o_conv = java_to_owned_str(env, o);
11349         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11350         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11351         return (uint64_t)ret_conv;
11352 }
11353
11354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11355         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11356         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11357         *ret_conv = CResult_StringErrorZ_err(e_conv);
11358         return (uint64_t)ret_conv;
11359 }
11360
11361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11362         if ((_res & 1) != 0) return;
11363         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
11364         FREE((void*)_res);
11365         CResult_StringErrorZ_free(_res_conv);
11366 }
11367
11368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11369         LDKChannelMonitorUpdate o_conv;
11370         o_conv.inner = (void*)(o & (~1));
11371         o_conv.is_owned = (o & 1) || (o == 0);
11372         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11373         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11374         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11375         return (uint64_t)ret_conv;
11376 }
11377
11378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11379         LDKDecodeError e_conv;
11380         e_conv.inner = (void*)(e & (~1));
11381         e_conv.is_owned = (e & 1) || (e == 0);
11382         e_conv = DecodeError_clone(&e_conv);
11383         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11384         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11385         return (uint64_t)ret_conv;
11386 }
11387
11388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11389         if ((_res & 1) != 0) return;
11390         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11391         FREE((void*)_res);
11392         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11393 }
11394
11395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11396         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11397         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11398         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11399         return (uint64_t)ret_conv;
11400 }
11401
11402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11403         LDKHTLCUpdate o_conv;
11404         o_conv.inner = (void*)(o & (~1));
11405         o_conv.is_owned = (o & 1) || (o == 0);
11406         o_conv = HTLCUpdate_clone(&o_conv);
11407         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11408         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11409         return (uint64_t)ret_conv;
11410 }
11411
11412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11413         LDKDecodeError e_conv;
11414         e_conv.inner = (void*)(e & (~1));
11415         e_conv.is_owned = (e & 1) || (e == 0);
11416         e_conv = DecodeError_clone(&e_conv);
11417         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11418         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11419         return (uint64_t)ret_conv;
11420 }
11421
11422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11423         if ((_res & 1) != 0) return;
11424         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11425         FREE((void*)_res);
11426         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11427 }
11428
11429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11430         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11431         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11432         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11433         return (uint64_t)ret_conv;
11434 }
11435
11436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
11437         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11438         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11439         return (uint64_t)ret_conv;
11440 }
11441
11442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11443         LDKMonitorUpdateError e_conv;
11444         e_conv.inner = (void*)(e & (~1));
11445         e_conv.is_owned = (e & 1) || (e == 0);
11446         e_conv = MonitorUpdateError_clone(&e_conv);
11447         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11448         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11449         return (uint64_t)ret_conv;
11450 }
11451
11452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11453         if ((_res & 1) != 0) return;
11454         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
11455         FREE((void*)_res);
11456         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11457 }
11458
11459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11460         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11461         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11462         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11463         return (uint64_t)ret_conv;
11464 }
11465
11466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11467         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11468         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11469         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
11470         return (uint64_t)ret_ref;
11471 }
11472
11473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11474         LDKOutPoint a_conv;
11475         a_conv.inner = (void*)(a & (~1));
11476         a_conv.is_owned = (a & 1) || (a == 0);
11477         a_conv = OutPoint_clone(&a_conv);
11478         LDKCVec_u8Z b_ref;
11479         b_ref.datalen = (*env)->GetArrayLength(env, b);
11480         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11481         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11482         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11483         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11484         return (uint64_t)ret_ref;
11485 }
11486
11487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11488         if ((_res & 1) != 0) return;
11489         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
11490         FREE((void*)_res);
11491         C2Tuple_OutPointScriptZ_free(_res_conv);
11492 }
11493
11494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11495         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11496         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11497         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
11498         return (uint64_t)ret_ref;
11499 }
11500
11501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
11502         LDKCVec_u8Z b_ref;
11503         b_ref.datalen = (*env)->GetArrayLength(env, b);
11504         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11505         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11506         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11507         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
11508         return (uint64_t)ret_ref;
11509 }
11510
11511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11512         if ((_res & 1) != 0) return;
11513         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
11514         FREE((void*)_res);
11515         C2Tuple_u32ScriptZ_free(_res_conv);
11516 }
11517
11518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11519         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11520         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11521         if (_res_constr.datalen > 0)
11522                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11523         else
11524                 _res_constr.data = NULL;
11525         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11526         for (size_t b = 0; b < _res_constr.datalen; b++) {
11527                 int64_t _res_conv_27 = _res_vals[b];
11528                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
11529                 FREE((void*)_res_conv_27);
11530                 _res_constr.data[b] = _res_conv_27_conv;
11531         }
11532         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11533         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11534 }
11535
11536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11537         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11538         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11539         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11540         return (uint64_t)ret_ref;
11541 }
11542
11543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11544         LDKThirtyTwoBytes a_ref;
11545         CHECK((*env)->GetArrayLength(env, a) == 32);
11546         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11547         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11548         b_constr.datalen = (*env)->GetArrayLength(env, b);
11549         if (b_constr.datalen > 0)
11550                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11551         else
11552                 b_constr.data = NULL;
11553         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11554         for (size_t b = 0; b < b_constr.datalen; b++) {
11555                 int64_t b_conv_27 = b_vals[b];
11556                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
11557                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
11558                 b_constr.data[b] = b_conv_27_conv;
11559         }
11560         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11561         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11562         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11563         return (uint64_t)ret_ref;
11564 }
11565
11566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11567         if ((_res & 1) != 0) return;
11568         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
11569         FREE((void*)_res);
11570         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11571 }
11572
11573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11574         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11575         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11576         if (_res_constr.datalen > 0)
11577                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11578         else
11579                 _res_constr.data = NULL;
11580         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11581         for (size_t v = 0; v < _res_constr.datalen; v++) {
11582                 int64_t _res_conv_47 = _res_vals[v];
11583                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11584                 FREE((void*)_res_conv_47);
11585                 _res_constr.data[v] = _res_conv_47_conv;
11586         }
11587         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11588         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11589 }
11590
11591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11592         LDKCVec_EventZ _res_constr;
11593         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11594         if (_res_constr.datalen > 0)
11595                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11596         else
11597                 _res_constr.data = NULL;
11598         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11599         for (size_t h = 0; h < _res_constr.datalen; h++) {
11600                 int64_t _res_conv_7 = _res_vals[h];
11601                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11602                 FREE((void*)_res_conv_7);
11603                 _res_constr.data[h] = _res_conv_7_conv;
11604         }
11605         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11606         CVec_EventZ_free(_res_constr);
11607 }
11608
11609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11610         LDKCVec_TransactionZ _res_constr;
11611         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11612         if (_res_constr.datalen > 0)
11613                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11614         else
11615                 _res_constr.data = NULL;
11616         for (size_t i = 0; i < _res_constr.datalen; i++) {
11617                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11618                 LDKTransaction _res_conv_8_ref;
11619                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11620                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11621                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11622                 _res_conv_8_ref.data_is_owned = true;
11623                 _res_constr.data[i] = _res_conv_8_ref;
11624         }
11625         CVec_TransactionZ_free(_res_constr);
11626 }
11627
11628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11629         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11630         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11631         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11632         return (uint64_t)ret_ref;
11633 }
11634
11635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11636         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11637         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11638         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11639         return (uint64_t)ret_ref;
11640 }
11641
11642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11643         if ((_res & 1) != 0) return;
11644         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11645         FREE((void*)_res);
11646         C2Tuple_u32TxOutZ_free(_res_conv);
11647 }
11648
11649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11650         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11651         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11652         if (_res_constr.datalen > 0)
11653                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11654         else
11655                 _res_constr.data = NULL;
11656         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11657         for (size_t a = 0; a < _res_constr.datalen; a++) {
11658                 int64_t _res_conv_26 = _res_vals[a];
11659                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11660                 FREE((void*)_res_conv_26);
11661                 _res_constr.data[a] = _res_conv_26_conv;
11662         }
11663         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11664         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11665 }
11666
11667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11668         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11669         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11670         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11671         return (uint64_t)ret_ref;
11672 }
11673
11674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11675         LDKThirtyTwoBytes a_ref;
11676         CHECK((*env)->GetArrayLength(env, a) == 32);
11677         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11678         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11679         b_constr.datalen = (*env)->GetArrayLength(env, b);
11680         if (b_constr.datalen > 0)
11681                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11682         else
11683                 b_constr.data = NULL;
11684         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11685         for (size_t a = 0; a < b_constr.datalen; a++) {
11686                 int64_t b_conv_26 = b_vals[a];
11687                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11688                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11689                 b_constr.data[a] = b_conv_26_conv;
11690         }
11691         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11692         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11693         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11694         return (uint64_t)ret_ref;
11695 }
11696
11697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11698         if ((_res & 1) != 0) return;
11699         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11700         FREE((void*)_res);
11701         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11702 }
11703
11704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11705         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11706         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11707         if (_res_constr.datalen > 0)
11708                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11709         else
11710                 _res_constr.data = NULL;
11711         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11712         for (size_t u = 0; u < _res_constr.datalen; u++) {
11713                 int64_t _res_conv_46 = _res_vals[u];
11714                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11715                 FREE((void*)_res_conv_46);
11716                 _res_constr.data[u] = _res_conv_46_conv;
11717         }
11718         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11719         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11720 }
11721
11722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11723         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11724         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11725         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11726         return (uint64_t)ret_conv;
11727 }
11728
11729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11730         LDKDecodeError e_conv;
11731         e_conv.inner = (void*)(e & (~1));
11732         e_conv.is_owned = (e & 1) || (e == 0);
11733         e_conv = DecodeError_clone(&e_conv);
11734         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11735         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11736         return (uint64_t)ret_conv;
11737 }
11738
11739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11740         if ((_res & 1) != 0) return;
11741         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11742         FREE((void*)_res);
11743         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11744 }
11745
11746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11747         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11748         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11749         return (uint64_t)ret_conv;
11750 }
11751
11752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11753         LDKLightningError e_conv;
11754         e_conv.inner = (void*)(e & (~1));
11755         e_conv.is_owned = (e & 1) || (e == 0);
11756         e_conv = LightningError_clone(&e_conv);
11757         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11758         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11759         return (uint64_t)ret_conv;
11760 }
11761
11762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11763         if ((_res & 1) != 0) return;
11764         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11765         FREE((void*)_res);
11766         CResult_boolLightningErrorZ_free(_res_conv);
11767 }
11768
11769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11770         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11771         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11772         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11773         return (uint64_t)ret_conv;
11774 }
11775
11776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11777         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11778         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11779         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11780         return (uint64_t)ret_ref;
11781 }
11782
11783 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) {
11784         LDKChannelAnnouncement a_conv;
11785         a_conv.inner = (void*)(a & (~1));
11786         a_conv.is_owned = (a & 1) || (a == 0);
11787         a_conv = ChannelAnnouncement_clone(&a_conv);
11788         LDKChannelUpdate b_conv;
11789         b_conv.inner = (void*)(b & (~1));
11790         b_conv.is_owned = (b & 1) || (b == 0);
11791         b_conv = ChannelUpdate_clone(&b_conv);
11792         LDKChannelUpdate c_conv;
11793         c_conv.inner = (void*)(c & (~1));
11794         c_conv.is_owned = (c & 1) || (c == 0);
11795         c_conv = ChannelUpdate_clone(&c_conv);
11796         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11797         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11798         return (uint64_t)ret_ref;
11799 }
11800
11801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11802         if ((_res & 1) != 0) return;
11803         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11804         FREE((void*)_res);
11805         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11806 }
11807
11808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11809         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11810         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11811         if (_res_constr.datalen > 0)
11812                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11813         else
11814                 _res_constr.data = NULL;
11815         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11816         for (size_t l = 0; l < _res_constr.datalen; l++) {
11817                 int64_t _res_conv_63 = _res_vals[l];
11818                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11819                 FREE((void*)_res_conv_63);
11820                 _res_constr.data[l] = _res_conv_63_conv;
11821         }
11822         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11823         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11824 }
11825
11826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11827         LDKCVec_NodeAnnouncementZ _res_constr;
11828         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11829         if (_res_constr.datalen > 0)
11830                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11831         else
11832                 _res_constr.data = NULL;
11833         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11834         for (size_t s = 0; s < _res_constr.datalen; s++) {
11835                 int64_t _res_conv_18 = _res_vals[s];
11836                 LDKNodeAnnouncement _res_conv_18_conv;
11837                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11838                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11839                 _res_constr.data[s] = _res_conv_18_conv;
11840         }
11841         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11842         CVec_NodeAnnouncementZ_free(_res_constr);
11843 }
11844
11845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11846         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11847         *ret_conv = CResult_NoneLightningErrorZ_ok();
11848         return (uint64_t)ret_conv;
11849 }
11850
11851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11852         LDKLightningError e_conv;
11853         e_conv.inner = (void*)(e & (~1));
11854         e_conv.is_owned = (e & 1) || (e == 0);
11855         e_conv = LightningError_clone(&e_conv);
11856         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11857         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11858         return (uint64_t)ret_conv;
11859 }
11860
11861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11862         if ((_res & 1) != 0) return;
11863         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11864         FREE((void*)_res);
11865         CResult_NoneLightningErrorZ_free(_res_conv);
11866 }
11867
11868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11869         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11870         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11871         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11872         return (uint64_t)ret_conv;
11873 }
11874
11875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11876         LDKCVec_PublicKeyZ _res_constr;
11877         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11878         if (_res_constr.datalen > 0)
11879                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11880         else
11881                 _res_constr.data = NULL;
11882         for (size_t i = 0; i < _res_constr.datalen; i++) {
11883                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11884                 LDKPublicKey _res_conv_8_ref;
11885                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11886                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11887                 _res_constr.data[i] = _res_conv_8_ref;
11888         }
11889         CVec_PublicKeyZ_free(_res_constr);
11890 }
11891
11892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11893         LDKCVec_u8Z o_ref;
11894         o_ref.datalen = (*env)->GetArrayLength(env, o);
11895         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11896         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11897         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11898         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11899         return (uint64_t)ret_conv;
11900 }
11901
11902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11903         LDKPeerHandleError e_conv;
11904         e_conv.inner = (void*)(e & (~1));
11905         e_conv.is_owned = (e & 1) || (e == 0);
11906         e_conv = PeerHandleError_clone(&e_conv);
11907         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11908         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11909         return (uint64_t)ret_conv;
11910 }
11911
11912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11913         if ((_res & 1) != 0) return;
11914         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11915         FREE((void*)_res);
11916         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11917 }
11918
11919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11920         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11921         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11922         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11923         return (uint64_t)ret_conv;
11924 }
11925
11926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11927         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11928         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11929         return (uint64_t)ret_conv;
11930 }
11931
11932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11933         LDKPeerHandleError e_conv;
11934         e_conv.inner = (void*)(e & (~1));
11935         e_conv.is_owned = (e & 1) || (e == 0);
11936         e_conv = PeerHandleError_clone(&e_conv);
11937         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11938         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11939         return (uint64_t)ret_conv;
11940 }
11941
11942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11943         if ((_res & 1) != 0) return;
11944         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11945         FREE((void*)_res);
11946         CResult_NonePeerHandleErrorZ_free(_res_conv);
11947 }
11948
11949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11950         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11951         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11952         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11953         return (uint64_t)ret_conv;
11954 }
11955
11956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11957         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11958         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11959         return (uint64_t)ret_conv;
11960 }
11961
11962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11963         LDKPeerHandleError e_conv;
11964         e_conv.inner = (void*)(e & (~1));
11965         e_conv.is_owned = (e & 1) || (e == 0);
11966         e_conv = PeerHandleError_clone(&e_conv);
11967         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11968         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11969         return (uint64_t)ret_conv;
11970 }
11971
11972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11973         if ((_res & 1) != 0) return;
11974         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11975         FREE((void*)_res);
11976         CResult_boolPeerHandleErrorZ_free(_res_conv);
11977 }
11978
11979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11980         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11981         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11982         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11983         return (uint64_t)ret_conv;
11984 }
11985
11986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11987         LDKDirectionalChannelInfo o_conv;
11988         o_conv.inner = (void*)(o & (~1));
11989         o_conv.is_owned = (o & 1) || (o == 0);
11990         o_conv = DirectionalChannelInfo_clone(&o_conv);
11991         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11992         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11993         return (uint64_t)ret_conv;
11994 }
11995
11996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11997         LDKDecodeError e_conv;
11998         e_conv.inner = (void*)(e & (~1));
11999         e_conv.is_owned = (e & 1) || (e == 0);
12000         e_conv = DecodeError_clone(&e_conv);
12001         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12002         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
12003         return (uint64_t)ret_conv;
12004 }
12005
12006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12007         if ((_res & 1) != 0) return;
12008         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12009         FREE((void*)_res);
12010         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
12011 }
12012
12013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12014         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
12015         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12016         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
12017         return (uint64_t)ret_conv;
12018 }
12019
12020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12021         LDKChannelInfo o_conv;
12022         o_conv.inner = (void*)(o & (~1));
12023         o_conv.is_owned = (o & 1) || (o == 0);
12024         o_conv = ChannelInfo_clone(&o_conv);
12025         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12026         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
12027         return (uint64_t)ret_conv;
12028 }
12029
12030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12031         LDKDecodeError e_conv;
12032         e_conv.inner = (void*)(e & (~1));
12033         e_conv.is_owned = (e & 1) || (e == 0);
12034         e_conv = DecodeError_clone(&e_conv);
12035         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12036         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
12037         return (uint64_t)ret_conv;
12038 }
12039
12040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12041         if ((_res & 1) != 0) return;
12042         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12043         FREE((void*)_res);
12044         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
12045 }
12046
12047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12048         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
12049         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12050         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
12051         return (uint64_t)ret_conv;
12052 }
12053
12054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12055         LDKRoutingFees o_conv;
12056         o_conv.inner = (void*)(o & (~1));
12057         o_conv.is_owned = (o & 1) || (o == 0);
12058         o_conv = RoutingFees_clone(&o_conv);
12059         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12060         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
12061         return (uint64_t)ret_conv;
12062 }
12063
12064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12065         LDKDecodeError e_conv;
12066         e_conv.inner = (void*)(e & (~1));
12067         e_conv.is_owned = (e & 1) || (e == 0);
12068         e_conv = DecodeError_clone(&e_conv);
12069         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12070         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
12071         return (uint64_t)ret_conv;
12072 }
12073
12074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12075         if ((_res & 1) != 0) return;
12076         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12077         FREE((void*)_res);
12078         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
12079 }
12080
12081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12082         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
12083         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12084         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
12085         return (uint64_t)ret_conv;
12086 }
12087
12088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12089         LDKNodeAnnouncementInfo o_conv;
12090         o_conv.inner = (void*)(o & (~1));
12091         o_conv.is_owned = (o & 1) || (o == 0);
12092         o_conv = NodeAnnouncementInfo_clone(&o_conv);
12093         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12094         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
12095         return (uint64_t)ret_conv;
12096 }
12097
12098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12099         LDKDecodeError e_conv;
12100         e_conv.inner = (void*)(e & (~1));
12101         e_conv.is_owned = (e & 1) || (e == 0);
12102         e_conv = DecodeError_clone(&e_conv);
12103         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12104         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
12105         return (uint64_t)ret_conv;
12106 }
12107
12108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12109         if ((_res & 1) != 0) return;
12110         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12111         FREE((void*)_res);
12112         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
12113 }
12114
12115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12116         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
12117         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12118         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
12119         return (uint64_t)ret_conv;
12120 }
12121
12122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12123         LDKCVec_u64Z _res_constr;
12124         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12125         if (_res_constr.datalen > 0)
12126                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12127         else
12128                 _res_constr.data = NULL;
12129         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12130         for (size_t g = 0; g < _res_constr.datalen; g++) {
12131                 int64_t _res_conv_6 = _res_vals[g];
12132                 _res_constr.data[g] = _res_conv_6;
12133         }
12134         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12135         CVec_u64Z_free(_res_constr);
12136 }
12137
12138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12139         LDKNodeInfo o_conv;
12140         o_conv.inner = (void*)(o & (~1));
12141         o_conv.is_owned = (o & 1) || (o == 0);
12142         o_conv = NodeInfo_clone(&o_conv);
12143         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12144         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
12145         return (uint64_t)ret_conv;
12146 }
12147
12148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12149         LDKDecodeError e_conv;
12150         e_conv.inner = (void*)(e & (~1));
12151         e_conv.is_owned = (e & 1) || (e == 0);
12152         e_conv = DecodeError_clone(&e_conv);
12153         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12154         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
12155         return (uint64_t)ret_conv;
12156 }
12157
12158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12159         if ((_res & 1) != 0) return;
12160         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12161         FREE((void*)_res);
12162         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
12163 }
12164
12165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12166         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
12167         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12168         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
12169         return (uint64_t)ret_conv;
12170 }
12171
12172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12173         LDKNetworkGraph o_conv;
12174         o_conv.inner = (void*)(o & (~1));
12175         o_conv.is_owned = (o & 1) || (o == 0);
12176         o_conv = NetworkGraph_clone(&o_conv);
12177         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12178         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12179         return (uint64_t)ret_conv;
12180 }
12181
12182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12183         LDKDecodeError e_conv;
12184         e_conv.inner = (void*)(e & (~1));
12185         e_conv.is_owned = (e & 1) || (e == 0);
12186         e_conv = DecodeError_clone(&e_conv);
12187         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12188         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12189         return (uint64_t)ret_conv;
12190 }
12191
12192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12193         if ((_res & 1) != 0) return;
12194         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
12195         FREE((void*)_res);
12196         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12197 }
12198
12199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12200         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12201         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12202         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12203         return (uint64_t)ret_conv;
12204 }
12205
12206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
12207         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12208         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12209         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
12210         return (uint64_t)ret_conv;
12211 }
12212
12213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
12214         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12215         *ret_conv = CResult_NetAddressu8Z_err(e);
12216         return (uint64_t)ret_conv;
12217 }
12218
12219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12220         if ((_res & 1) != 0) return;
12221         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
12222         FREE((void*)_res);
12223         CResult_NetAddressu8Z_free(_res_conv);
12224 }
12225
12226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12227         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
12228         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12229         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
12230         return (uint64_t)ret_conv;
12231 }
12232
12233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12234         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
12235         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12236         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
12237         return (uint64_t)ret_conv;
12238 }
12239
12240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12241         LDKDecodeError e_conv;
12242         e_conv.inner = (void*)(e & (~1));
12243         e_conv.is_owned = (e & 1) || (e == 0);
12244         e_conv = DecodeError_clone(&e_conv);
12245         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12246         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
12247         return (uint64_t)ret_conv;
12248 }
12249
12250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12251         if ((_res & 1) != 0) return;
12252         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12253         FREE((void*)_res);
12254         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
12255 }
12256
12257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12258         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
12259         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12260         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
12261         return (uint64_t)ret_conv;
12262 }
12263
12264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12265         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12266         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12267         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12268         return (uint64_t)ret_conv;
12269 }
12270
12271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12272         LDKDecodeError e_conv;
12273         e_conv.inner = (void*)(e & (~1));
12274         e_conv.is_owned = (e & 1) || (e == 0);
12275         e_conv = DecodeError_clone(&e_conv);
12276         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12277         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12278         return (uint64_t)ret_conv;
12279 }
12280
12281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12282         if ((_res & 1) != 0) return;
12283         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
12284         FREE((void*)_res);
12285         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12286 }
12287
12288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12289         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12290         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12291         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12292         return (uint64_t)ret_conv;
12293 }
12294
12295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12296         LDKCVec_UpdateAddHTLCZ _res_constr;
12297         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12298         if (_res_constr.datalen > 0)
12299                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12300         else
12301                 _res_constr.data = NULL;
12302         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12303         for (size_t p = 0; p < _res_constr.datalen; p++) {
12304                 int64_t _res_conv_15 = _res_vals[p];
12305                 LDKUpdateAddHTLC _res_conv_15_conv;
12306                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12307                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12308                 _res_constr.data[p] = _res_conv_15_conv;
12309         }
12310         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12311         CVec_UpdateAddHTLCZ_free(_res_constr);
12312 }
12313
12314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12315         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12316         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12317         if (_res_constr.datalen > 0)
12318                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12319         else
12320                 _res_constr.data = NULL;
12321         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12322         for (size_t t = 0; t < _res_constr.datalen; t++) {
12323                 int64_t _res_conv_19 = _res_vals[t];
12324                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12325                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12326                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12327                 _res_constr.data[t] = _res_conv_19_conv;
12328         }
12329         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12330         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12331 }
12332
12333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12334         LDKCVec_UpdateFailHTLCZ _res_constr;
12335         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12336         if (_res_constr.datalen > 0)
12337                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12338         else
12339                 _res_constr.data = NULL;
12340         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12341         for (size_t q = 0; q < _res_constr.datalen; q++) {
12342                 int64_t _res_conv_16 = _res_vals[q];
12343                 LDKUpdateFailHTLC _res_conv_16_conv;
12344                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12345                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12346                 _res_constr.data[q] = _res_conv_16_conv;
12347         }
12348         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12349         CVec_UpdateFailHTLCZ_free(_res_constr);
12350 }
12351
12352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12353         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12354         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12355         if (_res_constr.datalen > 0)
12356                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12357         else
12358                 _res_constr.data = NULL;
12359         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12360         for (size_t z = 0; z < _res_constr.datalen; z++) {
12361                 int64_t _res_conv_25 = _res_vals[z];
12362                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12363                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12364                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12365                 _res_constr.data[z] = _res_conv_25_conv;
12366         }
12367         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12368         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12369 }
12370
12371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12372         LDKAcceptChannel o_conv;
12373         o_conv.inner = (void*)(o & (~1));
12374         o_conv.is_owned = (o & 1) || (o == 0);
12375         o_conv = AcceptChannel_clone(&o_conv);
12376         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12377         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12378         return (uint64_t)ret_conv;
12379 }
12380
12381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12382         LDKDecodeError e_conv;
12383         e_conv.inner = (void*)(e & (~1));
12384         e_conv.is_owned = (e & 1) || (e == 0);
12385         e_conv = DecodeError_clone(&e_conv);
12386         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12387         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12388         return (uint64_t)ret_conv;
12389 }
12390
12391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12392         if ((_res & 1) != 0) return;
12393         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12394         FREE((void*)_res);
12395         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12396 }
12397
12398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12399         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12400         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12401         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12402         return (uint64_t)ret_conv;
12403 }
12404
12405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12406         LDKAnnouncementSignatures o_conv;
12407         o_conv.inner = (void*)(o & (~1));
12408         o_conv.is_owned = (o & 1) || (o == 0);
12409         o_conv = AnnouncementSignatures_clone(&o_conv);
12410         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12411         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12412         return (uint64_t)ret_conv;
12413 }
12414
12415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12416         LDKDecodeError e_conv;
12417         e_conv.inner = (void*)(e & (~1));
12418         e_conv.is_owned = (e & 1) || (e == 0);
12419         e_conv = DecodeError_clone(&e_conv);
12420         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12421         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12422         return (uint64_t)ret_conv;
12423 }
12424
12425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12426         if ((_res & 1) != 0) return;
12427         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12428         FREE((void*)_res);
12429         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12430 }
12431
12432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12433         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12434         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12435         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12436         return (uint64_t)ret_conv;
12437 }
12438
12439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12440         LDKChannelReestablish o_conv;
12441         o_conv.inner = (void*)(o & (~1));
12442         o_conv.is_owned = (o & 1) || (o == 0);
12443         o_conv = ChannelReestablish_clone(&o_conv);
12444         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12445         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12446         return (uint64_t)ret_conv;
12447 }
12448
12449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12450         LDKDecodeError e_conv;
12451         e_conv.inner = (void*)(e & (~1));
12452         e_conv.is_owned = (e & 1) || (e == 0);
12453         e_conv = DecodeError_clone(&e_conv);
12454         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12455         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12456         return (uint64_t)ret_conv;
12457 }
12458
12459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12460         if ((_res & 1) != 0) return;
12461         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
12462         FREE((void*)_res);
12463         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12464 }
12465
12466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12467         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12468         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12469         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12470         return (uint64_t)ret_conv;
12471 }
12472
12473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12474         LDKClosingSigned o_conv;
12475         o_conv.inner = (void*)(o & (~1));
12476         o_conv.is_owned = (o & 1) || (o == 0);
12477         o_conv = ClosingSigned_clone(&o_conv);
12478         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12479         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12480         return (uint64_t)ret_conv;
12481 }
12482
12483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12484         LDKDecodeError e_conv;
12485         e_conv.inner = (void*)(e & (~1));
12486         e_conv.is_owned = (e & 1) || (e == 0);
12487         e_conv = DecodeError_clone(&e_conv);
12488         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12489         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12490         return (uint64_t)ret_conv;
12491 }
12492
12493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12494         if ((_res & 1) != 0) return;
12495         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12496         FREE((void*)_res);
12497         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12498 }
12499
12500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12501         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12502         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12503         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12504         return (uint64_t)ret_conv;
12505 }
12506
12507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12508         LDKCommitmentSigned o_conv;
12509         o_conv.inner = (void*)(o & (~1));
12510         o_conv.is_owned = (o & 1) || (o == 0);
12511         o_conv = CommitmentSigned_clone(&o_conv);
12512         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12513         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12514         return (uint64_t)ret_conv;
12515 }
12516
12517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12518         LDKDecodeError e_conv;
12519         e_conv.inner = (void*)(e & (~1));
12520         e_conv.is_owned = (e & 1) || (e == 0);
12521         e_conv = DecodeError_clone(&e_conv);
12522         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12523         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12524         return (uint64_t)ret_conv;
12525 }
12526
12527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12528         if ((_res & 1) != 0) return;
12529         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12530         FREE((void*)_res);
12531         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12532 }
12533
12534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12535         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12536         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12537         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12538         return (uint64_t)ret_conv;
12539 }
12540
12541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12542         LDKFundingCreated o_conv;
12543         o_conv.inner = (void*)(o & (~1));
12544         o_conv.is_owned = (o & 1) || (o == 0);
12545         o_conv = FundingCreated_clone(&o_conv);
12546         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12547         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12548         return (uint64_t)ret_conv;
12549 }
12550
12551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12552         LDKDecodeError e_conv;
12553         e_conv.inner = (void*)(e & (~1));
12554         e_conv.is_owned = (e & 1) || (e == 0);
12555         e_conv = DecodeError_clone(&e_conv);
12556         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12557         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12558         return (uint64_t)ret_conv;
12559 }
12560
12561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12562         if ((_res & 1) != 0) return;
12563         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12564         FREE((void*)_res);
12565         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12566 }
12567
12568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12569         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12570         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12571         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12572         return (uint64_t)ret_conv;
12573 }
12574
12575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12576         LDKFundingSigned o_conv;
12577         o_conv.inner = (void*)(o & (~1));
12578         o_conv.is_owned = (o & 1) || (o == 0);
12579         o_conv = FundingSigned_clone(&o_conv);
12580         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12581         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12582         return (uint64_t)ret_conv;
12583 }
12584
12585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12586         LDKDecodeError e_conv;
12587         e_conv.inner = (void*)(e & (~1));
12588         e_conv.is_owned = (e & 1) || (e == 0);
12589         e_conv = DecodeError_clone(&e_conv);
12590         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12591         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12592         return (uint64_t)ret_conv;
12593 }
12594
12595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12596         if ((_res & 1) != 0) return;
12597         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12598         FREE((void*)_res);
12599         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12600 }
12601
12602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12603         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12604         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12605         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12606         return (uint64_t)ret_conv;
12607 }
12608
12609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12610         LDKFundingLocked o_conv;
12611         o_conv.inner = (void*)(o & (~1));
12612         o_conv.is_owned = (o & 1) || (o == 0);
12613         o_conv = FundingLocked_clone(&o_conv);
12614         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12615         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12616         return (uint64_t)ret_conv;
12617 }
12618
12619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12620         LDKDecodeError e_conv;
12621         e_conv.inner = (void*)(e & (~1));
12622         e_conv.is_owned = (e & 1) || (e == 0);
12623         e_conv = DecodeError_clone(&e_conv);
12624         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12625         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12626         return (uint64_t)ret_conv;
12627 }
12628
12629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12630         if ((_res & 1) != 0) return;
12631         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12632         FREE((void*)_res);
12633         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12634 }
12635
12636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12637         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12638         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12639         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12640         return (uint64_t)ret_conv;
12641 }
12642
12643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12644         LDKInit o_conv;
12645         o_conv.inner = (void*)(o & (~1));
12646         o_conv.is_owned = (o & 1) || (o == 0);
12647         o_conv = Init_clone(&o_conv);
12648         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12649         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12650         return (uint64_t)ret_conv;
12651 }
12652
12653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12654         LDKDecodeError e_conv;
12655         e_conv.inner = (void*)(e & (~1));
12656         e_conv.is_owned = (e & 1) || (e == 0);
12657         e_conv = DecodeError_clone(&e_conv);
12658         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12659         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12660         return (uint64_t)ret_conv;
12661 }
12662
12663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12664         if ((_res & 1) != 0) return;
12665         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12666         FREE((void*)_res);
12667         CResult_InitDecodeErrorZ_free(_res_conv);
12668 }
12669
12670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12671         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12672         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12673         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12674         return (uint64_t)ret_conv;
12675 }
12676
12677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12678         LDKOpenChannel o_conv;
12679         o_conv.inner = (void*)(o & (~1));
12680         o_conv.is_owned = (o & 1) || (o == 0);
12681         o_conv = OpenChannel_clone(&o_conv);
12682         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12683         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12684         return (uint64_t)ret_conv;
12685 }
12686
12687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12688         LDKDecodeError e_conv;
12689         e_conv.inner = (void*)(e & (~1));
12690         e_conv.is_owned = (e & 1) || (e == 0);
12691         e_conv = DecodeError_clone(&e_conv);
12692         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12693         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12694         return (uint64_t)ret_conv;
12695 }
12696
12697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12698         if ((_res & 1) != 0) return;
12699         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12700         FREE((void*)_res);
12701         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12702 }
12703
12704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12705         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12706         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12707         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12708         return (uint64_t)ret_conv;
12709 }
12710
12711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12712         LDKRevokeAndACK o_conv;
12713         o_conv.inner = (void*)(o & (~1));
12714         o_conv.is_owned = (o & 1) || (o == 0);
12715         o_conv = RevokeAndACK_clone(&o_conv);
12716         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12717         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12718         return (uint64_t)ret_conv;
12719 }
12720
12721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12722         LDKDecodeError e_conv;
12723         e_conv.inner = (void*)(e & (~1));
12724         e_conv.is_owned = (e & 1) || (e == 0);
12725         e_conv = DecodeError_clone(&e_conv);
12726         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12727         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12728         return (uint64_t)ret_conv;
12729 }
12730
12731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12732         if ((_res & 1) != 0) return;
12733         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12734         FREE((void*)_res);
12735         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12736 }
12737
12738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12739         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12740         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12741         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12742         return (uint64_t)ret_conv;
12743 }
12744
12745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12746         LDKShutdown o_conv;
12747         o_conv.inner = (void*)(o & (~1));
12748         o_conv.is_owned = (o & 1) || (o == 0);
12749         o_conv = Shutdown_clone(&o_conv);
12750         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12751         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12752         return (uint64_t)ret_conv;
12753 }
12754
12755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12756         LDKDecodeError e_conv;
12757         e_conv.inner = (void*)(e & (~1));
12758         e_conv.is_owned = (e & 1) || (e == 0);
12759         e_conv = DecodeError_clone(&e_conv);
12760         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12761         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12762         return (uint64_t)ret_conv;
12763 }
12764
12765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12766         if ((_res & 1) != 0) return;
12767         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12768         FREE((void*)_res);
12769         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12770 }
12771
12772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12773         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12774         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12775         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12776         return (uint64_t)ret_conv;
12777 }
12778
12779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12780         LDKUpdateFailHTLC o_conv;
12781         o_conv.inner = (void*)(o & (~1));
12782         o_conv.is_owned = (o & 1) || (o == 0);
12783         o_conv = UpdateFailHTLC_clone(&o_conv);
12784         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12785         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12786         return (uint64_t)ret_conv;
12787 }
12788
12789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12790         LDKDecodeError e_conv;
12791         e_conv.inner = (void*)(e & (~1));
12792         e_conv.is_owned = (e & 1) || (e == 0);
12793         e_conv = DecodeError_clone(&e_conv);
12794         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12795         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12796         return (uint64_t)ret_conv;
12797 }
12798
12799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12800         if ((_res & 1) != 0) return;
12801         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12802         FREE((void*)_res);
12803         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12804 }
12805
12806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12807         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12808         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12809         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12810         return (uint64_t)ret_conv;
12811 }
12812
12813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12814         LDKUpdateFailMalformedHTLC o_conv;
12815         o_conv.inner = (void*)(o & (~1));
12816         o_conv.is_owned = (o & 1) || (o == 0);
12817         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12818         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12819         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12820         return (uint64_t)ret_conv;
12821 }
12822
12823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12824         LDKDecodeError e_conv;
12825         e_conv.inner = (void*)(e & (~1));
12826         e_conv.is_owned = (e & 1) || (e == 0);
12827         e_conv = DecodeError_clone(&e_conv);
12828         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12829         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12830         return (uint64_t)ret_conv;
12831 }
12832
12833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12834         if ((_res & 1) != 0) return;
12835         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12836         FREE((void*)_res);
12837         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12838 }
12839
12840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12841         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12842         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12843         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12844         return (uint64_t)ret_conv;
12845 }
12846
12847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12848         LDKUpdateFee o_conv;
12849         o_conv.inner = (void*)(o & (~1));
12850         o_conv.is_owned = (o & 1) || (o == 0);
12851         o_conv = UpdateFee_clone(&o_conv);
12852         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12853         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12854         return (uint64_t)ret_conv;
12855 }
12856
12857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12858         LDKDecodeError e_conv;
12859         e_conv.inner = (void*)(e & (~1));
12860         e_conv.is_owned = (e & 1) || (e == 0);
12861         e_conv = DecodeError_clone(&e_conv);
12862         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12863         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12864         return (uint64_t)ret_conv;
12865 }
12866
12867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12868         if ((_res & 1) != 0) return;
12869         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12870         FREE((void*)_res);
12871         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12872 }
12873
12874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12875         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12876         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12877         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12878         return (uint64_t)ret_conv;
12879 }
12880
12881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12882         LDKUpdateFulfillHTLC o_conv;
12883         o_conv.inner = (void*)(o & (~1));
12884         o_conv.is_owned = (o & 1) || (o == 0);
12885         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12886         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12887         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12888         return (uint64_t)ret_conv;
12889 }
12890
12891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12892         LDKDecodeError e_conv;
12893         e_conv.inner = (void*)(e & (~1));
12894         e_conv.is_owned = (e & 1) || (e == 0);
12895         e_conv = DecodeError_clone(&e_conv);
12896         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12897         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12898         return (uint64_t)ret_conv;
12899 }
12900
12901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12902         if ((_res & 1) != 0) return;
12903         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12904         FREE((void*)_res);
12905         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12906 }
12907
12908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12909         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12910         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12911         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12912         return (uint64_t)ret_conv;
12913 }
12914
12915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12916         LDKUpdateAddHTLC o_conv;
12917         o_conv.inner = (void*)(o & (~1));
12918         o_conv.is_owned = (o & 1) || (o == 0);
12919         o_conv = UpdateAddHTLC_clone(&o_conv);
12920         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12921         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12922         return (uint64_t)ret_conv;
12923 }
12924
12925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12926         LDKDecodeError e_conv;
12927         e_conv.inner = (void*)(e & (~1));
12928         e_conv.is_owned = (e & 1) || (e == 0);
12929         e_conv = DecodeError_clone(&e_conv);
12930         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12931         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12932         return (uint64_t)ret_conv;
12933 }
12934
12935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12936         if ((_res & 1) != 0) return;
12937         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12938         FREE((void*)_res);
12939         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12940 }
12941
12942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12943         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12944         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12945         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12946         return (uint64_t)ret_conv;
12947 }
12948
12949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12950         LDKPing o_conv;
12951         o_conv.inner = (void*)(o & (~1));
12952         o_conv.is_owned = (o & 1) || (o == 0);
12953         o_conv = Ping_clone(&o_conv);
12954         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12955         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12956         return (uint64_t)ret_conv;
12957 }
12958
12959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12960         LDKDecodeError e_conv;
12961         e_conv.inner = (void*)(e & (~1));
12962         e_conv.is_owned = (e & 1) || (e == 0);
12963         e_conv = DecodeError_clone(&e_conv);
12964         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12965         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12966         return (uint64_t)ret_conv;
12967 }
12968
12969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12970         if ((_res & 1) != 0) return;
12971         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12972         FREE((void*)_res);
12973         CResult_PingDecodeErrorZ_free(_res_conv);
12974 }
12975
12976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12977         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12978         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12979         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12980         return (uint64_t)ret_conv;
12981 }
12982
12983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12984         LDKPong o_conv;
12985         o_conv.inner = (void*)(o & (~1));
12986         o_conv.is_owned = (o & 1) || (o == 0);
12987         o_conv = Pong_clone(&o_conv);
12988         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12989         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12990         return (uint64_t)ret_conv;
12991 }
12992
12993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12994         LDKDecodeError e_conv;
12995         e_conv.inner = (void*)(e & (~1));
12996         e_conv.is_owned = (e & 1) || (e == 0);
12997         e_conv = DecodeError_clone(&e_conv);
12998         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12999         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
13000         return (uint64_t)ret_conv;
13001 }
13002
13003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13004         if ((_res & 1) != 0) return;
13005         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
13006         FREE((void*)_res);
13007         CResult_PongDecodeErrorZ_free(_res_conv);
13008 }
13009
13010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13011         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
13012         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13013         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
13014         return (uint64_t)ret_conv;
13015 }
13016
13017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13018         LDKUnsignedChannelAnnouncement o_conv;
13019         o_conv.inner = (void*)(o & (~1));
13020         o_conv.is_owned = (o & 1) || (o == 0);
13021         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
13022         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13023         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
13024         return (uint64_t)ret_conv;
13025 }
13026
13027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13028         LDKDecodeError e_conv;
13029         e_conv.inner = (void*)(e & (~1));
13030         e_conv.is_owned = (e & 1) || (e == 0);
13031         e_conv = DecodeError_clone(&e_conv);
13032         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13033         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
13034         return (uint64_t)ret_conv;
13035 }
13036
13037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13038         if ((_res & 1) != 0) return;
13039         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13040         FREE((void*)_res);
13041         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
13042 }
13043
13044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13045         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13046         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13047         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13048         return (uint64_t)ret_conv;
13049 }
13050
13051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13052         LDKChannelAnnouncement o_conv;
13053         o_conv.inner = (void*)(o & (~1));
13054         o_conv.is_owned = (o & 1) || (o == 0);
13055         o_conv = ChannelAnnouncement_clone(&o_conv);
13056         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13057         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
13058         return (uint64_t)ret_conv;
13059 }
13060
13061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13062         LDKDecodeError e_conv;
13063         e_conv.inner = (void*)(e & (~1));
13064         e_conv.is_owned = (e & 1) || (e == 0);
13065         e_conv = DecodeError_clone(&e_conv);
13066         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13067         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
13068         return (uint64_t)ret_conv;
13069 }
13070
13071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13072         if ((_res & 1) != 0) return;
13073         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13074         FREE((void*)_res);
13075         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
13076 }
13077
13078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13079         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13080         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13081         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13082         return (uint64_t)ret_conv;
13083 }
13084
13085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13086         LDKUnsignedChannelUpdate o_conv;
13087         o_conv.inner = (void*)(o & (~1));
13088         o_conv.is_owned = (o & 1) || (o == 0);
13089         o_conv = UnsignedChannelUpdate_clone(&o_conv);
13090         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13091         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
13092         return (uint64_t)ret_conv;
13093 }
13094
13095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13096         LDKDecodeError e_conv;
13097         e_conv.inner = (void*)(e & (~1));
13098         e_conv.is_owned = (e & 1) || (e == 0);
13099         e_conv = DecodeError_clone(&e_conv);
13100         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13101         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
13102         return (uint64_t)ret_conv;
13103 }
13104
13105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13106         if ((_res & 1) != 0) return;
13107         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13108         FREE((void*)_res);
13109         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
13110 }
13111
13112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13113         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
13114         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13115         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
13116         return (uint64_t)ret_conv;
13117 }
13118
13119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13120         LDKChannelUpdate o_conv;
13121         o_conv.inner = (void*)(o & (~1));
13122         o_conv.is_owned = (o & 1) || (o == 0);
13123         o_conv = ChannelUpdate_clone(&o_conv);
13124         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13125         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
13126         return (uint64_t)ret_conv;
13127 }
13128
13129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13130         LDKDecodeError e_conv;
13131         e_conv.inner = (void*)(e & (~1));
13132         e_conv.is_owned = (e & 1) || (e == 0);
13133         e_conv = DecodeError_clone(&e_conv);
13134         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13135         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
13136         return (uint64_t)ret_conv;
13137 }
13138
13139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13140         if ((_res & 1) != 0) return;
13141         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13142         FREE((void*)_res);
13143         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
13144 }
13145
13146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13147         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
13148         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13149         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
13150         return (uint64_t)ret_conv;
13151 }
13152
13153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13154         LDKErrorMessage o_conv;
13155         o_conv.inner = (void*)(o & (~1));
13156         o_conv.is_owned = (o & 1) || (o == 0);
13157         o_conv = ErrorMessage_clone(&o_conv);
13158         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13159         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
13160         return (uint64_t)ret_conv;
13161 }
13162
13163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13164         LDKDecodeError e_conv;
13165         e_conv.inner = (void*)(e & (~1));
13166         e_conv.is_owned = (e & 1) || (e == 0);
13167         e_conv = DecodeError_clone(&e_conv);
13168         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13169         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
13170         return (uint64_t)ret_conv;
13171 }
13172
13173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13174         if ((_res & 1) != 0) return;
13175         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
13176         FREE((void*)_res);
13177         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
13178 }
13179
13180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13181         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
13182         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13183         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
13184         return (uint64_t)ret_conv;
13185 }
13186
13187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13188         LDKUnsignedNodeAnnouncement o_conv;
13189         o_conv.inner = (void*)(o & (~1));
13190         o_conv.is_owned = (o & 1) || (o == 0);
13191         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
13192         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13193         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
13194         return (uint64_t)ret_conv;
13195 }
13196
13197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13198         LDKDecodeError e_conv;
13199         e_conv.inner = (void*)(e & (~1));
13200         e_conv.is_owned = (e & 1) || (e == 0);
13201         e_conv = DecodeError_clone(&e_conv);
13202         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13203         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13204         return (uint64_t)ret_conv;
13205 }
13206
13207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13208         if ((_res & 1) != 0) return;
13209         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13210         FREE((void*)_res);
13211         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13212 }
13213
13214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13215         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13216         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13217         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13218         return (uint64_t)ret_conv;
13219 }
13220
13221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13222         LDKNodeAnnouncement o_conv;
13223         o_conv.inner = (void*)(o & (~1));
13224         o_conv.is_owned = (o & 1) || (o == 0);
13225         o_conv = NodeAnnouncement_clone(&o_conv);
13226         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13227         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13228         return (uint64_t)ret_conv;
13229 }
13230
13231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13232         LDKDecodeError e_conv;
13233         e_conv.inner = (void*)(e & (~1));
13234         e_conv.is_owned = (e & 1) || (e == 0);
13235         e_conv = DecodeError_clone(&e_conv);
13236         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13237         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13238         return (uint64_t)ret_conv;
13239 }
13240
13241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13242         if ((_res & 1) != 0) return;
13243         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13244         FREE((void*)_res);
13245         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13246 }
13247
13248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13249         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13250         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13251         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13252         return (uint64_t)ret_conv;
13253 }
13254
13255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13256         LDKQueryShortChannelIds o_conv;
13257         o_conv.inner = (void*)(o & (~1));
13258         o_conv.is_owned = (o & 1) || (o == 0);
13259         o_conv = QueryShortChannelIds_clone(&o_conv);
13260         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13261         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13262         return (uint64_t)ret_conv;
13263 }
13264
13265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13266         LDKDecodeError e_conv;
13267         e_conv.inner = (void*)(e & (~1));
13268         e_conv.is_owned = (e & 1) || (e == 0);
13269         e_conv = DecodeError_clone(&e_conv);
13270         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13271         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13272         return (uint64_t)ret_conv;
13273 }
13274
13275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13276         if ((_res & 1) != 0) return;
13277         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
13278         FREE((void*)_res);
13279         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13280 }
13281
13282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13283         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13284         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13285         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13286         return (uint64_t)ret_conv;
13287 }
13288
13289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13290         LDKReplyShortChannelIdsEnd o_conv;
13291         o_conv.inner = (void*)(o & (~1));
13292         o_conv.is_owned = (o & 1) || (o == 0);
13293         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13294         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13295         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13296         return (uint64_t)ret_conv;
13297 }
13298
13299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13300         LDKDecodeError e_conv;
13301         e_conv.inner = (void*)(e & (~1));
13302         e_conv.is_owned = (e & 1) || (e == 0);
13303         e_conv = DecodeError_clone(&e_conv);
13304         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13305         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13306         return (uint64_t)ret_conv;
13307 }
13308
13309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13310         if ((_res & 1) != 0) return;
13311         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
13312         FREE((void*)_res);
13313         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13314 }
13315
13316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13317         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13318         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13319         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13320         return (uint64_t)ret_conv;
13321 }
13322
13323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13324         LDKQueryChannelRange o_conv;
13325         o_conv.inner = (void*)(o & (~1));
13326         o_conv.is_owned = (o & 1) || (o == 0);
13327         o_conv = QueryChannelRange_clone(&o_conv);
13328         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13329         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13330         return (uint64_t)ret_conv;
13331 }
13332
13333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13334         LDKDecodeError e_conv;
13335         e_conv.inner = (void*)(e & (~1));
13336         e_conv.is_owned = (e & 1) || (e == 0);
13337         e_conv = DecodeError_clone(&e_conv);
13338         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13339         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13340         return (uint64_t)ret_conv;
13341 }
13342
13343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13344         if ((_res & 1) != 0) return;
13345         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13346         FREE((void*)_res);
13347         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13348 }
13349
13350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13351         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13352         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13353         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13354         return (uint64_t)ret_conv;
13355 }
13356
13357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13358         LDKReplyChannelRange o_conv;
13359         o_conv.inner = (void*)(o & (~1));
13360         o_conv.is_owned = (o & 1) || (o == 0);
13361         o_conv = ReplyChannelRange_clone(&o_conv);
13362         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13363         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13364         return (uint64_t)ret_conv;
13365 }
13366
13367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13368         LDKDecodeError e_conv;
13369         e_conv.inner = (void*)(e & (~1));
13370         e_conv.is_owned = (e & 1) || (e == 0);
13371         e_conv = DecodeError_clone(&e_conv);
13372         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13373         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13374         return (uint64_t)ret_conv;
13375 }
13376
13377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13378         if ((_res & 1) != 0) return;
13379         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13380         FREE((void*)_res);
13381         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13382 }
13383
13384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13385         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13386         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13387         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13388         return (uint64_t)ret_conv;
13389 }
13390
13391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13392         LDKGossipTimestampFilter o_conv;
13393         o_conv.inner = (void*)(o & (~1));
13394         o_conv.is_owned = (o & 1) || (o == 0);
13395         o_conv = GossipTimestampFilter_clone(&o_conv);
13396         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13397         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13398         return (uint64_t)ret_conv;
13399 }
13400
13401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13402         LDKDecodeError e_conv;
13403         e_conv.inner = (void*)(e & (~1));
13404         e_conv.is_owned = (e & 1) || (e == 0);
13405         e_conv = DecodeError_clone(&e_conv);
13406         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13407         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13408         return (uint64_t)ret_conv;
13409 }
13410
13411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13412         if ((_res & 1) != 0) return;
13413         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
13414         FREE((void*)_res);
13415         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13416 }
13417
13418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13419         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13420         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13421         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13422         return (uint64_t)ret_conv;
13423 }
13424
13425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13426         LDKInvoice o_conv;
13427         o_conv.inner = (void*)(o & (~1));
13428         o_conv.is_owned = (o & 1) || (o == 0);
13429         o_conv = Invoice_clone(&o_conv);
13430         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13431         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13432         return (uint64_t)ret_conv;
13433 }
13434
13435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13436         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
13437         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13438         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13439         return (uint64_t)ret_conv;
13440 }
13441
13442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13443         if ((_res & 1) != 0) return;
13444         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
13445         FREE((void*)_res);
13446         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13447 }
13448
13449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13450         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13451         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13452         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13453         return (uint64_t)ret_conv;
13454 }
13455
13456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13457         if ((this_ptr & 1) != 0) return;
13458         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
13459         FREE((void*)this_ptr);
13460         PaymentPurpose_free(this_ptr_conv);
13461 }
13462
13463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13464         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
13465         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13466         *ret_copy = PaymentPurpose_clone(orig_conv);
13467         uint64_t ret_ref = (uint64_t)ret_copy;
13468         return ret_ref;
13469 }
13470
13471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13472         if ((this_ptr & 1) != 0) return;
13473         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
13474         FREE((void*)this_ptr);
13475         Event_free(this_ptr_conv);
13476 }
13477
13478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13479         LDKEvent* orig_conv = (LDKEvent*)orig;
13480         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13481         *ret_copy = Event_clone(orig_conv);
13482         uint64_t ret_ref = (uint64_t)ret_copy;
13483         return ret_ref;
13484 }
13485
13486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
13487         LDKEvent* obj_conv = (LDKEvent*)obj;
13488         LDKCVec_u8Z ret_var = Event_write(obj_conv);
13489         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13490         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13491         CVec_u8Z_free(ret_var);
13492         return ret_arr;
13493 }
13494
13495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13496         if ((this_ptr & 1) != 0) return;
13497         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
13498         FREE((void*)this_ptr);
13499         MessageSendEvent_free(this_ptr_conv);
13500 }
13501
13502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13503         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
13504         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13505         *ret_copy = MessageSendEvent_clone(orig_conv);
13506         uint64_t ret_ref = (uint64_t)ret_copy;
13507         return ret_ref;
13508 }
13509
13510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13511         if ((this_ptr & 1) != 0) return;
13512         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
13513         FREE((void*)this_ptr);
13514         MessageSendEventsProvider_free(this_ptr_conv);
13515 }
13516
13517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13518         if ((this_ptr & 1) != 0) return;
13519         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
13520         FREE((void*)this_ptr);
13521         EventsProvider_free(this_ptr_conv);
13522 }
13523
13524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13525         if ((this_ptr & 1) != 0) return;
13526         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
13527         FREE((void*)this_ptr);
13528         EventHandler_free(this_ptr_conv);
13529 }
13530
13531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13532         if ((this_ptr & 1) != 0) return;
13533         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
13534         FREE((void*)this_ptr);
13535         APIError_free(this_ptr_conv);
13536 }
13537
13538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13539         LDKAPIError* orig_conv = (LDKAPIError*)orig;
13540         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13541         *ret_copy = APIError_clone(orig_conv);
13542         uint64_t ret_ref = (uint64_t)ret_copy;
13543         return ret_ref;
13544 }
13545
13546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
13547         LDKu8slice msg_ref;
13548         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13549         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13550         unsigned char sk_arr[32];
13551         CHECK((*env)->GetArrayLength(env, sk) == 32);
13552         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
13553         unsigned char (*sk_ref)[32] = &sk_arr;
13554         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13555         *ret_conv = sign(msg_ref, sk_ref);
13556         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13557         return (uint64_t)ret_conv;
13558 }
13559
13560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
13561         LDKu8slice msg_ref;
13562         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13563         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13564         LDKStr sig_conv = java_to_owned_str(env, sig);
13565         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13566         *ret_conv = recover_pk(msg_ref, sig_conv);
13567         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13568         return (uint64_t)ret_conv;
13569 }
13570
13571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
13572         LDKu8slice msg_ref;
13573         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13574         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13575         LDKStr sig_conv = java_to_owned_str(env, sig);
13576         LDKPublicKey pk_ref;
13577         CHECK((*env)->GetArrayLength(env, pk) == 33);
13578         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
13579         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
13580         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13581         return ret_val;
13582 }
13583
13584 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13585         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
13586         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
13587         return ret_conv;
13588 }
13589
13590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
13591         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
13592         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
13593         jboolean ret_val = Level_eq(a_conv, b_conv);
13594         return ret_val;
13595 }
13596
13597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
13598         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13599         int64_t ret_val = Level_hash(o_conv);
13600         return ret_val;
13601 }
13602
13603 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13604         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13605         return ret_conv;
13606 }
13607
13608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13609         if ((this_ptr & 1) != 0) return;
13610         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13611         FREE((void*)this_ptr);
13612         Logger_free(this_ptr_conv);
13613 }
13614
13615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13616         LDKChannelHandshakeConfig this_obj_conv;
13617         this_obj_conv.inner = (void*)(this_obj & (~1));
13618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13619         ChannelHandshakeConfig_free(this_obj_conv);
13620 }
13621
13622 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13623         LDKChannelHandshakeConfig this_ptr_conv;
13624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13625         this_ptr_conv.is_owned = false;
13626         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13627         return ret_val;
13628 }
13629
13630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13631         LDKChannelHandshakeConfig this_ptr_conv;
13632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13633         this_ptr_conv.is_owned = false;
13634         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13635 }
13636
13637 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13638         LDKChannelHandshakeConfig this_ptr_conv;
13639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13640         this_ptr_conv.is_owned = false;
13641         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13642         return ret_val;
13643 }
13644
13645 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) {
13646         LDKChannelHandshakeConfig this_ptr_conv;
13647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13648         this_ptr_conv.is_owned = false;
13649         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13650 }
13651
13652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13653         LDKChannelHandshakeConfig this_ptr_conv;
13654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13655         this_ptr_conv.is_owned = false;
13656         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13657         return ret_val;
13658 }
13659
13660 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) {
13661         LDKChannelHandshakeConfig this_ptr_conv;
13662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13663         this_ptr_conv.is_owned = false;
13664         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13665 }
13666
13667 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) {
13668         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13671         uint64_t ret_ref = (uint64_t)ret_var.inner;
13672         if (ret_var.is_owned) {
13673                 ret_ref |= 1;
13674         }
13675         return ret_ref;
13676 }
13677
13678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13679         LDKChannelHandshakeConfig orig_conv;
13680         orig_conv.inner = (void*)(orig & (~1));
13681         orig_conv.is_owned = false;
13682         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13685         uint64_t ret_ref = (uint64_t)ret_var.inner;
13686         if (ret_var.is_owned) {
13687                 ret_ref |= 1;
13688         }
13689         return ret_ref;
13690 }
13691
13692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13693         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13694         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13695         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13696         uint64_t ret_ref = (uint64_t)ret_var.inner;
13697         if (ret_var.is_owned) {
13698                 ret_ref |= 1;
13699         }
13700         return ret_ref;
13701 }
13702
13703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13704         LDKChannelHandshakeLimits this_obj_conv;
13705         this_obj_conv.inner = (void*)(this_obj & (~1));
13706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13707         ChannelHandshakeLimits_free(this_obj_conv);
13708 }
13709
13710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13711         LDKChannelHandshakeLimits this_ptr_conv;
13712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13713         this_ptr_conv.is_owned = false;
13714         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13715         return ret_val;
13716 }
13717
13718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13719         LDKChannelHandshakeLimits this_ptr_conv;
13720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13721         this_ptr_conv.is_owned = false;
13722         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13723 }
13724
13725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13726         LDKChannelHandshakeLimits this_ptr_conv;
13727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13728         this_ptr_conv.is_owned = false;
13729         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13730         return ret_val;
13731 }
13732
13733 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) {
13734         LDKChannelHandshakeLimits this_ptr_conv;
13735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13736         this_ptr_conv.is_owned = false;
13737         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13738 }
13739
13740 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) {
13741         LDKChannelHandshakeLimits this_ptr_conv;
13742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13743         this_ptr_conv.is_owned = false;
13744         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13745         return ret_val;
13746 }
13747
13748 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) {
13749         LDKChannelHandshakeLimits this_ptr_conv;
13750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13751         this_ptr_conv.is_owned = false;
13752         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13753 }
13754
13755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13756         LDKChannelHandshakeLimits this_ptr_conv;
13757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13758         this_ptr_conv.is_owned = false;
13759         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13760         return ret_val;
13761 }
13762
13763 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) {
13764         LDKChannelHandshakeLimits this_ptr_conv;
13765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13766         this_ptr_conv.is_owned = false;
13767         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13768 }
13769
13770 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13771         LDKChannelHandshakeLimits this_ptr_conv;
13772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13773         this_ptr_conv.is_owned = false;
13774         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13775         return ret_val;
13776 }
13777
13778 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) {
13779         LDKChannelHandshakeLimits this_ptr_conv;
13780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13781         this_ptr_conv.is_owned = false;
13782         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13783 }
13784
13785 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13786         LDKChannelHandshakeLimits this_ptr_conv;
13787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13788         this_ptr_conv.is_owned = false;
13789         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
13790         return ret_val;
13791 }
13792
13793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13794         LDKChannelHandshakeLimits this_ptr_conv;
13795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13796         this_ptr_conv.is_owned = false;
13797         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
13798 }
13799
13800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
13801         LDKChannelHandshakeLimits this_ptr_conv;
13802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13803         this_ptr_conv.is_owned = false;
13804         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
13805         return ret_val;
13806 }
13807
13808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13809         LDKChannelHandshakeLimits this_ptr_conv;
13810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13811         this_ptr_conv.is_owned = false;
13812         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
13813 }
13814
13815 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13816         LDKChannelHandshakeLimits this_ptr_conv;
13817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13818         this_ptr_conv.is_owned = false;
13819         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
13820         return ret_val;
13821 }
13822
13823 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) {
13824         LDKChannelHandshakeLimits this_ptr_conv;
13825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13826         this_ptr_conv.is_owned = false;
13827         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
13828 }
13829
13830 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) {
13831         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);
13832         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13833         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13834         uint64_t ret_ref = (uint64_t)ret_var.inner;
13835         if (ret_var.is_owned) {
13836                 ret_ref |= 1;
13837         }
13838         return ret_ref;
13839 }
13840
13841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13842         LDKChannelHandshakeLimits orig_conv;
13843         orig_conv.inner = (void*)(orig & (~1));
13844         orig_conv.is_owned = false;
13845         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
13846         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13847         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13848         uint64_t ret_ref = (uint64_t)ret_var.inner;
13849         if (ret_var.is_owned) {
13850                 ret_ref |= 1;
13851         }
13852         return ret_ref;
13853 }
13854
13855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
13856         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
13857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13859         uint64_t ret_ref = (uint64_t)ret_var.inner;
13860         if (ret_var.is_owned) {
13861                 ret_ref |= 1;
13862         }
13863         return ret_ref;
13864 }
13865
13866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13867         LDKChannelConfig this_obj_conv;
13868         this_obj_conv.inner = (void*)(this_obj & (~1));
13869         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13870         ChannelConfig_free(this_obj_conv);
13871 }
13872
13873 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
13874         LDKChannelConfig this_ptr_conv;
13875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13876         this_ptr_conv.is_owned = false;
13877         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
13878         return ret_val;
13879 }
13880
13881 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) {
13882         LDKChannelConfig this_ptr_conv;
13883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13884         this_ptr_conv.is_owned = false;
13885         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
13886 }
13887
13888 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13889         LDKChannelConfig this_ptr_conv;
13890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13891         this_ptr_conv.is_owned = false;
13892         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
13893         return ret_val;
13894 }
13895
13896 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) {
13897         LDKChannelConfig this_ptr_conv;
13898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13899         this_ptr_conv.is_owned = false;
13900         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
13901 }
13902
13903 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
13904         LDKChannelConfig this_ptr_conv;
13905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13906         this_ptr_conv.is_owned = false;
13907         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
13908         return ret_val;
13909 }
13910
13911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13912         LDKChannelConfig this_ptr_conv;
13913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13914         this_ptr_conv.is_owned = false;
13915         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
13916 }
13917
13918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
13919         LDKChannelConfig this_ptr_conv;
13920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13921         this_ptr_conv.is_owned = false;
13922         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
13923         return ret_val;
13924 }
13925
13926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13927         LDKChannelConfig this_ptr_conv;
13928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13929         this_ptr_conv.is_owned = false;
13930         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
13931 }
13932
13933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13934         LDKChannelConfig this_ptr_conv;
13935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13936         this_ptr_conv.is_owned = false;
13937         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
13938         return ret_val;
13939 }
13940
13941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13942         LDKChannelConfig this_ptr_conv;
13943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13944         this_ptr_conv.is_owned = false;
13945         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
13946 }
13947
13948 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) {
13949         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);
13950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13952         uint64_t ret_ref = (uint64_t)ret_var.inner;
13953         if (ret_var.is_owned) {
13954                 ret_ref |= 1;
13955         }
13956         return ret_ref;
13957 }
13958
13959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13960         LDKChannelConfig orig_conv;
13961         orig_conv.inner = (void*)(orig & (~1));
13962         orig_conv.is_owned = false;
13963         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
13964         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13965         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13966         uint64_t ret_ref = (uint64_t)ret_var.inner;
13967         if (ret_var.is_owned) {
13968                 ret_ref |= 1;
13969         }
13970         return ret_ref;
13971 }
13972
13973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
13974         LDKChannelConfig ret_var = ChannelConfig_default();
13975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13977         uint64_t ret_ref = (uint64_t)ret_var.inner;
13978         if (ret_var.is_owned) {
13979                 ret_ref |= 1;
13980         }
13981         return ret_ref;
13982 }
13983
13984 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
13985         LDKChannelConfig obj_conv;
13986         obj_conv.inner = (void*)(obj & (~1));
13987         obj_conv.is_owned = false;
13988         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13989         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13990         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13991         CVec_u8Z_free(ret_var);
13992         return ret_arr;
13993 }
13994
13995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13996         LDKu8slice ser_ref;
13997         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13998         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13999         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14000         *ret_conv = ChannelConfig_read(ser_ref);
14001         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14002         return (uint64_t)ret_conv;
14003 }
14004
14005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14006         LDKUserConfig this_obj_conv;
14007         this_obj_conv.inner = (void*)(this_obj & (~1));
14008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14009         UserConfig_free(this_obj_conv);
14010 }
14011
14012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
14013         LDKUserConfig this_ptr_conv;
14014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14015         this_ptr_conv.is_owned = false;
14016         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
14017         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14018         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14019         uint64_t ret_ref = (uint64_t)ret_var.inner;
14020         if (ret_var.is_owned) {
14021                 ret_ref |= 1;
14022         }
14023         return ret_ref;
14024 }
14025
14026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14027         LDKUserConfig this_ptr_conv;
14028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14029         this_ptr_conv.is_owned = false;
14030         LDKChannelHandshakeConfig val_conv;
14031         val_conv.inner = (void*)(val & (~1));
14032         val_conv.is_owned = (val & 1) || (val == 0);
14033         val_conv = ChannelHandshakeConfig_clone(&val_conv);
14034         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
14035 }
14036
14037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
14038         LDKUserConfig this_ptr_conv;
14039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14040         this_ptr_conv.is_owned = false;
14041         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
14042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14044         uint64_t ret_ref = (uint64_t)ret_var.inner;
14045         if (ret_var.is_owned) {
14046                 ret_ref |= 1;
14047         }
14048         return ret_ref;
14049 }
14050
14051 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) {
14052         LDKUserConfig this_ptr_conv;
14053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14054         this_ptr_conv.is_owned = false;
14055         LDKChannelHandshakeLimits val_conv;
14056         val_conv.inner = (void*)(val & (~1));
14057         val_conv.is_owned = (val & 1) || (val == 0);
14058         val_conv = ChannelHandshakeLimits_clone(&val_conv);
14059         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
14060 }
14061
14062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
14063         LDKUserConfig this_ptr_conv;
14064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14065         this_ptr_conv.is_owned = false;
14066         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
14067         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14068         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14069         uint64_t ret_ref = (uint64_t)ret_var.inner;
14070         if (ret_var.is_owned) {
14071                 ret_ref |= 1;
14072         }
14073         return ret_ref;
14074 }
14075
14076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14077         LDKUserConfig this_ptr_conv;
14078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14079         this_ptr_conv.is_owned = false;
14080         LDKChannelConfig val_conv;
14081         val_conv.inner = (void*)(val & (~1));
14082         val_conv.is_owned = (val & 1) || (val == 0);
14083         val_conv = ChannelConfig_clone(&val_conv);
14084         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
14085 }
14086
14087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
14088         LDKUserConfig this_ptr_conv;
14089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14090         this_ptr_conv.is_owned = false;
14091         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
14092         return ret_val;
14093 }
14094
14095 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) {
14096         LDKUserConfig this_ptr_conv;
14097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14098         this_ptr_conv.is_owned = false;
14099         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
14100 }
14101
14102 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) {
14103         LDKChannelHandshakeConfig own_channel_config_arg_conv;
14104         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
14105         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
14106         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
14107         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
14108         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
14109         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
14110         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
14111         LDKChannelConfig channel_options_arg_conv;
14112         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
14113         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
14114         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
14115         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);
14116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14118         uint64_t ret_ref = (uint64_t)ret_var.inner;
14119         if (ret_var.is_owned) {
14120                 ret_ref |= 1;
14121         }
14122         return ret_ref;
14123 }
14124
14125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14126         LDKUserConfig orig_conv;
14127         orig_conv.inner = (void*)(orig & (~1));
14128         orig_conv.is_owned = false;
14129         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
14130         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14131         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14132         uint64_t ret_ref = (uint64_t)ret_var.inner;
14133         if (ret_var.is_owned) {
14134                 ret_ref |= 1;
14135         }
14136         return ret_ref;
14137 }
14138
14139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
14140         LDKUserConfig ret_var = UserConfig_default();
14141         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14142         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14143         uint64_t ret_ref = (uint64_t)ret_var.inner;
14144         if (ret_var.is_owned) {
14145                 ret_ref |= 1;
14146         }
14147         return ret_ref;
14148 }
14149
14150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14151         LDKBestBlock this_obj_conv;
14152         this_obj_conv.inner = (void*)(this_obj & (~1));
14153         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14154         BestBlock_free(this_obj_conv);
14155 }
14156
14157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14158         LDKBestBlock orig_conv;
14159         orig_conv.inner = (void*)(orig & (~1));
14160         orig_conv.is_owned = false;
14161         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
14162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14164         uint64_t ret_ref = (uint64_t)ret_var.inner;
14165         if (ret_var.is_owned) {
14166                 ret_ref |= 1;
14167         }
14168         return ret_ref;
14169 }
14170
14171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
14172         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
14173         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
14174         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14175         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14176         uint64_t ret_ref = (uint64_t)ret_var.inner;
14177         if (ret_var.is_owned) {
14178                 ret_ref |= 1;
14179         }
14180         return ret_ref;
14181 }
14182
14183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
14184         LDKThirtyTwoBytes block_hash_ref;
14185         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
14186         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
14187         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
14188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14190         uint64_t ret_ref = (uint64_t)ret_var.inner;
14191         if (ret_var.is_owned) {
14192                 ret_ref |= 1;
14193         }
14194         return ret_ref;
14195 }
14196
14197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14198         LDKBestBlock this_arg_conv;
14199         this_arg_conv.inner = (void*)(this_arg & (~1));
14200         this_arg_conv.is_owned = false;
14201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
14203         return ret_arr;
14204 }
14205
14206 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
14207         LDKBestBlock this_arg_conv;
14208         this_arg_conv.inner = (void*)(this_arg & (~1));
14209         this_arg_conv.is_owned = false;
14210         int32_t ret_val = BestBlock_height(&this_arg_conv);
14211         return ret_val;
14212 }
14213
14214 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14215         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
14216         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
14217         return ret_conv;
14218 }
14219
14220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14221         if ((this_ptr & 1) != 0) return;
14222         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
14223         FREE((void*)this_ptr);
14224         Access_free(this_ptr_conv);
14225 }
14226
14227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14228         if ((this_ptr & 1) != 0) return;
14229         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
14230         FREE((void*)this_ptr);
14231         Listen_free(this_ptr_conv);
14232 }
14233
14234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14235         if ((this_ptr & 1) != 0) return;
14236         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
14237         FREE((void*)this_ptr);
14238         Confirm_free(this_ptr_conv);
14239 }
14240
14241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14242         if ((this_ptr & 1) != 0) return;
14243         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
14244         FREE((void*)this_ptr);
14245         Watch_free(this_ptr_conv);
14246 }
14247
14248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14249         if ((this_ptr & 1) != 0) return;
14250         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
14251         FREE((void*)this_ptr);
14252         Filter_free(this_ptr_conv);
14253 }
14254
14255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14256         LDKWatchedOutput this_obj_conv;
14257         this_obj_conv.inner = (void*)(this_obj & (~1));
14258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14259         WatchedOutput_free(this_obj_conv);
14260 }
14261
14262 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14263         LDKWatchedOutput this_ptr_conv;
14264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14265         this_ptr_conv.is_owned = false;
14266         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14267         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
14268         return ret_arr;
14269 }
14270
14271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14272         LDKWatchedOutput this_ptr_conv;
14273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14274         this_ptr_conv.is_owned = false;
14275         LDKThirtyTwoBytes val_ref;
14276         CHECK((*env)->GetArrayLength(env, val) == 32);
14277         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14278         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
14279 }
14280
14281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14282         LDKWatchedOutput this_ptr_conv;
14283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14284         this_ptr_conv.is_owned = false;
14285         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
14286         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14287         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14288         uint64_t ret_ref = (uint64_t)ret_var.inner;
14289         if (ret_var.is_owned) {
14290                 ret_ref |= 1;
14291         }
14292         return ret_ref;
14293 }
14294
14295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14296         LDKWatchedOutput this_ptr_conv;
14297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14298         this_ptr_conv.is_owned = false;
14299         LDKOutPoint val_conv;
14300         val_conv.inner = (void*)(val & (~1));
14301         val_conv.is_owned = (val & 1) || (val == 0);
14302         val_conv = OutPoint_clone(&val_conv);
14303         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
14304 }
14305
14306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14307         LDKWatchedOutput this_ptr_conv;
14308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14309         this_ptr_conv.is_owned = false;
14310         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
14311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14313         return ret_arr;
14314 }
14315
14316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14317         LDKWatchedOutput this_ptr_conv;
14318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14319         this_ptr_conv.is_owned = false;
14320         LDKCVec_u8Z val_ref;
14321         val_ref.datalen = (*env)->GetArrayLength(env, val);
14322         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14323         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14324         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
14325 }
14326
14327 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) {
14328         LDKThirtyTwoBytes block_hash_arg_ref;
14329         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
14330         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
14331         LDKOutPoint outpoint_arg_conv;
14332         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14333         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14334         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14335         LDKCVec_u8Z script_pubkey_arg_ref;
14336         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
14337         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14338         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
14339         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
14340         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14341         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14342         uint64_t ret_ref = (uint64_t)ret_var.inner;
14343         if (ret_var.is_owned) {
14344                 ret_ref |= 1;
14345         }
14346         return ret_ref;
14347 }
14348
14349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14350         LDKWatchedOutput orig_conv;
14351         orig_conv.inner = (void*)(orig & (~1));
14352         orig_conv.is_owned = false;
14353         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
14354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14356         uint64_t ret_ref = (uint64_t)ret_var.inner;
14357         if (ret_var.is_owned) {
14358                 ret_ref |= 1;
14359         }
14360         return ret_ref;
14361 }
14362
14363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
14364         LDKWatchedOutput o_conv;
14365         o_conv.inner = (void*)(o & (~1));
14366         o_conv.is_owned = false;
14367         int64_t ret_val = WatchedOutput_hash(&o_conv);
14368         return ret_val;
14369 }
14370
14371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14372         if ((this_ptr & 1) != 0) return;
14373         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
14374         FREE((void*)this_ptr);
14375         BroadcasterInterface_free(this_ptr_conv);
14376 }
14377
14378 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14379         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
14380         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
14381         return ret_conv;
14382 }
14383
14384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14385         if ((this_ptr & 1) != 0) return;
14386         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
14387         FREE((void*)this_ptr);
14388         FeeEstimator_free(this_ptr_conv);
14389 }
14390
14391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14392         LDKChainMonitor this_obj_conv;
14393         this_obj_conv.inner = (void*)(this_obj & (~1));
14394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14395         ChainMonitor_free(this_obj_conv);
14396 }
14397
14398 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) {
14399         LDKFilter *chain_source_conv_ptr = NULL;
14400         if (chain_source != 0) {
14401                 LDKFilter chain_source_conv;
14402                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
14403                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
14404                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14405                         LDKFilter_JCalls_cloned(&chain_source_conv);
14406                 }
14407                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
14408                 *chain_source_conv_ptr = chain_source_conv;
14409         }
14410         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14411         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14412                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14413                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14414         }
14415         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14416         if (logger_conv.free == LDKLogger_JCalls_free) {
14417                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14418                 LDKLogger_JCalls_cloned(&logger_conv);
14419         }
14420         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
14421         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
14422                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14423                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
14424         }
14425         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
14426         if (persister_conv.free == LDKPersist_JCalls_free) {
14427                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14428                 LDKPersist_JCalls_cloned(&persister_conv);
14429         }
14430         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
14431         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14432         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14433         uint64_t ret_ref = (uint64_t)ret_var.inner;
14434         if (ret_var.is_owned) {
14435                 ret_ref |= 1;
14436         }
14437         return ret_ref;
14438 }
14439
14440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
14441         LDKChainMonitor this_arg_conv;
14442         this_arg_conv.inner = (void*)(this_arg & (~1));
14443         this_arg_conv.is_owned = false;
14444         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
14445         *ret = ChainMonitor_as_Listen(&this_arg_conv);
14446         return (uint64_t)ret;
14447 }
14448
14449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
14450         LDKChainMonitor this_arg_conv;
14451         this_arg_conv.inner = (void*)(this_arg & (~1));
14452         this_arg_conv.is_owned = false;
14453         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
14454         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
14455         return (uint64_t)ret;
14456 }
14457
14458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14459         LDKChainMonitor this_arg_conv;
14460         this_arg_conv.inner = (void*)(this_arg & (~1));
14461         this_arg_conv.is_owned = false;
14462         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
14463         *ret = ChainMonitor_as_Watch(&this_arg_conv);
14464         return (uint64_t)ret;
14465 }
14466
14467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
14468         LDKChainMonitor this_arg_conv;
14469         this_arg_conv.inner = (void*)(this_arg & (~1));
14470         this_arg_conv.is_owned = false;
14471         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
14472         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
14473         return (uint64_t)ret;
14474 }
14475
14476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14477         LDKChannelMonitorUpdate this_obj_conv;
14478         this_obj_conv.inner = (void*)(this_obj & (~1));
14479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14480         ChannelMonitorUpdate_free(this_obj_conv);
14481 }
14482
14483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14484         LDKChannelMonitorUpdate this_ptr_conv;
14485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14486         this_ptr_conv.is_owned = false;
14487         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
14488         return ret_val;
14489 }
14490
14491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14492         LDKChannelMonitorUpdate this_ptr_conv;
14493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14494         this_ptr_conv.is_owned = false;
14495         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
14496 }
14497
14498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14499         LDKChannelMonitorUpdate orig_conv;
14500         orig_conv.inner = (void*)(orig & (~1));
14501         orig_conv.is_owned = false;
14502         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
14503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14505         uint64_t ret_ref = (uint64_t)ret_var.inner;
14506         if (ret_var.is_owned) {
14507                 ret_ref |= 1;
14508         }
14509         return ret_ref;
14510 }
14511
14512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14513         LDKChannelMonitorUpdate obj_conv;
14514         obj_conv.inner = (void*)(obj & (~1));
14515         obj_conv.is_owned = false;
14516         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
14517         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14518         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14519         CVec_u8Z_free(ret_var);
14520         return ret_arr;
14521 }
14522
14523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14524         LDKu8slice ser_ref;
14525         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14526         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14527         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14528         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
14529         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14530         return (uint64_t)ret_conv;
14531 }
14532
14533 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14534         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
14535         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
14536         return ret_conv;
14537 }
14538
14539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14540         LDKMonitorUpdateError this_obj_conv;
14541         this_obj_conv.inner = (void*)(this_obj & (~1));
14542         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14543         MonitorUpdateError_free(this_obj_conv);
14544 }
14545
14546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14547         LDKMonitorUpdateError orig_conv;
14548         orig_conv.inner = (void*)(orig & (~1));
14549         orig_conv.is_owned = false;
14550         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
14551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14553         uint64_t ret_ref = (uint64_t)ret_var.inner;
14554         if (ret_var.is_owned) {
14555                 ret_ref |= 1;
14556         }
14557         return ret_ref;
14558 }
14559
14560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14561         if ((this_ptr & 1) != 0) return;
14562         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
14563         FREE((void*)this_ptr);
14564         MonitorEvent_free(this_ptr_conv);
14565 }
14566
14567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14568         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
14569         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14570         *ret_copy = MonitorEvent_clone(orig_conv);
14571         uint64_t ret_ref = (uint64_t)ret_copy;
14572         return ret_ref;
14573 }
14574
14575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14576         LDKHTLCUpdate this_obj_conv;
14577         this_obj_conv.inner = (void*)(this_obj & (~1));
14578         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14579         HTLCUpdate_free(this_obj_conv);
14580 }
14581
14582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14583         LDKHTLCUpdate orig_conv;
14584         orig_conv.inner = (void*)(orig & (~1));
14585         orig_conv.is_owned = false;
14586         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
14587         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14588         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14589         uint64_t ret_ref = (uint64_t)ret_var.inner;
14590         if (ret_var.is_owned) {
14591                 ret_ref |= 1;
14592         }
14593         return ret_ref;
14594 }
14595
14596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14597         LDKHTLCUpdate obj_conv;
14598         obj_conv.inner = (void*)(obj & (~1));
14599         obj_conv.is_owned = false;
14600         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
14601         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14602         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14603         CVec_u8Z_free(ret_var);
14604         return ret_arr;
14605 }
14606
14607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14608         LDKu8slice ser_ref;
14609         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14610         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14611         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14612         *ret_conv = HTLCUpdate_read(ser_ref);
14613         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14614         return (uint64_t)ret_conv;
14615 }
14616
14617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14618         LDKChannelMonitor this_obj_conv;
14619         this_obj_conv.inner = (void*)(this_obj & (~1));
14620         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14621         ChannelMonitor_free(this_obj_conv);
14622 }
14623
14624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14625         LDKChannelMonitor orig_conv;
14626         orig_conv.inner = (void*)(orig & (~1));
14627         orig_conv.is_owned = false;
14628         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
14629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14631         uint64_t ret_ref = (uint64_t)ret_var.inner;
14632         if (ret_var.is_owned) {
14633                 ret_ref |= 1;
14634         }
14635         return ret_ref;
14636 }
14637
14638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14639         LDKChannelMonitor obj_conv;
14640         obj_conv.inner = (void*)(obj & (~1));
14641         obj_conv.is_owned = false;
14642         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
14643         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14644         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14645         CVec_u8Z_free(ret_var);
14646         return ret_arr;
14647 }
14648
14649 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) {
14650         LDKChannelMonitor this_arg_conv;
14651         this_arg_conv.inner = (void*)(this_arg & (~1));
14652         this_arg_conv.is_owned = false;
14653         LDKChannelMonitorUpdate updates_conv;
14654         updates_conv.inner = (void*)(updates & (~1));
14655         updates_conv.is_owned = false;
14656         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14657         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14658         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14659         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14660         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
14661         return (uint64_t)ret_conv;
14662 }
14663
14664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14665         LDKChannelMonitor this_arg_conv;
14666         this_arg_conv.inner = (void*)(this_arg & (~1));
14667         this_arg_conv.is_owned = false;
14668         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
14669         return ret_val;
14670 }
14671
14672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
14673         LDKChannelMonitor this_arg_conv;
14674         this_arg_conv.inner = (void*)(this_arg & (~1));
14675         this_arg_conv.is_owned = false;
14676         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14677         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
14678         return (uint64_t)ret_ref;
14679 }
14680
14681 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14682         LDKChannelMonitor this_arg_conv;
14683         this_arg_conv.inner = (void*)(this_arg & (~1));
14684         this_arg_conv.is_owned = false;
14685         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
14686         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14687         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14688         for (size_t v = 0; v < ret_var.datalen; v++) {
14689                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14690                 *ret_conv_47_ref = ret_var.data[v];
14691                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
14692         }
14693         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14694         FREE(ret_var.data);
14695         return ret_arr;
14696 }
14697
14698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14699         LDKChannelMonitor this_arg_conv;
14700         this_arg_conv.inner = (void*)(this_arg & (~1));
14701         this_arg_conv.is_owned = false;
14702         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14703         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14704 }
14705
14706 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14707         LDKChannelMonitor this_arg_conv;
14708         this_arg_conv.inner = (void*)(this_arg & (~1));
14709         this_arg_conv.is_owned = false;
14710         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14711         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14712         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14713         for (size_t o = 0; o < ret_var.datalen; o++) {
14714                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14715                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14716                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14717                 ret_arr_ptr[o] = ret_conv_14_ref;
14718         }
14719         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14720         FREE(ret_var.data);
14721         return ret_arr;
14722 }
14723
14724 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14725         LDKChannelMonitor this_arg_conv;
14726         this_arg_conv.inner = (void*)(this_arg & (~1));
14727         this_arg_conv.is_owned = false;
14728         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14729         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14730         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14731         for (size_t h = 0; h < ret_var.datalen; h++) {
14732                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14733                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
14734                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
14735                 ret_arr_ptr[h] = ret_conv_7_ref;
14736         }
14737         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14738         FREE(ret_var.data);
14739         return ret_arr;
14740 }
14741
14742 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) {
14743         LDKChannelMonitor this_arg_conv;
14744         this_arg_conv.inner = (void*)(this_arg & (~1));
14745         this_arg_conv.is_owned = false;
14746         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14747         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
14748         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14749         ;
14750         for (size_t i = 0; i < ret_var.datalen; i++) {
14751                 LDKTransaction ret_conv_8_var = ret_var.data[i];
14752                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
14753                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
14754                 Transaction_free(ret_conv_8_var);
14755                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14756         }
14757         FREE(ret_var.data);
14758         return ret_arr;
14759 }
14760
14761 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) {
14762         LDKChannelMonitor this_arg_conv;
14763         this_arg_conv.inner = (void*)(this_arg & (~1));
14764         this_arg_conv.is_owned = false;
14765         unsigned char header_arr[80];
14766         CHECK((*env)->GetArrayLength(env, header) == 80);
14767         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14768         unsigned char (*header_ref)[80] = &header_arr;
14769         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14770         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14771         if (txdata_constr.datalen > 0)
14772                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14773         else
14774                 txdata_constr.data = NULL;
14775         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14776         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14777                 int64_t txdata_conv_24 = txdata_vals[y];
14778                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14779                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14780                 txdata_constr.data[y] = txdata_conv_24_conv;
14781         }
14782         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14783         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14784         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14785                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14786                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14787         }
14788         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14789         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14790                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14791                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14792         }
14793         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14794         if (logger_conv.free == LDKLogger_JCalls_free) {
14795                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14796                 LDKLogger_JCalls_cloned(&logger_conv);
14797         }
14798         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);
14799         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14800         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14801         for (size_t u = 0; u < ret_var.datalen; u++) {
14802                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14803                 *ret_conv_46_ref = ret_var.data[u];
14804                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14805         }
14806         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14807         FREE(ret_var.data);
14808         return ret_arr;
14809 }
14810
14811 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) {
14812         LDKChannelMonitor this_arg_conv;
14813         this_arg_conv.inner = (void*)(this_arg & (~1));
14814         this_arg_conv.is_owned = false;
14815         unsigned char header_arr[80];
14816         CHECK((*env)->GetArrayLength(env, header) == 80);
14817         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14818         unsigned char (*header_ref)[80] = &header_arr;
14819         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14820         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14821                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14822                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14823         }
14824         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14825         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14826                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14827                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14828         }
14829         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14830         if (logger_conv.free == LDKLogger_JCalls_free) {
14831                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14832                 LDKLogger_JCalls_cloned(&logger_conv);
14833         }
14834         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14835 }
14836
14837 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) {
14838         LDKChannelMonitor this_arg_conv;
14839         this_arg_conv.inner = (void*)(this_arg & (~1));
14840         this_arg_conv.is_owned = false;
14841         unsigned char header_arr[80];
14842         CHECK((*env)->GetArrayLength(env, header) == 80);
14843         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14844         unsigned char (*header_ref)[80] = &header_arr;
14845         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14846         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14847         if (txdata_constr.datalen > 0)
14848                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14849         else
14850                 txdata_constr.data = NULL;
14851         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14852         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14853                 int64_t txdata_conv_24 = txdata_vals[y];
14854                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14855                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14856                 txdata_constr.data[y] = txdata_conv_24_conv;
14857         }
14858         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14859         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14860         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14861                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14862                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14863         }
14864         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14865         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14866                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14867                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14868         }
14869         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14870         if (logger_conv.free == LDKLogger_JCalls_free) {
14871                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14872                 LDKLogger_JCalls_cloned(&logger_conv);
14873         }
14874         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);
14875         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14876         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14877         for (size_t u = 0; u < ret_var.datalen; u++) {
14878                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14879                 *ret_conv_46_ref = ret_var.data[u];
14880                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14881         }
14882         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14883         FREE(ret_var.data);
14884         return ret_arr;
14885 }
14886
14887 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) {
14888         LDKChannelMonitor this_arg_conv;
14889         this_arg_conv.inner = (void*)(this_arg & (~1));
14890         this_arg_conv.is_owned = false;
14891         unsigned char txid_arr[32];
14892         CHECK((*env)->GetArrayLength(env, txid) == 32);
14893         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
14894         unsigned char (*txid_ref)[32] = &txid_arr;
14895         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14896         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14897                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14898                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14899         }
14900         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14901         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14902                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14903                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14904         }
14905         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14906         if (logger_conv.free == LDKLogger_JCalls_free) {
14907                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14908                 LDKLogger_JCalls_cloned(&logger_conv);
14909         }
14910         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
14911 }
14912
14913 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) {
14914         LDKChannelMonitor this_arg_conv;
14915         this_arg_conv.inner = (void*)(this_arg & (~1));
14916         this_arg_conv.is_owned = false;
14917         unsigned char header_arr[80];
14918         CHECK((*env)->GetArrayLength(env, header) == 80);
14919         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14920         unsigned char (*header_ref)[80] = &header_arr;
14921         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14922         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14923                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14924                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14925         }
14926         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14927         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14928                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14929                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
14930         }
14931         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14932         if (logger_conv.free == LDKLogger_JCalls_free) {
14933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14934                 LDKLogger_JCalls_cloned(&logger_conv);
14935         }
14936         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14937         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14938         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14939         for (size_t u = 0; u < ret_var.datalen; u++) {
14940                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14941                 *ret_conv_46_ref = ret_var.data[u];
14942                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14943         }
14944         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14945         FREE(ret_var.data);
14946         return ret_arr;
14947 }
14948
14949 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
14950         LDKChannelMonitor this_arg_conv;
14951         this_arg_conv.inner = (void*)(this_arg & (~1));
14952         this_arg_conv.is_owned = false;
14953         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14954         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14955         ;
14956         for (size_t i = 0; i < ret_var.datalen; i++) {
14957                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
14958                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
14959                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14960         }
14961         FREE(ret_var.data);
14962         return ret_arr;
14963 }
14964
14965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
14966         LDKChannelMonitor this_arg_conv;
14967         this_arg_conv.inner = (void*)(this_arg & (~1));
14968         this_arg_conv.is_owned = false;
14969         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
14970         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14971         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14972         uint64_t ret_ref = (uint64_t)ret_var.inner;
14973         if (ret_var.is_owned) {
14974                 ret_ref |= 1;
14975         }
14976         return ret_ref;
14977 }
14978
14979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14980         if ((this_ptr & 1) != 0) return;
14981         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
14982         FREE((void*)this_ptr);
14983         Persist_free(this_ptr_conv);
14984 }
14985
14986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
14987         LDKu8slice ser_ref;
14988         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14989         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14990         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14991         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14992         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14993         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14994         return (uint64_t)ret_conv;
14995 }
14996
14997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14998         LDKOutPoint this_obj_conv;
14999         this_obj_conv.inner = (void*)(this_obj & (~1));
15000         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15001         OutPoint_free(this_obj_conv);
15002 }
15003
15004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
15005         LDKOutPoint this_ptr_conv;
15006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15007         this_ptr_conv.is_owned = false;
15008         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15009         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
15010         return ret_arr;
15011 }
15012
15013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15014         LDKOutPoint this_ptr_conv;
15015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15016         this_ptr_conv.is_owned = false;
15017         LDKThirtyTwoBytes val_ref;
15018         CHECK((*env)->GetArrayLength(env, val) == 32);
15019         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15020         OutPoint_set_txid(&this_ptr_conv, val_ref);
15021 }
15022
15023 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
15024         LDKOutPoint this_ptr_conv;
15025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15026         this_ptr_conv.is_owned = false;
15027         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
15028         return ret_val;
15029 }
15030
15031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15032         LDKOutPoint this_ptr_conv;
15033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15034         this_ptr_conv.is_owned = false;
15035         OutPoint_set_index(&this_ptr_conv, val);
15036 }
15037
15038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
15039         LDKThirtyTwoBytes txid_arg_ref;
15040         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
15041         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
15042         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
15043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15045         uint64_t ret_ref = (uint64_t)ret_var.inner;
15046         if (ret_var.is_owned) {
15047                 ret_ref |= 1;
15048         }
15049         return ret_ref;
15050 }
15051
15052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15053         LDKOutPoint orig_conv;
15054         orig_conv.inner = (void*)(orig & (~1));
15055         orig_conv.is_owned = false;
15056         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
15057         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15058         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15059         uint64_t ret_ref = (uint64_t)ret_var.inner;
15060         if (ret_var.is_owned) {
15061                 ret_ref |= 1;
15062         }
15063         return ret_ref;
15064 }
15065
15066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
15067         LDKOutPoint a_conv;
15068         a_conv.inner = (void*)(a & (~1));
15069         a_conv.is_owned = false;
15070         LDKOutPoint b_conv;
15071         b_conv.inner = (void*)(b & (~1));
15072         b_conv.is_owned = false;
15073         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
15074         return ret_val;
15075 }
15076
15077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
15078         LDKOutPoint o_conv;
15079         o_conv.inner = (void*)(o & (~1));
15080         o_conv.is_owned = false;
15081         int64_t ret_val = OutPoint_hash(&o_conv);
15082         return ret_val;
15083 }
15084
15085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15086         LDKOutPoint this_arg_conv;
15087         this_arg_conv.inner = (void*)(this_arg & (~1));
15088         this_arg_conv.is_owned = false;
15089         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
15091         return ret_arr;
15092 }
15093
15094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
15095         LDKOutPoint obj_conv;
15096         obj_conv.inner = (void*)(obj & (~1));
15097         obj_conv.is_owned = false;
15098         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
15099         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15100         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15101         CVec_u8Z_free(ret_var);
15102         return ret_arr;
15103 }
15104
15105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15106         LDKu8slice ser_ref;
15107         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15108         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15109         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15110         *ret_conv = OutPoint_read(ser_ref);
15111         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15112         return (uint64_t)ret_conv;
15113 }
15114
15115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15116         LDKDelayedPaymentOutputDescriptor this_obj_conv;
15117         this_obj_conv.inner = (void*)(this_obj & (~1));
15118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15119         DelayedPaymentOutputDescriptor_free(this_obj_conv);
15120 }
15121
15122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15123         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15125         this_ptr_conv.is_owned = false;
15126         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15127         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15128         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15129         uint64_t ret_ref = (uint64_t)ret_var.inner;
15130         if (ret_var.is_owned) {
15131                 ret_ref |= 1;
15132         }
15133         return ret_ref;
15134 }
15135
15136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15137         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15139         this_ptr_conv.is_owned = false;
15140         LDKOutPoint val_conv;
15141         val_conv.inner = (void*)(val & (~1));
15142         val_conv.is_owned = (val & 1) || (val == 0);
15143         val_conv = OutPoint_clone(&val_conv);
15144         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15145 }
15146
15147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15148         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15150         this_ptr_conv.is_owned = false;
15151         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15152         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
15153         return ret_arr;
15154 }
15155
15156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15157         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15159         this_ptr_conv.is_owned = false;
15160         LDKPublicKey val_ref;
15161         CHECK((*env)->GetArrayLength(env, val) == 33);
15162         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15163         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
15164 }
15165
15166 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
15167         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15169         this_ptr_conv.is_owned = false;
15170         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
15171         return ret_val;
15172 }
15173
15174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15175         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15177         this_ptr_conv.is_owned = false;
15178         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
15179 }
15180
15181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15182         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15184         this_ptr_conv.is_owned = false;
15185         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15186         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15187 }
15188
15189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
15190         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15192         this_ptr_conv.is_owned = false;
15193         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
15195         return ret_arr;
15196 }
15197
15198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15199         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15201         this_ptr_conv.is_owned = false;
15202         LDKPublicKey val_ref;
15203         CHECK((*env)->GetArrayLength(env, val) == 33);
15204         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15205         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
15206 }
15207
15208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15209         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15211         this_ptr_conv.is_owned = false;
15212         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15213         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15214         return ret_arr;
15215 }
15216
15217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15218         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15220         this_ptr_conv.is_owned = false;
15221         LDKThirtyTwoBytes val_ref;
15222         CHECK((*env)->GetArrayLength(env, val) == 32);
15223         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15224         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15225 }
15226
15227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15228         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15230         this_ptr_conv.is_owned = false;
15231         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15232         return ret_val;
15233 }
15234
15235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15236         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15238         this_ptr_conv.is_owned = false;
15239         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15240 }
15241
15242 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) {
15243         LDKOutPoint outpoint_arg_conv;
15244         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15245         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15246         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15247         LDKPublicKey per_commitment_point_arg_ref;
15248         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
15249         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
15250         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15251         LDKPublicKey revocation_pubkey_arg_ref;
15252         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
15253         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
15254         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15255         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15256         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15257         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);
15258         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15259         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15260         uint64_t ret_ref = (uint64_t)ret_var.inner;
15261         if (ret_var.is_owned) {
15262                 ret_ref |= 1;
15263         }
15264         return ret_ref;
15265 }
15266
15267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15268         LDKDelayedPaymentOutputDescriptor orig_conv;
15269         orig_conv.inner = (void*)(orig & (~1));
15270         orig_conv.is_owned = false;
15271         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
15272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15274         uint64_t ret_ref = (uint64_t)ret_var.inner;
15275         if (ret_var.is_owned) {
15276                 ret_ref |= 1;
15277         }
15278         return ret_ref;
15279 }
15280
15281 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15282         LDKDelayedPaymentOutputDescriptor obj_conv;
15283         obj_conv.inner = (void*)(obj & (~1));
15284         obj_conv.is_owned = false;
15285         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
15286         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15287         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15288         CVec_u8Z_free(ret_var);
15289         return ret_arr;
15290 }
15291
15292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15293         LDKu8slice ser_ref;
15294         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15295         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15296         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15297         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
15298         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15299         return (uint64_t)ret_conv;
15300 }
15301
15302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15303         LDKStaticPaymentOutputDescriptor this_obj_conv;
15304         this_obj_conv.inner = (void*)(this_obj & (~1));
15305         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15306         StaticPaymentOutputDescriptor_free(this_obj_conv);
15307 }
15308
15309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15310         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15312         this_ptr_conv.is_owned = false;
15313         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15314         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15315         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15316         uint64_t ret_ref = (uint64_t)ret_var.inner;
15317         if (ret_var.is_owned) {
15318                 ret_ref |= 1;
15319         }
15320         return ret_ref;
15321 }
15322
15323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15324         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15326         this_ptr_conv.is_owned = false;
15327         LDKOutPoint val_conv;
15328         val_conv.inner = (void*)(val & (~1));
15329         val_conv.is_owned = (val & 1) || (val == 0);
15330         val_conv = OutPoint_clone(&val_conv);
15331         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15332 }
15333
15334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15335         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15337         this_ptr_conv.is_owned = false;
15338         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15339         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15340 }
15341
15342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15343         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15345         this_ptr_conv.is_owned = false;
15346         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15347         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15348         return ret_arr;
15349 }
15350
15351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15352         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15354         this_ptr_conv.is_owned = false;
15355         LDKThirtyTwoBytes val_ref;
15356         CHECK((*env)->GetArrayLength(env, val) == 32);
15357         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15358         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15359 }
15360
15361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15362         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15364         this_ptr_conv.is_owned = false;
15365         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15366         return ret_val;
15367 }
15368
15369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15370         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15372         this_ptr_conv.is_owned = false;
15373         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15374 }
15375
15376 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) {
15377         LDKOutPoint outpoint_arg_conv;
15378         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15379         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15380         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15381         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15382         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15383         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15384         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15385         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
15386         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15387         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15388         uint64_t ret_ref = (uint64_t)ret_var.inner;
15389         if (ret_var.is_owned) {
15390                 ret_ref |= 1;
15391         }
15392         return ret_ref;
15393 }
15394
15395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15396         LDKStaticPaymentOutputDescriptor orig_conv;
15397         orig_conv.inner = (void*)(orig & (~1));
15398         orig_conv.is_owned = false;
15399         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
15400         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15401         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15402         uint64_t ret_ref = (uint64_t)ret_var.inner;
15403         if (ret_var.is_owned) {
15404                 ret_ref |= 1;
15405         }
15406         return ret_ref;
15407 }
15408
15409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15410         LDKStaticPaymentOutputDescriptor obj_conv;
15411         obj_conv.inner = (void*)(obj & (~1));
15412         obj_conv.is_owned = false;
15413         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
15414         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15415         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15416         CVec_u8Z_free(ret_var);
15417         return ret_arr;
15418 }
15419
15420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15421         LDKu8slice ser_ref;
15422         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15423         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15424         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15425         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
15426         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15427         return (uint64_t)ret_conv;
15428 }
15429
15430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15431         if ((this_ptr & 1) != 0) return;
15432         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
15433         FREE((void*)this_ptr);
15434         SpendableOutputDescriptor_free(this_ptr_conv);
15435 }
15436
15437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15438         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
15439         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15440         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
15441         uint64_t ret_ref = (uint64_t)ret_copy;
15442         return ret_ref;
15443 }
15444
15445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15446         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
15447         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
15448         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15449         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15450         CVec_u8Z_free(ret_var);
15451         return ret_arr;
15452 }
15453
15454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15455         LDKu8slice ser_ref;
15456         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15457         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15458         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15459         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
15460         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15461         return (uint64_t)ret_conv;
15462 }
15463
15464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15465         if ((this_ptr & 1) != 0) return;
15466         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
15467         FREE((void*)this_ptr);
15468         BaseSign_free(this_ptr_conv);
15469 }
15470
15471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15472         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
15473         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15474         *ret = Sign_clone(orig_conv);
15475         return (uint64_t)ret;
15476 }
15477
15478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15479         if ((this_ptr & 1) != 0) return;
15480         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
15481         FREE((void*)this_ptr);
15482         Sign_free(this_ptr_conv);
15483 }
15484
15485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15486         if ((this_ptr & 1) != 0) return;
15487         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
15488         FREE((void*)this_ptr);
15489         KeysInterface_free(this_ptr_conv);
15490 }
15491
15492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15493         LDKInMemorySigner this_obj_conv;
15494         this_obj_conv.inner = (void*)(this_obj & (~1));
15495         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15496         InMemorySigner_free(this_obj_conv);
15497 }
15498
15499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15500         LDKInMemorySigner this_ptr_conv;
15501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15502         this_ptr_conv.is_owned = false;
15503         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15504         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
15505         return ret_arr;
15506 }
15507
15508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15509         LDKInMemorySigner this_ptr_conv;
15510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15511         this_ptr_conv.is_owned = false;
15512         LDKSecretKey val_ref;
15513         CHECK((*env)->GetArrayLength(env, val) == 32);
15514         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15515         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
15516 }
15517
15518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15519         LDKInMemorySigner this_ptr_conv;
15520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15521         this_ptr_conv.is_owned = false;
15522         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15523         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
15524         return ret_arr;
15525 }
15526
15527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15528         LDKInMemorySigner this_ptr_conv;
15529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15530         this_ptr_conv.is_owned = false;
15531         LDKSecretKey val_ref;
15532         CHECK((*env)->GetArrayLength(env, val) == 32);
15533         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15534         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
15535 }
15536
15537 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15538         LDKInMemorySigner this_ptr_conv;
15539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15540         this_ptr_conv.is_owned = false;
15541         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15542         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
15543         return ret_arr;
15544 }
15545
15546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15547         LDKInMemorySigner this_ptr_conv;
15548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15549         this_ptr_conv.is_owned = false;
15550         LDKSecretKey val_ref;
15551         CHECK((*env)->GetArrayLength(env, val) == 32);
15552         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15553         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
15554 }
15555
15556 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15557         LDKInMemorySigner this_ptr_conv;
15558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15559         this_ptr_conv.is_owned = false;
15560         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
15562         return ret_arr;
15563 }
15564
15565 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) {
15566         LDKInMemorySigner this_ptr_conv;
15567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15568         this_ptr_conv.is_owned = false;
15569         LDKSecretKey val_ref;
15570         CHECK((*env)->GetArrayLength(env, val) == 32);
15571         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15572         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
15573 }
15574
15575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15576         LDKInMemorySigner this_ptr_conv;
15577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15578         this_ptr_conv.is_owned = false;
15579         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15580         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
15581         return ret_arr;
15582 }
15583
15584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15585         LDKInMemorySigner this_ptr_conv;
15586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15587         this_ptr_conv.is_owned = false;
15588         LDKSecretKey val_ref;
15589         CHECK((*env)->GetArrayLength(env, val) == 32);
15590         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15591         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
15592 }
15593
15594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
15595         LDKInMemorySigner this_ptr_conv;
15596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15597         this_ptr_conv.is_owned = false;
15598         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15599         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
15600         return ret_arr;
15601 }
15602
15603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15604         LDKInMemorySigner this_ptr_conv;
15605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15606         this_ptr_conv.is_owned = false;
15607         LDKThirtyTwoBytes val_ref;
15608         CHECK((*env)->GetArrayLength(env, val) == 32);
15609         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15610         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
15611 }
15612
15613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15614         LDKInMemorySigner orig_conv;
15615         orig_conv.inner = (void*)(orig & (~1));
15616         orig_conv.is_owned = false;
15617         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
15618         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15619         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15620         uint64_t ret_ref = (uint64_t)ret_var.inner;
15621         if (ret_var.is_owned) {
15622                 ret_ref |= 1;
15623         }
15624         return ret_ref;
15625 }
15626
15627 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) {
15628         LDKSecretKey funding_key_ref;
15629         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
15630         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
15631         LDKSecretKey revocation_base_key_ref;
15632         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
15633         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
15634         LDKSecretKey payment_key_ref;
15635         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
15636         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
15637         LDKSecretKey delayed_payment_base_key_ref;
15638         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
15639         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
15640         LDKSecretKey htlc_base_key_ref;
15641         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
15642         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
15643         LDKThirtyTwoBytes commitment_seed_ref;
15644         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
15645         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
15646         LDKThirtyTwoBytes channel_keys_id_ref;
15647         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
15648         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
15649         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);
15650         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15651         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15652         uint64_t ret_ref = (uint64_t)ret_var.inner;
15653         if (ret_var.is_owned) {
15654                 ret_ref |= 1;
15655         }
15656         return ret_ref;
15657 }
15658
15659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
15660         LDKInMemorySigner this_arg_conv;
15661         this_arg_conv.inner = (void*)(this_arg & (~1));
15662         this_arg_conv.is_owned = false;
15663         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
15664         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15665         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15666         uint64_t ret_ref = (uint64_t)ret_var.inner;
15667         if (ret_var.is_owned) {
15668                 ret_ref |= 1;
15669         }
15670         return ret_ref;
15671 }
15672
15673 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15674         LDKInMemorySigner this_arg_conv;
15675         this_arg_conv.inner = (void*)(this_arg & (~1));
15676         this_arg_conv.is_owned = false;
15677         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
15678         return ret_val;
15679 }
15680
15681 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15682         LDKInMemorySigner this_arg_conv;
15683         this_arg_conv.inner = (void*)(this_arg & (~1));
15684         this_arg_conv.is_owned = false;
15685         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
15686         return ret_val;
15687 }
15688
15689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
15690         LDKInMemorySigner this_arg_conv;
15691         this_arg_conv.inner = (void*)(this_arg & (~1));
15692         this_arg_conv.is_owned = false;
15693         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
15694         return ret_val;
15695 }
15696
15697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
15698         LDKInMemorySigner this_arg_conv;
15699         this_arg_conv.inner = (void*)(this_arg & (~1));
15700         this_arg_conv.is_owned = false;
15701         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
15702         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15703         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15704         uint64_t ret_ref = (uint64_t)ret_var.inner;
15705         if (ret_var.is_owned) {
15706                 ret_ref |= 1;
15707         }
15708         return ret_ref;
15709 }
15710
15711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
15712         LDKInMemorySigner this_arg_conv;
15713         this_arg_conv.inner = (void*)(this_arg & (~1));
15714         this_arg_conv.is_owned = false;
15715         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
15716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15718         uint64_t ret_ref = (uint64_t)ret_var.inner;
15719         if (ret_var.is_owned) {
15720                 ret_ref |= 1;
15721         }
15722         return ret_ref;
15723 }
15724
15725 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) {
15726         LDKInMemorySigner this_arg_conv;
15727         this_arg_conv.inner = (void*)(this_arg & (~1));
15728         this_arg_conv.is_owned = false;
15729         LDKTransaction spend_tx_ref;
15730         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15731         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15732         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15733         spend_tx_ref.data_is_owned = true;
15734         LDKStaticPaymentOutputDescriptor descriptor_conv;
15735         descriptor_conv.inner = (void*)(descriptor & (~1));
15736         descriptor_conv.is_owned = false;
15737         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15738         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15739         return (uint64_t)ret_conv;
15740 }
15741
15742 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) {
15743         LDKInMemorySigner this_arg_conv;
15744         this_arg_conv.inner = (void*)(this_arg & (~1));
15745         this_arg_conv.is_owned = false;
15746         LDKTransaction spend_tx_ref;
15747         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15748         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15749         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15750         spend_tx_ref.data_is_owned = true;
15751         LDKDelayedPaymentOutputDescriptor descriptor_conv;
15752         descriptor_conv.inner = (void*)(descriptor & (~1));
15753         descriptor_conv.is_owned = false;
15754         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15755         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15756         return (uint64_t)ret_conv;
15757 }
15758
15759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
15760         LDKInMemorySigner this_arg_conv;
15761         this_arg_conv.inner = (void*)(this_arg & (~1));
15762         this_arg_conv.is_owned = false;
15763         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
15764         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
15765         return (uint64_t)ret;
15766 }
15767
15768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
15769         LDKInMemorySigner this_arg_conv;
15770         this_arg_conv.inner = (void*)(this_arg & (~1));
15771         this_arg_conv.is_owned = false;
15772         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15773         *ret = InMemorySigner_as_Sign(&this_arg_conv);
15774         return (uint64_t)ret;
15775 }
15776
15777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
15778         LDKInMemorySigner obj_conv;
15779         obj_conv.inner = (void*)(obj & (~1));
15780         obj_conv.is_owned = false;
15781         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
15782         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15783         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15784         CVec_u8Z_free(ret_var);
15785         return ret_arr;
15786 }
15787
15788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15789         LDKu8slice ser_ref;
15790         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15791         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15792         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15793         *ret_conv = InMemorySigner_read(ser_ref);
15794         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15795         return (uint64_t)ret_conv;
15796 }
15797
15798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15799         LDKKeysManager this_obj_conv;
15800         this_obj_conv.inner = (void*)(this_obj & (~1));
15801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15802         KeysManager_free(this_obj_conv);
15803 }
15804
15805 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) {
15806         unsigned char seed_arr[32];
15807         CHECK((*env)->GetArrayLength(env, seed) == 32);
15808         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
15809         unsigned char (*seed_ref)[32] = &seed_arr;
15810         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
15811         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15812         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15813         uint64_t ret_ref = (uint64_t)ret_var.inner;
15814         if (ret_var.is_owned) {
15815                 ret_ref |= 1;
15816         }
15817         return ret_ref;
15818 }
15819
15820 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) {
15821         LDKKeysManager this_arg_conv;
15822         this_arg_conv.inner = (void*)(this_arg & (~1));
15823         this_arg_conv.is_owned = false;
15824         unsigned char params_arr[32];
15825         CHECK((*env)->GetArrayLength(env, params) == 32);
15826         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
15827         unsigned char (*params_ref)[32] = &params_arr;
15828         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
15829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15831         uint64_t ret_ref = (uint64_t)ret_var.inner;
15832         if (ret_var.is_owned) {
15833                 ret_ref |= 1;
15834         }
15835         return ret_ref;
15836 }
15837
15838 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) {
15839         LDKKeysManager this_arg_conv;
15840         this_arg_conv.inner = (void*)(this_arg & (~1));
15841         this_arg_conv.is_owned = false;
15842         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
15843         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
15844         if (descriptors_constr.datalen > 0)
15845                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15846         else
15847                 descriptors_constr.data = NULL;
15848         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
15849         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
15850                 int64_t descriptors_conv_27 = descriptors_vals[b];
15851                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
15852                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
15853                 descriptors_constr.data[b] = descriptors_conv_27_conv;
15854         }
15855         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
15856         LDKCVec_TxOutZ outputs_constr;
15857         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15858         if (outputs_constr.datalen > 0)
15859                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15860         else
15861                 outputs_constr.data = NULL;
15862         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15863         for (size_t h = 0; h < outputs_constr.datalen; h++) {
15864                 int64_t outputs_conv_7 = outputs_vals[h];
15865                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
15866                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
15867                 outputs_constr.data[h] = outputs_conv_7_conv;
15868         }
15869         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15870         LDKCVec_u8Z change_destination_script_ref;
15871         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
15872         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
15873         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
15874         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15875         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
15876         return (uint64_t)ret_conv;
15877 }
15878
15879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
15880         LDKKeysManager this_arg_conv;
15881         this_arg_conv.inner = (void*)(this_arg & (~1));
15882         this_arg_conv.is_owned = false;
15883         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15884         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
15885         return (uint64_t)ret;
15886 }
15887
15888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15889         LDKChannelManager this_obj_conv;
15890         this_obj_conv.inner = (void*)(this_obj & (~1));
15891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15892         ChannelManager_free(this_obj_conv);
15893 }
15894
15895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15896         LDKChainParameters this_obj_conv;
15897         this_obj_conv.inner = (void*)(this_obj & (~1));
15898         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15899         ChainParameters_free(this_obj_conv);
15900 }
15901
15902 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
15903         LDKChainParameters this_ptr_conv;
15904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15905         this_ptr_conv.is_owned = false;
15906         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
15907         return ret_conv;
15908 }
15909
15910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
15911         LDKChainParameters this_ptr_conv;
15912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15913         this_ptr_conv.is_owned = false;
15914         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
15915         ChainParameters_set_network(&this_ptr_conv, val_conv);
15916 }
15917
15918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
15919         LDKChainParameters this_ptr_conv;
15920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15921         this_ptr_conv.is_owned = false;
15922         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15923         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15924         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15925         uint64_t ret_ref = (uint64_t)ret_var.inner;
15926         if (ret_var.is_owned) {
15927                 ret_ref |= 1;
15928         }
15929         return ret_ref;
15930 }
15931
15932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15933         LDKChainParameters this_ptr_conv;
15934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15935         this_ptr_conv.is_owned = false;
15936         LDKBestBlock val_conv;
15937         val_conv.inner = (void*)(val & (~1));
15938         val_conv.is_owned = (val & 1) || (val == 0);
15939         val_conv = BestBlock_clone(&val_conv);
15940         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15941 }
15942
15943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
15944         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
15945         LDKBestBlock best_block_arg_conv;
15946         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15947         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15948         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15949         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15952         uint64_t ret_ref = (uint64_t)ret_var.inner;
15953         if (ret_var.is_owned) {
15954                 ret_ref |= 1;
15955         }
15956         return ret_ref;
15957 }
15958
15959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15960         LDKChainParameters orig_conv;
15961         orig_conv.inner = (void*)(orig & (~1));
15962         orig_conv.is_owned = false;
15963         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15964         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15965         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15966         uint64_t ret_ref = (uint64_t)ret_var.inner;
15967         if (ret_var.is_owned) {
15968                 ret_ref |= 1;
15969         }
15970         return ret_ref;
15971 }
15972
15973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15974         LDKChannelCounterparty this_obj_conv;
15975         this_obj_conv.inner = (void*)(this_obj & (~1));
15976         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15977         ChannelCounterparty_free(this_obj_conv);
15978 }
15979
15980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15981         LDKChannelCounterparty this_ptr_conv;
15982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15983         this_ptr_conv.is_owned = false;
15984         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15985         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
15986         return ret_arr;
15987 }
15988
15989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15990         LDKChannelCounterparty this_ptr_conv;
15991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15992         this_ptr_conv.is_owned = false;
15993         LDKPublicKey val_ref;
15994         CHECK((*env)->GetArrayLength(env, val) == 33);
15995         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15996         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
15997 }
15998
15999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16000         LDKChannelCounterparty this_ptr_conv;
16001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16002         this_ptr_conv.is_owned = false;
16003         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
16004         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16005         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16006         uint64_t ret_ref = (uint64_t)ret_var.inner;
16007         if (ret_var.is_owned) {
16008                 ret_ref |= 1;
16009         }
16010         return ret_ref;
16011 }
16012
16013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16014         LDKChannelCounterparty this_ptr_conv;
16015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16016         this_ptr_conv.is_owned = false;
16017         LDKInitFeatures val_conv;
16018         val_conv.inner = (void*)(val & (~1));
16019         val_conv.is_owned = (val & 1) || (val == 0);
16020         val_conv = InitFeatures_clone(&val_conv);
16021         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
16022 }
16023
16024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16025         LDKChannelCounterparty this_ptr_conv;
16026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16027         this_ptr_conv.is_owned = false;
16028         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
16029         return ret_val;
16030 }
16031
16032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16033         LDKChannelCounterparty this_ptr_conv;
16034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16035         this_ptr_conv.is_owned = false;
16036         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
16037 }
16038
16039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16040         LDKChannelCounterparty orig_conv;
16041         orig_conv.inner = (void*)(orig & (~1));
16042         orig_conv.is_owned = false;
16043         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
16044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16046         uint64_t ret_ref = (uint64_t)ret_var.inner;
16047         if (ret_var.is_owned) {
16048                 ret_ref |= 1;
16049         }
16050         return ret_ref;
16051 }
16052
16053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16054         LDKChannelDetails this_obj_conv;
16055         this_obj_conv.inner = (void*)(this_obj & (~1));
16056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16057         ChannelDetails_free(this_obj_conv);
16058 }
16059
16060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16061         LDKChannelDetails this_ptr_conv;
16062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16063         this_ptr_conv.is_owned = false;
16064         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
16066         return ret_arr;
16067 }
16068
16069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16070         LDKChannelDetails this_ptr_conv;
16071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16072         this_ptr_conv.is_owned = false;
16073         LDKThirtyTwoBytes val_ref;
16074         CHECK((*env)->GetArrayLength(env, val) == 32);
16075         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16076         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
16077 }
16078
16079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
16080         LDKChannelDetails this_ptr_conv;
16081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16082         this_ptr_conv.is_owned = false;
16083         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
16084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16086         uint64_t ret_ref = (uint64_t)ret_var.inner;
16087         if (ret_var.is_owned) {
16088                 ret_ref |= 1;
16089         }
16090         return ret_ref;
16091 }
16092
16093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16094         LDKChannelDetails this_ptr_conv;
16095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16096         this_ptr_conv.is_owned = false;
16097         LDKChannelCounterparty val_conv;
16098         val_conv.inner = (void*)(val & (~1));
16099         val_conv.is_owned = (val & 1) || (val == 0);
16100         val_conv = ChannelCounterparty_clone(&val_conv);
16101         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
16102 }
16103
16104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
16105         LDKChannelDetails this_ptr_conv;
16106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16107         this_ptr_conv.is_owned = false;
16108         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
16109         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16110         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16111         uint64_t ret_ref = (uint64_t)ret_var.inner;
16112         if (ret_var.is_owned) {
16113                 ret_ref |= 1;
16114         }
16115         return ret_ref;
16116 }
16117
16118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16119         LDKChannelDetails this_ptr_conv;
16120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16121         this_ptr_conv.is_owned = false;
16122         LDKOutPoint val_conv;
16123         val_conv.inner = (void*)(val & (~1));
16124         val_conv.is_owned = (val & 1) || (val == 0);
16125         val_conv = OutPoint_clone(&val_conv);
16126         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
16127 }
16128
16129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16130         LDKChannelDetails this_ptr_conv;
16131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16132         this_ptr_conv.is_owned = false;
16133         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16134         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
16135         uint64_t ret_ref = (uint64_t)ret_copy;
16136         return ret_ref;
16137 }
16138
16139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16140         LDKChannelDetails this_ptr_conv;
16141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16142         this_ptr_conv.is_owned = false;
16143         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16144         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
16145 }
16146
16147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16148         LDKChannelDetails this_ptr_conv;
16149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16150         this_ptr_conv.is_owned = false;
16151         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
16152         return ret_val;
16153 }
16154
16155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16156         LDKChannelDetails this_ptr_conv;
16157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16158         this_ptr_conv.is_owned = false;
16159         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
16160 }
16161
16162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16163         LDKChannelDetails this_ptr_conv;
16164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16165         this_ptr_conv.is_owned = false;
16166         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16167         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
16168         uint64_t ret_ref = (uint64_t)ret_copy;
16169         return ret_ref;
16170 }
16171
16172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16173         LDKChannelDetails this_ptr_conv;
16174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16175         this_ptr_conv.is_owned = false;
16176         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16177         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
16178 }
16179
16180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16181         LDKChannelDetails this_ptr_conv;
16182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16183         this_ptr_conv.is_owned = false;
16184         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
16185         return ret_val;
16186 }
16187
16188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16189         LDKChannelDetails this_ptr_conv;
16190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16191         this_ptr_conv.is_owned = false;
16192         ChannelDetails_set_user_id(&this_ptr_conv, val);
16193 }
16194
16195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16196         LDKChannelDetails this_ptr_conv;
16197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16198         this_ptr_conv.is_owned = false;
16199         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
16200         return ret_val;
16201 }
16202
16203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16204         LDKChannelDetails this_ptr_conv;
16205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16206         this_ptr_conv.is_owned = false;
16207         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
16208 }
16209
16210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16211         LDKChannelDetails this_ptr_conv;
16212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16213         this_ptr_conv.is_owned = false;
16214         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
16215         return ret_val;
16216 }
16217
16218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16219         LDKChannelDetails this_ptr_conv;
16220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16221         this_ptr_conv.is_owned = false;
16222         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16223 }
16224
16225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
16226         LDKChannelDetails this_ptr_conv;
16227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16228         this_ptr_conv.is_owned = false;
16229         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16230         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16231         uint64_t ret_ref = (uint64_t)ret_copy;
16232         return ret_ref;
16233 }
16234
16235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16236         LDKChannelDetails this_ptr_conv;
16237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16238         this_ptr_conv.is_owned = false;
16239         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16240         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16241 }
16242
16243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16244         LDKChannelDetails this_ptr_conv;
16245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16246         this_ptr_conv.is_owned = false;
16247         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16248         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16249         uint64_t ret_ref = (uint64_t)ret_copy;
16250         return ret_ref;
16251 }
16252
16253 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) {
16254         LDKChannelDetails this_ptr_conv;
16255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16256         this_ptr_conv.is_owned = false;
16257         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16258         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16259 }
16260
16261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
16262         LDKChannelDetails this_ptr_conv;
16263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16264         this_ptr_conv.is_owned = false;
16265         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16266         return ret_val;
16267 }
16268
16269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16270         LDKChannelDetails this_ptr_conv;
16271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16272         this_ptr_conv.is_owned = false;
16273         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16274 }
16275
16276 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
16277         LDKChannelDetails this_ptr_conv;
16278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16279         this_ptr_conv.is_owned = false;
16280         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16281         return ret_val;
16282 }
16283
16284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16285         LDKChannelDetails this_ptr_conv;
16286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16287         this_ptr_conv.is_owned = false;
16288         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16289 }
16290
16291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
16292         LDKChannelDetails this_ptr_conv;
16293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16294         this_ptr_conv.is_owned = false;
16295         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16296         return ret_val;
16297 }
16298
16299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16300         LDKChannelDetails this_ptr_conv;
16301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16302         this_ptr_conv.is_owned = false;
16303         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16304 }
16305
16306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
16307         LDKChannelDetails this_ptr_conv;
16308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16309         this_ptr_conv.is_owned = false;
16310         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16311         return ret_val;
16312 }
16313
16314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16315         LDKChannelDetails this_ptr_conv;
16316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16317         this_ptr_conv.is_owned = false;
16318         ChannelDetails_set_is_public(&this_ptr_conv, val);
16319 }
16320
16321 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) {
16322         LDKThirtyTwoBytes channel_id_arg_ref;
16323         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16324         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16325         LDKChannelCounterparty counterparty_arg_conv;
16326         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16327         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16328         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16329         LDKOutPoint funding_txo_arg_conv;
16330         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16331         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16332         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16333         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16334         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16335         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16336         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16337         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);
16338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16340         uint64_t ret_ref = (uint64_t)ret_var.inner;
16341         if (ret_var.is_owned) {
16342                 ret_ref |= 1;
16343         }
16344         return ret_ref;
16345 }
16346
16347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16348         LDKChannelDetails orig_conv;
16349         orig_conv.inner = (void*)(orig & (~1));
16350         orig_conv.is_owned = false;
16351         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
16352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16354         uint64_t ret_ref = (uint64_t)ret_var.inner;
16355         if (ret_var.is_owned) {
16356                 ret_ref |= 1;
16357         }
16358         return ret_ref;
16359 }
16360
16361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16362         if ((this_ptr & 1) != 0) return;
16363         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
16364         FREE((void*)this_ptr);
16365         PaymentSendFailure_free(this_ptr_conv);
16366 }
16367
16368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16369         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
16370         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16371         *ret_copy = PaymentSendFailure_clone(orig_conv);
16372         uint64_t ret_ref = (uint64_t)ret_copy;
16373         return ret_ref;
16374 }
16375
16376 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) {
16377         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
16378         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
16379                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16380                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
16381         }
16382         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16383         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16384                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16385                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
16386         }
16387         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16388         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16389                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16390                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
16391         }
16392         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16393         if (logger_conv.free == LDKLogger_JCalls_free) {
16394                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16395                 LDKLogger_JCalls_cloned(&logger_conv);
16396         }
16397         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16398         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16399                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16400                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
16401         }
16402         LDKUserConfig config_conv;
16403         config_conv.inner = (void*)(config & (~1));
16404         config_conv.is_owned = (config & 1) || (config == 0);
16405         config_conv = UserConfig_clone(&config_conv);
16406         LDKChainParameters params_conv;
16407         params_conv.inner = (void*)(params & (~1));
16408         params_conv.is_owned = (params & 1) || (params == 0);
16409         params_conv = ChainParameters_clone(&params_conv);
16410         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
16411         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16412         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16413         uint64_t ret_ref = (uint64_t)ret_var.inner;
16414         if (ret_var.is_owned) {
16415                 ret_ref |= 1;
16416         }
16417         return ret_ref;
16418 }
16419
16420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
16421         LDKChannelManager this_arg_conv;
16422         this_arg_conv.inner = (void*)(this_arg & (~1));
16423         this_arg_conv.is_owned = false;
16424         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
16425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16427         uint64_t ret_ref = (uint64_t)ret_var.inner;
16428         if (ret_var.is_owned) {
16429                 ret_ref |= 1;
16430         }
16431         return ret_ref;
16432 }
16433
16434 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) {
16435         LDKChannelManager this_arg_conv;
16436         this_arg_conv.inner = (void*)(this_arg & (~1));
16437         this_arg_conv.is_owned = false;
16438         LDKPublicKey their_network_key_ref;
16439         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
16440         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
16441         LDKUserConfig override_config_conv;
16442         override_config_conv.inner = (void*)(override_config & (~1));
16443         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
16444         override_config_conv = UserConfig_clone(&override_config_conv);
16445         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16446         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
16447         return (uint64_t)ret_conv;
16448 }
16449
16450 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16451         LDKChannelManager this_arg_conv;
16452         this_arg_conv.inner = (void*)(this_arg & (~1));
16453         this_arg_conv.is_owned = false;
16454         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
16455         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16456         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16457         for (size_t q = 0; q < ret_var.datalen; q++) {
16458                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16459                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16460                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16461                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16462                 if (ret_conv_16_var.is_owned) {
16463                         ret_conv_16_ref |= 1;
16464                 }
16465                 ret_arr_ptr[q] = ret_conv_16_ref;
16466         }
16467         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16468         FREE(ret_var.data);
16469         return ret_arr;
16470 }
16471
16472 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16473         LDKChannelManager this_arg_conv;
16474         this_arg_conv.inner = (void*)(this_arg & (~1));
16475         this_arg_conv.is_owned = false;
16476         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
16477         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16478         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16479         for (size_t q = 0; q < ret_var.datalen; q++) {
16480                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16481                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16482                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16483                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16484                 if (ret_conv_16_var.is_owned) {
16485                         ret_conv_16_ref |= 1;
16486                 }
16487                 ret_arr_ptr[q] = ret_conv_16_ref;
16488         }
16489         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16490         FREE(ret_var.data);
16491         return ret_arr;
16492 }
16493
16494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
16495         LDKChannelManager this_arg_conv;
16496         this_arg_conv.inner = (void*)(this_arg & (~1));
16497         this_arg_conv.is_owned = false;
16498         unsigned char channel_id_arr[32];
16499         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16500         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16501         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16502         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16503         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
16504         return (uint64_t)ret_conv;
16505 }
16506
16507 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) {
16508         LDKChannelManager this_arg_conv;
16509         this_arg_conv.inner = (void*)(this_arg & (~1));
16510         this_arg_conv.is_owned = false;
16511         unsigned char channel_id_arr[32];
16512         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16513         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16514         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16515         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16516         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
16517         return (uint64_t)ret_conv;
16518 }
16519
16520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16521         LDKChannelManager this_arg_conv;
16522         this_arg_conv.inner = (void*)(this_arg & (~1));
16523         this_arg_conv.is_owned = false;
16524         ChannelManager_force_close_all_channels(&this_arg_conv);
16525 }
16526
16527 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) {
16528         LDKChannelManager this_arg_conv;
16529         this_arg_conv.inner = (void*)(this_arg & (~1));
16530         this_arg_conv.is_owned = false;
16531         LDKRoute route_conv;
16532         route_conv.inner = (void*)(route & (~1));
16533         route_conv.is_owned = false;
16534         LDKThirtyTwoBytes payment_hash_ref;
16535         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16536         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16537         LDKThirtyTwoBytes payment_secret_ref;
16538         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
16539         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
16540         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16541         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
16542         return (uint64_t)ret_conv;
16543 }
16544
16545 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) {
16546         LDKChannelManager this_arg_conv;
16547         this_arg_conv.inner = (void*)(this_arg & (~1));
16548         this_arg_conv.is_owned = false;
16549         LDKRoute route_conv;
16550         route_conv.inner = (void*)(route & (~1));
16551         route_conv.is_owned = false;
16552         LDKThirtyTwoBytes payment_preimage_ref;
16553         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
16554         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
16555         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
16556         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
16557         return (uint64_t)ret_conv;
16558 }
16559
16560 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) {
16561         LDKChannelManager this_arg_conv;
16562         this_arg_conv.inner = (void*)(this_arg & (~1));
16563         this_arg_conv.is_owned = false;
16564         unsigned char temporary_channel_id_arr[32];
16565         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
16566         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
16567         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
16568         LDKTransaction funding_transaction_ref;
16569         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
16570         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
16571         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
16572         funding_transaction_ref.data_is_owned = true;
16573         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16574         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
16575         return (uint64_t)ret_conv;
16576 }
16577
16578 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) {
16579         LDKChannelManager this_arg_conv;
16580         this_arg_conv.inner = (void*)(this_arg & (~1));
16581         this_arg_conv.is_owned = false;
16582         LDKThreeBytes rgb_ref;
16583         CHECK((*env)->GetArrayLength(env, rgb) == 3);
16584         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
16585         LDKThirtyTwoBytes alias_ref;
16586         CHECK((*env)->GetArrayLength(env, alias) == 32);
16587         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
16588         LDKCVec_NetAddressZ addresses_constr;
16589         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
16590         if (addresses_constr.datalen > 0)
16591                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16592         else
16593                 addresses_constr.data = NULL;
16594         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
16595         for (size_t m = 0; m < addresses_constr.datalen; m++) {
16596                 int64_t addresses_conv_12 = addresses_vals[m];
16597                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
16598                 addresses_constr.data[m] = addresses_conv_12_conv;
16599         }
16600         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
16601         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
16602 }
16603
16604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
16605         LDKChannelManager this_arg_conv;
16606         this_arg_conv.inner = (void*)(this_arg & (~1));
16607         this_arg_conv.is_owned = false;
16608         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
16609 }
16610
16611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
16612         LDKChannelManager this_arg_conv;
16613         this_arg_conv.inner = (void*)(this_arg & (~1));
16614         this_arg_conv.is_owned = false;
16615         ChannelManager_timer_tick_occurred(&this_arg_conv);
16616 }
16617
16618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
16619         LDKChannelManager this_arg_conv;
16620         this_arg_conv.inner = (void*)(this_arg & (~1));
16621         this_arg_conv.is_owned = false;
16622         unsigned char payment_hash_arr[32];
16623         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16624         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
16625         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
16626         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
16627         return ret_val;
16628 }
16629
16630 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
16631         LDKChannelManager this_arg_conv;
16632         this_arg_conv.inner = (void*)(this_arg & (~1));
16633         this_arg_conv.is_owned = false;
16634         LDKThirtyTwoBytes payment_preimage_ref;
16635         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
16636         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
16637         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
16638         return ret_val;
16639 }
16640
16641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
16642         LDKChannelManager this_arg_conv;
16643         this_arg_conv.inner = (void*)(this_arg & (~1));
16644         this_arg_conv.is_owned = false;
16645         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16646         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
16647         return ret_arr;
16648 }
16649
16650 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) {
16651         LDKChannelManager this_arg_conv;
16652         this_arg_conv.inner = (void*)(this_arg & (~1));
16653         this_arg_conv.is_owned = false;
16654         LDKOutPoint funding_txo_conv;
16655         funding_txo_conv.inner = (void*)(funding_txo & (~1));
16656         funding_txo_conv.is_owned = false;
16657         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
16658 }
16659
16660 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) {
16661         LDKChannelManager this_arg_conv;
16662         this_arg_conv.inner = (void*)(this_arg & (~1));
16663         this_arg_conv.is_owned = false;
16664         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16665         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16666         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
16667         return (uint64_t)ret_ref;
16668 }
16669
16670 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) {
16671         LDKChannelManager this_arg_conv;
16672         this_arg_conv.inner = (void*)(this_arg & (~1));
16673         this_arg_conv.is_owned = false;
16674         LDKThirtyTwoBytes payment_hash_ref;
16675         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16676         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16677         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16678         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16679         *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);
16680         return (uint64_t)ret_conv;
16681 }
16682
16683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16684         LDKChannelManager this_arg_conv;
16685         this_arg_conv.inner = (void*)(this_arg & (~1));
16686         this_arg_conv.is_owned = false;
16687         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16688         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
16689         return (uint64_t)ret;
16690 }
16691
16692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16693         LDKChannelManager this_arg_conv;
16694         this_arg_conv.inner = (void*)(this_arg & (~1));
16695         this_arg_conv.is_owned = false;
16696         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
16697         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
16698         return (uint64_t)ret;
16699 }
16700
16701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
16702         LDKChannelManager this_arg_conv;
16703         this_arg_conv.inner = (void*)(this_arg & (~1));
16704         this_arg_conv.is_owned = false;
16705         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
16706         *ret = ChannelManager_as_Listen(&this_arg_conv);
16707         return (uint64_t)ret;
16708 }
16709
16710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
16711         LDKChannelManager this_arg_conv;
16712         this_arg_conv.inner = (void*)(this_arg & (~1));
16713         this_arg_conv.is_owned = false;
16714         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
16715         *ret = ChannelManager_as_Confirm(&this_arg_conv);
16716         return (uint64_t)ret;
16717 }
16718
16719 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) {
16720         LDKChannelManager this_arg_conv;
16721         this_arg_conv.inner = (void*)(this_arg & (~1));
16722         this_arg_conv.is_owned = false;
16723         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
16724         return ret_val;
16725 }
16726
16727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
16728         LDKChannelManager this_arg_conv;
16729         this_arg_conv.inner = (void*)(this_arg & (~1));
16730         this_arg_conv.is_owned = false;
16731         ChannelManager_await_persistable_update(&this_arg_conv);
16732 }
16733
16734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
16735         LDKChannelManager this_arg_conv;
16736         this_arg_conv.inner = (void*)(this_arg & (~1));
16737         this_arg_conv.is_owned = false;
16738         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
16739         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16740         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16741         uint64_t ret_ref = (uint64_t)ret_var.inner;
16742         if (ret_var.is_owned) {
16743                 ret_ref |= 1;
16744         }
16745         return ret_ref;
16746 }
16747
16748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
16749         LDKChannelManager this_arg_conv;
16750         this_arg_conv.inner = (void*)(this_arg & (~1));
16751         this_arg_conv.is_owned = false;
16752         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16753         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
16754         return (uint64_t)ret;
16755 }
16756
16757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
16758         LDKChannelManager obj_conv;
16759         obj_conv.inner = (void*)(obj & (~1));
16760         obj_conv.is_owned = false;
16761         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
16762         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16763         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16764         CVec_u8Z_free(ret_var);
16765         return ret_arr;
16766 }
16767
16768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16769         LDKChannelManagerReadArgs this_obj_conv;
16770         this_obj_conv.inner = (void*)(this_obj & (~1));
16771         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16772         ChannelManagerReadArgs_free(this_obj_conv);
16773 }
16774
16775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
16776         LDKChannelManagerReadArgs this_ptr_conv;
16777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16778         this_ptr_conv.is_owned = false;
16779         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
16780         return ret_ret;
16781 }
16782
16783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16784         LDKChannelManagerReadArgs this_ptr_conv;
16785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16786         this_ptr_conv.is_owned = false;
16787         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
16788         if (val_conv.free == LDKKeysInterface_JCalls_free) {
16789                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16790                 LDKKeysInterface_JCalls_cloned(&val_conv);
16791         }
16792         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
16793 }
16794
16795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
16796         LDKChannelManagerReadArgs this_ptr_conv;
16797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16798         this_ptr_conv.is_owned = false;
16799         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
16800         return ret_ret;
16801 }
16802
16803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16804         LDKChannelManagerReadArgs this_ptr_conv;
16805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16806         this_ptr_conv.is_owned = false;
16807         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
16808         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
16809                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16810                 LDKFeeEstimator_JCalls_cloned(&val_conv);
16811         }
16812         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16813 }
16814
16815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
16816         LDKChannelManagerReadArgs this_ptr_conv;
16817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16818         this_ptr_conv.is_owned = false;
16819         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16820         return ret_ret;
16821 }
16822
16823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16824         LDKChannelManagerReadArgs this_ptr_conv;
16825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16826         this_ptr_conv.is_owned = false;
16827         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16828         if (val_conv.free == LDKWatch_JCalls_free) {
16829                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16830                 LDKWatch_JCalls_cloned(&val_conv);
16831         }
16832         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16833 }
16834
16835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
16836         LDKChannelManagerReadArgs this_ptr_conv;
16837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16838         this_ptr_conv.is_owned = false;
16839         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16840         return ret_ret;
16841 }
16842
16843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16844         LDKChannelManagerReadArgs this_ptr_conv;
16845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16846         this_ptr_conv.is_owned = false;
16847         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16848         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
16849                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16850                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
16851         }
16852         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16853 }
16854
16855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
16856         LDKChannelManagerReadArgs this_ptr_conv;
16857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16858         this_ptr_conv.is_owned = false;
16859         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16860         return ret_ret;
16861 }
16862
16863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16864         LDKChannelManagerReadArgs this_ptr_conv;
16865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16866         this_ptr_conv.is_owned = false;
16867         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16868         if (val_conv.free == LDKLogger_JCalls_free) {
16869                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16870                 LDKLogger_JCalls_cloned(&val_conv);
16871         }
16872         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16873 }
16874
16875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16876         LDKChannelManagerReadArgs this_ptr_conv;
16877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16878         this_ptr_conv.is_owned = false;
16879         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
16880         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16881         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16882         uint64_t ret_ref = (uint64_t)ret_var.inner;
16883         if (ret_var.is_owned) {
16884                 ret_ref |= 1;
16885         }
16886         return ret_ref;
16887 }
16888
16889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16890         LDKChannelManagerReadArgs this_ptr_conv;
16891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16892         this_ptr_conv.is_owned = false;
16893         LDKUserConfig val_conv;
16894         val_conv.inner = (void*)(val & (~1));
16895         val_conv.is_owned = (val & 1) || (val == 0);
16896         val_conv = UserConfig_clone(&val_conv);
16897         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16898 }
16899
16900 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) {
16901         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16902         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16903                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16904                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
16905         }
16906         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16907         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16908                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16909                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
16910         }
16911         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16912         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16913                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16914                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
16915         }
16916         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16917         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16918                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16919                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
16920         }
16921         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16922         if (logger_conv.free == LDKLogger_JCalls_free) {
16923                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16924                 LDKLogger_JCalls_cloned(&logger_conv);
16925         }
16926         LDKUserConfig default_config_conv;
16927         default_config_conv.inner = (void*)(default_config & (~1));
16928         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16929         default_config_conv = UserConfig_clone(&default_config_conv);
16930         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16931         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
16932         if (channel_monitors_constr.datalen > 0)
16933                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16934         else
16935                 channel_monitors_constr.data = NULL;
16936         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
16937         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16938                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
16939                 LDKChannelMonitor channel_monitors_conv_16_conv;
16940                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16941                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16942                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16943         }
16944         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
16945         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);
16946         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16947         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16948         uint64_t ret_ref = (uint64_t)ret_var.inner;
16949         if (ret_var.is_owned) {
16950                 ret_ref |= 1;
16951         }
16952         return ret_ref;
16953 }
16954
16955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
16956         LDKu8slice ser_ref;
16957         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16958         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16959         LDKChannelManagerReadArgs arg_conv;
16960         arg_conv.inner = (void*)(arg & (~1));
16961         arg_conv.is_owned = (arg & 1) || (arg == 0);
16962         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16963         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16964         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16965         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16966         return (uint64_t)ret_conv;
16967 }
16968
16969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16970         LDKDecodeError this_obj_conv;
16971         this_obj_conv.inner = (void*)(this_obj & (~1));
16972         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16973         DecodeError_free(this_obj_conv);
16974 }
16975
16976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16977         LDKDecodeError orig_conv;
16978         orig_conv.inner = (void*)(orig & (~1));
16979         orig_conv.is_owned = false;
16980         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16983         uint64_t ret_ref = (uint64_t)ret_var.inner;
16984         if (ret_var.is_owned) {
16985                 ret_ref |= 1;
16986         }
16987         return ret_ref;
16988 }
16989
16990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16991         LDKInit this_obj_conv;
16992         this_obj_conv.inner = (void*)(this_obj & (~1));
16993         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16994         Init_free(this_obj_conv);
16995 }
16996
16997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16998         LDKInit this_ptr_conv;
16999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17000         this_ptr_conv.is_owned = false;
17001         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
17002         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17003         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17004         uint64_t ret_ref = (uint64_t)ret_var.inner;
17005         if (ret_var.is_owned) {
17006                 ret_ref |= 1;
17007         }
17008         return ret_ref;
17009 }
17010
17011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17012         LDKInit this_ptr_conv;
17013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17014         this_ptr_conv.is_owned = false;
17015         LDKInitFeatures val_conv;
17016         val_conv.inner = (void*)(val & (~1));
17017         val_conv.is_owned = (val & 1) || (val == 0);
17018         val_conv = InitFeatures_clone(&val_conv);
17019         Init_set_features(&this_ptr_conv, val_conv);
17020 }
17021
17022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
17023         LDKInitFeatures features_arg_conv;
17024         features_arg_conv.inner = (void*)(features_arg & (~1));
17025         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
17026         features_arg_conv = InitFeatures_clone(&features_arg_conv);
17027         LDKInit ret_var = Init_new(features_arg_conv);
17028         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17029         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17030         uint64_t ret_ref = (uint64_t)ret_var.inner;
17031         if (ret_var.is_owned) {
17032                 ret_ref |= 1;
17033         }
17034         return ret_ref;
17035 }
17036
17037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17038         LDKInit orig_conv;
17039         orig_conv.inner = (void*)(orig & (~1));
17040         orig_conv.is_owned = false;
17041         LDKInit ret_var = Init_clone(&orig_conv);
17042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17044         uint64_t ret_ref = (uint64_t)ret_var.inner;
17045         if (ret_var.is_owned) {
17046                 ret_ref |= 1;
17047         }
17048         return ret_ref;
17049 }
17050
17051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17052         LDKErrorMessage this_obj_conv;
17053         this_obj_conv.inner = (void*)(this_obj & (~1));
17054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17055         ErrorMessage_free(this_obj_conv);
17056 }
17057
17058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17059         LDKErrorMessage this_ptr_conv;
17060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17061         this_ptr_conv.is_owned = false;
17062         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
17064         return ret_arr;
17065 }
17066
17067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17068         LDKErrorMessage this_ptr_conv;
17069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17070         this_ptr_conv.is_owned = false;
17071         LDKThirtyTwoBytes val_ref;
17072         CHECK((*env)->GetArrayLength(env, val) == 32);
17073         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17074         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
17075 }
17076
17077 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
17078         LDKErrorMessage this_ptr_conv;
17079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17080         this_ptr_conv.is_owned = false;
17081         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
17082         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
17083         Str_free(ret_str);
17084         return ret_conv;
17085 }
17086
17087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
17088         LDKErrorMessage this_ptr_conv;
17089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17090         this_ptr_conv.is_owned = false;
17091         LDKStr val_conv = java_to_owned_str(env, val);
17092         ErrorMessage_set_data(&this_ptr_conv, val_conv);
17093 }
17094
17095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
17096         LDKThirtyTwoBytes channel_id_arg_ref;
17097         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17098         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17099         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
17100         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
17101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17103         uint64_t ret_ref = (uint64_t)ret_var.inner;
17104         if (ret_var.is_owned) {
17105                 ret_ref |= 1;
17106         }
17107         return ret_ref;
17108 }
17109
17110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17111         LDKErrorMessage orig_conv;
17112         orig_conv.inner = (void*)(orig & (~1));
17113         orig_conv.is_owned = false;
17114         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
17115         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17116         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17117         uint64_t ret_ref = (uint64_t)ret_var.inner;
17118         if (ret_var.is_owned) {
17119                 ret_ref |= 1;
17120         }
17121         return ret_ref;
17122 }
17123
17124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17125         LDKPing this_obj_conv;
17126         this_obj_conv.inner = (void*)(this_obj & (~1));
17127         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17128         Ping_free(this_obj_conv);
17129 }
17130
17131 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17132         LDKPing this_ptr_conv;
17133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17134         this_ptr_conv.is_owned = false;
17135         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
17136         return ret_val;
17137 }
17138
17139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17140         LDKPing this_ptr_conv;
17141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17142         this_ptr_conv.is_owned = false;
17143         Ping_set_ponglen(&this_ptr_conv, val);
17144 }
17145
17146 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17147         LDKPing this_ptr_conv;
17148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17149         this_ptr_conv.is_owned = false;
17150         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
17151         return ret_val;
17152 }
17153
17154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17155         LDKPing this_ptr_conv;
17156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17157         this_ptr_conv.is_owned = false;
17158         Ping_set_byteslen(&this_ptr_conv, val);
17159 }
17160
17161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
17162         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
17163         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17164         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17165         uint64_t ret_ref = (uint64_t)ret_var.inner;
17166         if (ret_var.is_owned) {
17167                 ret_ref |= 1;
17168         }
17169         return ret_ref;
17170 }
17171
17172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17173         LDKPing orig_conv;
17174         orig_conv.inner = (void*)(orig & (~1));
17175         orig_conv.is_owned = false;
17176         LDKPing ret_var = Ping_clone(&orig_conv);
17177         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17178         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17179         uint64_t ret_ref = (uint64_t)ret_var.inner;
17180         if (ret_var.is_owned) {
17181                 ret_ref |= 1;
17182         }
17183         return ret_ref;
17184 }
17185
17186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17187         LDKPong this_obj_conv;
17188         this_obj_conv.inner = (void*)(this_obj & (~1));
17189         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17190         Pong_free(this_obj_conv);
17191 }
17192
17193 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17194         LDKPong this_ptr_conv;
17195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17196         this_ptr_conv.is_owned = false;
17197         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
17198         return ret_val;
17199 }
17200
17201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17202         LDKPong this_ptr_conv;
17203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17204         this_ptr_conv.is_owned = false;
17205         Pong_set_byteslen(&this_ptr_conv, val);
17206 }
17207
17208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
17209         LDKPong ret_var = Pong_new(byteslen_arg);
17210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17212         uint64_t ret_ref = (uint64_t)ret_var.inner;
17213         if (ret_var.is_owned) {
17214                 ret_ref |= 1;
17215         }
17216         return ret_ref;
17217 }
17218
17219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17220         LDKPong orig_conv;
17221         orig_conv.inner = (void*)(orig & (~1));
17222         orig_conv.is_owned = false;
17223         LDKPong ret_var = Pong_clone(&orig_conv);
17224         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17225         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17226         uint64_t ret_ref = (uint64_t)ret_var.inner;
17227         if (ret_var.is_owned) {
17228                 ret_ref |= 1;
17229         }
17230         return ret_ref;
17231 }
17232
17233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17234         LDKOpenChannel this_obj_conv;
17235         this_obj_conv.inner = (void*)(this_obj & (~1));
17236         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17237         OpenChannel_free(this_obj_conv);
17238 }
17239
17240 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17241         LDKOpenChannel this_ptr_conv;
17242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17243         this_ptr_conv.is_owned = false;
17244         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17245         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
17246         return ret_arr;
17247 }
17248
17249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17250         LDKOpenChannel this_ptr_conv;
17251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17252         this_ptr_conv.is_owned = false;
17253         LDKThirtyTwoBytes val_ref;
17254         CHECK((*env)->GetArrayLength(env, val) == 32);
17255         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17256         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
17257 }
17258
17259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17260         LDKOpenChannel this_ptr_conv;
17261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17262         this_ptr_conv.is_owned = false;
17263         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17264         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
17265         return ret_arr;
17266 }
17267
17268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17269         LDKOpenChannel this_ptr_conv;
17270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17271         this_ptr_conv.is_owned = false;
17272         LDKThirtyTwoBytes val_ref;
17273         CHECK((*env)->GetArrayLength(env, val) == 32);
17274         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17275         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17276 }
17277
17278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17279         LDKOpenChannel this_ptr_conv;
17280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17281         this_ptr_conv.is_owned = false;
17282         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
17283         return ret_val;
17284 }
17285
17286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17287         LDKOpenChannel this_ptr_conv;
17288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17289         this_ptr_conv.is_owned = false;
17290         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
17291 }
17292
17293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17294         LDKOpenChannel this_ptr_conv;
17295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17296         this_ptr_conv.is_owned = false;
17297         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
17298         return ret_val;
17299 }
17300
17301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17302         LDKOpenChannel this_ptr_conv;
17303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17304         this_ptr_conv.is_owned = false;
17305         OpenChannel_set_push_msat(&this_ptr_conv, val);
17306 }
17307
17308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17309         LDKOpenChannel this_ptr_conv;
17310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17311         this_ptr_conv.is_owned = false;
17312         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
17313         return ret_val;
17314 }
17315
17316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17317         LDKOpenChannel this_ptr_conv;
17318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17319         this_ptr_conv.is_owned = false;
17320         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17321 }
17322
17323 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) {
17324         LDKOpenChannel this_ptr_conv;
17325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17326         this_ptr_conv.is_owned = false;
17327         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17328         return ret_val;
17329 }
17330
17331 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) {
17332         LDKOpenChannel this_ptr_conv;
17333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17334         this_ptr_conv.is_owned = false;
17335         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17336 }
17337
17338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17339         LDKOpenChannel this_ptr_conv;
17340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17341         this_ptr_conv.is_owned = false;
17342         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17343         return ret_val;
17344 }
17345
17346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17347         LDKOpenChannel this_ptr_conv;
17348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17349         this_ptr_conv.is_owned = false;
17350         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17351 }
17352
17353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17354         LDKOpenChannel this_ptr_conv;
17355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17356         this_ptr_conv.is_owned = false;
17357         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
17358         return ret_val;
17359 }
17360
17361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17362         LDKOpenChannel this_ptr_conv;
17363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17364         this_ptr_conv.is_owned = false;
17365         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17366 }
17367
17368 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17369         LDKOpenChannel this_ptr_conv;
17370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17371         this_ptr_conv.is_owned = false;
17372         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
17373         return ret_val;
17374 }
17375
17376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17377         LDKOpenChannel this_ptr_conv;
17378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17379         this_ptr_conv.is_owned = false;
17380         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
17381 }
17382
17383 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17384         LDKOpenChannel this_ptr_conv;
17385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17386         this_ptr_conv.is_owned = false;
17387         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
17388         return ret_val;
17389 }
17390
17391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17392         LDKOpenChannel this_ptr_conv;
17393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17394         this_ptr_conv.is_owned = false;
17395         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
17396 }
17397
17398 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17399         LDKOpenChannel this_ptr_conv;
17400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17401         this_ptr_conv.is_owned = false;
17402         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
17403         return ret_val;
17404 }
17405
17406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17407         LDKOpenChannel this_ptr_conv;
17408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17409         this_ptr_conv.is_owned = false;
17410         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17411 }
17412
17413 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17414         LDKOpenChannel this_ptr_conv;
17415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17416         this_ptr_conv.is_owned = false;
17417         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17418         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17419         return ret_arr;
17420 }
17421
17422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17423         LDKOpenChannel this_ptr_conv;
17424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17425         this_ptr_conv.is_owned = false;
17426         LDKPublicKey val_ref;
17427         CHECK((*env)->GetArrayLength(env, val) == 33);
17428         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17429         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17430 }
17431
17432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17433         LDKOpenChannel this_ptr_conv;
17434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17435         this_ptr_conv.is_owned = false;
17436         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17438         return ret_arr;
17439 }
17440
17441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17442         LDKOpenChannel this_ptr_conv;
17443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17444         this_ptr_conv.is_owned = false;
17445         LDKPublicKey val_ref;
17446         CHECK((*env)->GetArrayLength(env, val) == 33);
17447         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17448         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17449 }
17450
17451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17452         LDKOpenChannel this_ptr_conv;
17453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17454         this_ptr_conv.is_owned = false;
17455         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17456         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
17457         return ret_arr;
17458 }
17459
17460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17461         LDKOpenChannel this_ptr_conv;
17462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17463         this_ptr_conv.is_owned = false;
17464         LDKPublicKey val_ref;
17465         CHECK((*env)->GetArrayLength(env, val) == 33);
17466         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17467         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
17468 }
17469
17470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17471         LDKOpenChannel this_ptr_conv;
17472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17473         this_ptr_conv.is_owned = false;
17474         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17476         return ret_arr;
17477 }
17478
17479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17480         LDKOpenChannel this_ptr_conv;
17481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17482         this_ptr_conv.is_owned = false;
17483         LDKPublicKey val_ref;
17484         CHECK((*env)->GetArrayLength(env, val) == 33);
17485         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17486         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17487 }
17488
17489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17490         LDKOpenChannel this_ptr_conv;
17491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17492         this_ptr_conv.is_owned = false;
17493         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17494         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17495         return ret_arr;
17496 }
17497
17498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17499         LDKOpenChannel this_ptr_conv;
17500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17501         this_ptr_conv.is_owned = false;
17502         LDKPublicKey val_ref;
17503         CHECK((*env)->GetArrayLength(env, val) == 33);
17504         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17505         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17506 }
17507
17508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17509         LDKOpenChannel this_ptr_conv;
17510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17511         this_ptr_conv.is_owned = false;
17512         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17513         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17514         return ret_arr;
17515 }
17516
17517 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) {
17518         LDKOpenChannel this_ptr_conv;
17519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17520         this_ptr_conv.is_owned = false;
17521         LDKPublicKey val_ref;
17522         CHECK((*env)->GetArrayLength(env, val) == 33);
17523         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17524         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17525 }
17526
17527 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
17528         LDKOpenChannel this_ptr_conv;
17529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17530         this_ptr_conv.is_owned = false;
17531         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
17532         return ret_val;
17533 }
17534
17535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
17536         LDKOpenChannel this_ptr_conv;
17537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17538         this_ptr_conv.is_owned = false;
17539         OpenChannel_set_channel_flags(&this_ptr_conv, val);
17540 }
17541
17542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17543         LDKOpenChannel orig_conv;
17544         orig_conv.inner = (void*)(orig & (~1));
17545         orig_conv.is_owned = false;
17546         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
17547         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17548         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17549         uint64_t ret_ref = (uint64_t)ret_var.inner;
17550         if (ret_var.is_owned) {
17551                 ret_ref |= 1;
17552         }
17553         return ret_ref;
17554 }
17555
17556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17557         LDKAcceptChannel this_obj_conv;
17558         this_obj_conv.inner = (void*)(this_obj & (~1));
17559         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17560         AcceptChannel_free(this_obj_conv);
17561 }
17562
17563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17564         LDKAcceptChannel this_ptr_conv;
17565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17566         this_ptr_conv.is_owned = false;
17567         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
17569         return ret_arr;
17570 }
17571
17572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17573         LDKAcceptChannel this_ptr_conv;
17574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17575         this_ptr_conv.is_owned = false;
17576         LDKThirtyTwoBytes val_ref;
17577         CHECK((*env)->GetArrayLength(env, val) == 32);
17578         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17579         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17580 }
17581
17582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17583         LDKAcceptChannel this_ptr_conv;
17584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17585         this_ptr_conv.is_owned = false;
17586         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
17587         return ret_val;
17588 }
17589
17590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17591         LDKAcceptChannel this_ptr_conv;
17592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17593         this_ptr_conv.is_owned = false;
17594         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17595 }
17596
17597 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) {
17598         LDKAcceptChannel this_ptr_conv;
17599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17600         this_ptr_conv.is_owned = false;
17601         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17602         return ret_val;
17603 }
17604
17605 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) {
17606         LDKAcceptChannel this_ptr_conv;
17607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17608         this_ptr_conv.is_owned = false;
17609         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17610 }
17611
17612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17613         LDKAcceptChannel this_ptr_conv;
17614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17615         this_ptr_conv.is_owned = false;
17616         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17617         return ret_val;
17618 }
17619
17620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17621         LDKAcceptChannel this_ptr_conv;
17622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17623         this_ptr_conv.is_owned = false;
17624         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17625 }
17626
17627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17628         LDKAcceptChannel this_ptr_conv;
17629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17630         this_ptr_conv.is_owned = false;
17631         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
17632         return ret_val;
17633 }
17634
17635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17636         LDKAcceptChannel this_ptr_conv;
17637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17638         this_ptr_conv.is_owned = false;
17639         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17640 }
17641
17642 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
17643         LDKAcceptChannel this_ptr_conv;
17644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17645         this_ptr_conv.is_owned = false;
17646         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
17647         return ret_val;
17648 }
17649
17650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17651         LDKAcceptChannel this_ptr_conv;
17652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17653         this_ptr_conv.is_owned = false;
17654         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
17655 }
17656
17657 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17658         LDKAcceptChannel this_ptr_conv;
17659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17660         this_ptr_conv.is_owned = false;
17661         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
17662         return ret_val;
17663 }
17664
17665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17666         LDKAcceptChannel this_ptr_conv;
17667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17668         this_ptr_conv.is_owned = false;
17669         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
17670 }
17671
17672 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17673         LDKAcceptChannel this_ptr_conv;
17674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17675         this_ptr_conv.is_owned = false;
17676         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
17677         return ret_val;
17678 }
17679
17680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17681         LDKAcceptChannel this_ptr_conv;
17682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17683         this_ptr_conv.is_owned = false;
17684         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17685 }
17686
17687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17688         LDKAcceptChannel this_ptr_conv;
17689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17690         this_ptr_conv.is_owned = false;
17691         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17692         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17693         return ret_arr;
17694 }
17695
17696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17697         LDKAcceptChannel this_ptr_conv;
17698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17699         this_ptr_conv.is_owned = false;
17700         LDKPublicKey val_ref;
17701         CHECK((*env)->GetArrayLength(env, val) == 33);
17702         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17703         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17704 }
17705
17706 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17707         LDKAcceptChannel this_ptr_conv;
17708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17709         this_ptr_conv.is_owned = false;
17710         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17711         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17712         return ret_arr;
17713 }
17714
17715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17716         LDKAcceptChannel this_ptr_conv;
17717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17718         this_ptr_conv.is_owned = false;
17719         LDKPublicKey val_ref;
17720         CHECK((*env)->GetArrayLength(env, val) == 33);
17721         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17722         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17723 }
17724
17725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17726         LDKAcceptChannel this_ptr_conv;
17727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17728         this_ptr_conv.is_owned = false;
17729         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17730         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
17731         return ret_arr;
17732 }
17733
17734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17735         LDKAcceptChannel this_ptr_conv;
17736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17737         this_ptr_conv.is_owned = false;
17738         LDKPublicKey val_ref;
17739         CHECK((*env)->GetArrayLength(env, val) == 33);
17740         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17741         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
17742 }
17743
17744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17745         LDKAcceptChannel this_ptr_conv;
17746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17747         this_ptr_conv.is_owned = false;
17748         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17749         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17750         return ret_arr;
17751 }
17752
17753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17754         LDKAcceptChannel this_ptr_conv;
17755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17756         this_ptr_conv.is_owned = false;
17757         LDKPublicKey val_ref;
17758         CHECK((*env)->GetArrayLength(env, val) == 33);
17759         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17760         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17761 }
17762
17763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17764         LDKAcceptChannel this_ptr_conv;
17765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17766         this_ptr_conv.is_owned = false;
17767         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17769         return ret_arr;
17770 }
17771
17772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17773         LDKAcceptChannel this_ptr_conv;
17774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17775         this_ptr_conv.is_owned = false;
17776         LDKPublicKey val_ref;
17777         CHECK((*env)->GetArrayLength(env, val) == 33);
17778         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17779         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17780 }
17781
17782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17783         LDKAcceptChannel this_ptr_conv;
17784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17785         this_ptr_conv.is_owned = false;
17786         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17787         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17788         return ret_arr;
17789 }
17790
17791 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) {
17792         LDKAcceptChannel this_ptr_conv;
17793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17794         this_ptr_conv.is_owned = false;
17795         LDKPublicKey val_ref;
17796         CHECK((*env)->GetArrayLength(env, val) == 33);
17797         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17798         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17799 }
17800
17801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17802         LDKAcceptChannel orig_conv;
17803         orig_conv.inner = (void*)(orig & (~1));
17804         orig_conv.is_owned = false;
17805         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
17806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17808         uint64_t ret_ref = (uint64_t)ret_var.inner;
17809         if (ret_var.is_owned) {
17810                 ret_ref |= 1;
17811         }
17812         return ret_ref;
17813 }
17814
17815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17816         LDKFundingCreated this_obj_conv;
17817         this_obj_conv.inner = (void*)(this_obj & (~1));
17818         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17819         FundingCreated_free(this_obj_conv);
17820 }
17821
17822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17823         LDKFundingCreated this_ptr_conv;
17824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17825         this_ptr_conv.is_owned = false;
17826         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17827         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
17828         return ret_arr;
17829 }
17830
17831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17832         LDKFundingCreated this_ptr_conv;
17833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17834         this_ptr_conv.is_owned = false;
17835         LDKThirtyTwoBytes val_ref;
17836         CHECK((*env)->GetArrayLength(env, val) == 32);
17837         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17838         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17839 }
17840
17841 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17842         LDKFundingCreated this_ptr_conv;
17843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17844         this_ptr_conv.is_owned = false;
17845         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17846         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
17847         return ret_arr;
17848 }
17849
17850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17851         LDKFundingCreated this_ptr_conv;
17852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17853         this_ptr_conv.is_owned = false;
17854         LDKThirtyTwoBytes val_ref;
17855         CHECK((*env)->GetArrayLength(env, val) == 32);
17856         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17857         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17858 }
17859
17860 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17861         LDKFundingCreated this_ptr_conv;
17862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17863         this_ptr_conv.is_owned = false;
17864         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17865         return ret_val;
17866 }
17867
17868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17869         LDKFundingCreated this_ptr_conv;
17870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17871         this_ptr_conv.is_owned = false;
17872         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17873 }
17874
17875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17876         LDKFundingCreated this_ptr_conv;
17877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17878         this_ptr_conv.is_owned = false;
17879         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17880         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
17881         return ret_arr;
17882 }
17883
17884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17885         LDKFundingCreated this_ptr_conv;
17886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17887         this_ptr_conv.is_owned = false;
17888         LDKSignature val_ref;
17889         CHECK((*env)->GetArrayLength(env, val) == 64);
17890         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17891         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17892 }
17893
17894 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) {
17895         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17896         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
17897         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
17898         LDKThirtyTwoBytes funding_txid_arg_ref;
17899         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
17900         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
17901         LDKSignature signature_arg_ref;
17902         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17903         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17904         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17905         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17906         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17907         uint64_t ret_ref = (uint64_t)ret_var.inner;
17908         if (ret_var.is_owned) {
17909                 ret_ref |= 1;
17910         }
17911         return ret_ref;
17912 }
17913
17914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17915         LDKFundingCreated orig_conv;
17916         orig_conv.inner = (void*)(orig & (~1));
17917         orig_conv.is_owned = false;
17918         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17919         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17920         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17921         uint64_t ret_ref = (uint64_t)ret_var.inner;
17922         if (ret_var.is_owned) {
17923                 ret_ref |= 1;
17924         }
17925         return ret_ref;
17926 }
17927
17928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17929         LDKFundingSigned this_obj_conv;
17930         this_obj_conv.inner = (void*)(this_obj & (~1));
17931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17932         FundingSigned_free(this_obj_conv);
17933 }
17934
17935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17936         LDKFundingSigned this_ptr_conv;
17937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17938         this_ptr_conv.is_owned = false;
17939         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17940         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
17941         return ret_arr;
17942 }
17943
17944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17945         LDKFundingSigned this_ptr_conv;
17946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17947         this_ptr_conv.is_owned = false;
17948         LDKThirtyTwoBytes val_ref;
17949         CHECK((*env)->GetArrayLength(env, val) == 32);
17950         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17951         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17952 }
17953
17954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17955         LDKFundingSigned this_ptr_conv;
17956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17957         this_ptr_conv.is_owned = false;
17958         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
17960         return ret_arr;
17961 }
17962
17963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17964         LDKFundingSigned this_ptr_conv;
17965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17966         this_ptr_conv.is_owned = false;
17967         LDKSignature val_ref;
17968         CHECK((*env)->GetArrayLength(env, val) == 64);
17969         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17970         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17971 }
17972
17973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
17974         LDKThirtyTwoBytes channel_id_arg_ref;
17975         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17976         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17977         LDKSignature signature_arg_ref;
17978         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17979         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17980         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17983         uint64_t ret_ref = (uint64_t)ret_var.inner;
17984         if (ret_var.is_owned) {
17985                 ret_ref |= 1;
17986         }
17987         return ret_ref;
17988 }
17989
17990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17991         LDKFundingSigned orig_conv;
17992         orig_conv.inner = (void*)(orig & (~1));
17993         orig_conv.is_owned = false;
17994         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17997         uint64_t ret_ref = (uint64_t)ret_var.inner;
17998         if (ret_var.is_owned) {
17999                 ret_ref |= 1;
18000         }
18001         return ret_ref;
18002 }
18003
18004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18005         LDKFundingLocked this_obj_conv;
18006         this_obj_conv.inner = (void*)(this_obj & (~1));
18007         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18008         FundingLocked_free(this_obj_conv);
18009 }
18010
18011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18012         LDKFundingLocked this_ptr_conv;
18013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18014         this_ptr_conv.is_owned = false;
18015         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18016         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
18017         return ret_arr;
18018 }
18019
18020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18021         LDKFundingLocked this_ptr_conv;
18022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18023         this_ptr_conv.is_owned = false;
18024         LDKThirtyTwoBytes val_ref;
18025         CHECK((*env)->GetArrayLength(env, val) == 32);
18026         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18027         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
18028 }
18029
18030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18031         LDKFundingLocked this_ptr_conv;
18032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18033         this_ptr_conv.is_owned = false;
18034         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18035         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18036         return ret_arr;
18037 }
18038
18039 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) {
18040         LDKFundingLocked this_ptr_conv;
18041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18042         this_ptr_conv.is_owned = false;
18043         LDKPublicKey val_ref;
18044         CHECK((*env)->GetArrayLength(env, val) == 33);
18045         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18046         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18047 }
18048
18049 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) {
18050         LDKThirtyTwoBytes channel_id_arg_ref;
18051         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18052         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18053         LDKPublicKey next_per_commitment_point_arg_ref;
18054         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18055         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18056         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
18057         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18058         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18059         uint64_t ret_ref = (uint64_t)ret_var.inner;
18060         if (ret_var.is_owned) {
18061                 ret_ref |= 1;
18062         }
18063         return ret_ref;
18064 }
18065
18066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18067         LDKFundingLocked orig_conv;
18068         orig_conv.inner = (void*)(orig & (~1));
18069         orig_conv.is_owned = false;
18070         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
18071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18073         uint64_t ret_ref = (uint64_t)ret_var.inner;
18074         if (ret_var.is_owned) {
18075                 ret_ref |= 1;
18076         }
18077         return ret_ref;
18078 }
18079
18080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18081         LDKShutdown this_obj_conv;
18082         this_obj_conv.inner = (void*)(this_obj & (~1));
18083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18084         Shutdown_free(this_obj_conv);
18085 }
18086
18087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18088         LDKShutdown this_ptr_conv;
18089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18090         this_ptr_conv.is_owned = false;
18091         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18092         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
18093         return ret_arr;
18094 }
18095
18096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18097         LDKShutdown this_ptr_conv;
18098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18099         this_ptr_conv.is_owned = false;
18100         LDKThirtyTwoBytes val_ref;
18101         CHECK((*env)->GetArrayLength(env, val) == 32);
18102         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18103         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
18104 }
18105
18106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18107         LDKShutdown this_ptr_conv;
18108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18109         this_ptr_conv.is_owned = false;
18110         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
18111         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18112         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18113         return ret_arr;
18114 }
18115
18116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18117         LDKShutdown this_ptr_conv;
18118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18119         this_ptr_conv.is_owned = false;
18120         LDKCVec_u8Z val_ref;
18121         val_ref.datalen = (*env)->GetArrayLength(env, val);
18122         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18123         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18124         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
18125 }
18126
18127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
18128         LDKThirtyTwoBytes channel_id_arg_ref;
18129         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18130         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18131         LDKCVec_u8Z scriptpubkey_arg_ref;
18132         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
18133         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18134         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
18135         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
18136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18138         uint64_t ret_ref = (uint64_t)ret_var.inner;
18139         if (ret_var.is_owned) {
18140                 ret_ref |= 1;
18141         }
18142         return ret_ref;
18143 }
18144
18145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18146         LDKShutdown orig_conv;
18147         orig_conv.inner = (void*)(orig & (~1));
18148         orig_conv.is_owned = false;
18149         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
18150         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18151         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18152         uint64_t ret_ref = (uint64_t)ret_var.inner;
18153         if (ret_var.is_owned) {
18154                 ret_ref |= 1;
18155         }
18156         return ret_ref;
18157 }
18158
18159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18160         LDKClosingSigned this_obj_conv;
18161         this_obj_conv.inner = (void*)(this_obj & (~1));
18162         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18163         ClosingSigned_free(this_obj_conv);
18164 }
18165
18166 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18167         LDKClosingSigned this_ptr_conv;
18168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18169         this_ptr_conv.is_owned = false;
18170         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18171         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
18172         return ret_arr;
18173 }
18174
18175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18176         LDKClosingSigned this_ptr_conv;
18177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18178         this_ptr_conv.is_owned = false;
18179         LDKThirtyTwoBytes val_ref;
18180         CHECK((*env)->GetArrayLength(env, val) == 32);
18181         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18182         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
18183 }
18184
18185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18186         LDKClosingSigned this_ptr_conv;
18187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18188         this_ptr_conv.is_owned = false;
18189         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
18190         return ret_val;
18191 }
18192
18193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18194         LDKClosingSigned this_ptr_conv;
18195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18196         this_ptr_conv.is_owned = false;
18197         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
18198 }
18199
18200 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18201         LDKClosingSigned this_ptr_conv;
18202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18203         this_ptr_conv.is_owned = false;
18204         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18205         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
18206         return ret_arr;
18207 }
18208
18209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18210         LDKClosingSigned this_ptr_conv;
18211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18212         this_ptr_conv.is_owned = false;
18213         LDKSignature val_ref;
18214         CHECK((*env)->GetArrayLength(env, val) == 64);
18215         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18216         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
18217 }
18218
18219 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) {
18220         LDKThirtyTwoBytes channel_id_arg_ref;
18221         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18222         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18223         LDKSignature signature_arg_ref;
18224         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18225         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18226         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
18227         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18228         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18229         uint64_t ret_ref = (uint64_t)ret_var.inner;
18230         if (ret_var.is_owned) {
18231                 ret_ref |= 1;
18232         }
18233         return ret_ref;
18234 }
18235
18236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18237         LDKClosingSigned orig_conv;
18238         orig_conv.inner = (void*)(orig & (~1));
18239         orig_conv.is_owned = false;
18240         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
18241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18243         uint64_t ret_ref = (uint64_t)ret_var.inner;
18244         if (ret_var.is_owned) {
18245                 ret_ref |= 1;
18246         }
18247         return ret_ref;
18248 }
18249
18250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18251         LDKUpdateAddHTLC this_obj_conv;
18252         this_obj_conv.inner = (void*)(this_obj & (~1));
18253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18254         UpdateAddHTLC_free(this_obj_conv);
18255 }
18256
18257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18258         LDKUpdateAddHTLC this_ptr_conv;
18259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18260         this_ptr_conv.is_owned = false;
18261         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
18263         return ret_arr;
18264 }
18265
18266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18267         LDKUpdateAddHTLC this_ptr_conv;
18268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18269         this_ptr_conv.is_owned = false;
18270         LDKThirtyTwoBytes val_ref;
18271         CHECK((*env)->GetArrayLength(env, val) == 32);
18272         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18273         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
18274 }
18275
18276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18277         LDKUpdateAddHTLC this_ptr_conv;
18278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18279         this_ptr_conv.is_owned = false;
18280         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
18281         return ret_val;
18282 }
18283
18284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18285         LDKUpdateAddHTLC this_ptr_conv;
18286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18287         this_ptr_conv.is_owned = false;
18288         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
18289 }
18290
18291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18292         LDKUpdateAddHTLC this_ptr_conv;
18293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18294         this_ptr_conv.is_owned = false;
18295         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
18296         return ret_val;
18297 }
18298
18299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18300         LDKUpdateAddHTLC this_ptr_conv;
18301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18302         this_ptr_conv.is_owned = false;
18303         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
18304 }
18305
18306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18307         LDKUpdateAddHTLC this_ptr_conv;
18308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18309         this_ptr_conv.is_owned = false;
18310         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18311         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
18312         return ret_arr;
18313 }
18314
18315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18316         LDKUpdateAddHTLC this_ptr_conv;
18317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18318         this_ptr_conv.is_owned = false;
18319         LDKThirtyTwoBytes val_ref;
18320         CHECK((*env)->GetArrayLength(env, val) == 32);
18321         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18322         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
18323 }
18324
18325 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18326         LDKUpdateAddHTLC this_ptr_conv;
18327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18328         this_ptr_conv.is_owned = false;
18329         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
18330         return ret_val;
18331 }
18332
18333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18334         LDKUpdateAddHTLC this_ptr_conv;
18335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18336         this_ptr_conv.is_owned = false;
18337         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
18338 }
18339
18340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18341         LDKUpdateAddHTLC orig_conv;
18342         orig_conv.inner = (void*)(orig & (~1));
18343         orig_conv.is_owned = false;
18344         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
18345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18347         uint64_t ret_ref = (uint64_t)ret_var.inner;
18348         if (ret_var.is_owned) {
18349                 ret_ref |= 1;
18350         }
18351         return ret_ref;
18352 }
18353
18354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18355         LDKUpdateFulfillHTLC this_obj_conv;
18356         this_obj_conv.inner = (void*)(this_obj & (~1));
18357         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18358         UpdateFulfillHTLC_free(this_obj_conv);
18359 }
18360
18361 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18362         LDKUpdateFulfillHTLC this_ptr_conv;
18363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18364         this_ptr_conv.is_owned = false;
18365         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18366         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
18367         return ret_arr;
18368 }
18369
18370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18371         LDKUpdateFulfillHTLC this_ptr_conv;
18372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18373         this_ptr_conv.is_owned = false;
18374         LDKThirtyTwoBytes val_ref;
18375         CHECK((*env)->GetArrayLength(env, val) == 32);
18376         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18377         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
18378 }
18379
18380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18381         LDKUpdateFulfillHTLC this_ptr_conv;
18382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18383         this_ptr_conv.is_owned = false;
18384         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
18385         return ret_val;
18386 }
18387
18388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18389         LDKUpdateFulfillHTLC this_ptr_conv;
18390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18391         this_ptr_conv.is_owned = false;
18392         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
18393 }
18394
18395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
18396         LDKUpdateFulfillHTLC this_ptr_conv;
18397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18398         this_ptr_conv.is_owned = false;
18399         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
18401         return ret_arr;
18402 }
18403
18404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18405         LDKUpdateFulfillHTLC this_ptr_conv;
18406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18407         this_ptr_conv.is_owned = false;
18408         LDKThirtyTwoBytes val_ref;
18409         CHECK((*env)->GetArrayLength(env, val) == 32);
18410         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18411         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
18412 }
18413
18414 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) {
18415         LDKThirtyTwoBytes channel_id_arg_ref;
18416         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18417         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18418         LDKThirtyTwoBytes payment_preimage_arg_ref;
18419         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
18420         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
18421         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
18422         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18423         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18424         uint64_t ret_ref = (uint64_t)ret_var.inner;
18425         if (ret_var.is_owned) {
18426                 ret_ref |= 1;
18427         }
18428         return ret_ref;
18429 }
18430
18431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18432         LDKUpdateFulfillHTLC orig_conv;
18433         orig_conv.inner = (void*)(orig & (~1));
18434         orig_conv.is_owned = false;
18435         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
18436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18438         uint64_t ret_ref = (uint64_t)ret_var.inner;
18439         if (ret_var.is_owned) {
18440                 ret_ref |= 1;
18441         }
18442         return ret_ref;
18443 }
18444
18445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18446         LDKUpdateFailHTLC this_obj_conv;
18447         this_obj_conv.inner = (void*)(this_obj & (~1));
18448         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18449         UpdateFailHTLC_free(this_obj_conv);
18450 }
18451
18452 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18453         LDKUpdateFailHTLC this_ptr_conv;
18454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18455         this_ptr_conv.is_owned = false;
18456         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18457         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
18458         return ret_arr;
18459 }
18460
18461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18462         LDKUpdateFailHTLC this_ptr_conv;
18463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18464         this_ptr_conv.is_owned = false;
18465         LDKThirtyTwoBytes val_ref;
18466         CHECK((*env)->GetArrayLength(env, val) == 32);
18467         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18468         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
18469 }
18470
18471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18472         LDKUpdateFailHTLC this_ptr_conv;
18473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18474         this_ptr_conv.is_owned = false;
18475         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
18476         return ret_val;
18477 }
18478
18479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18480         LDKUpdateFailHTLC this_ptr_conv;
18481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18482         this_ptr_conv.is_owned = false;
18483         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
18484 }
18485
18486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18487         LDKUpdateFailHTLC orig_conv;
18488         orig_conv.inner = (void*)(orig & (~1));
18489         orig_conv.is_owned = false;
18490         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
18491         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18492         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18493         uint64_t ret_ref = (uint64_t)ret_var.inner;
18494         if (ret_var.is_owned) {
18495                 ret_ref |= 1;
18496         }
18497         return ret_ref;
18498 }
18499
18500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18501         LDKUpdateFailMalformedHTLC this_obj_conv;
18502         this_obj_conv.inner = (void*)(this_obj & (~1));
18503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18504         UpdateFailMalformedHTLC_free(this_obj_conv);
18505 }
18506
18507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18508         LDKUpdateFailMalformedHTLC this_ptr_conv;
18509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18510         this_ptr_conv.is_owned = false;
18511         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18512         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
18513         return ret_arr;
18514 }
18515
18516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18517         LDKUpdateFailMalformedHTLC this_ptr_conv;
18518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18519         this_ptr_conv.is_owned = false;
18520         LDKThirtyTwoBytes val_ref;
18521         CHECK((*env)->GetArrayLength(env, val) == 32);
18522         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18523         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
18524 }
18525
18526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18527         LDKUpdateFailMalformedHTLC this_ptr_conv;
18528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18529         this_ptr_conv.is_owned = false;
18530         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
18531         return ret_val;
18532 }
18533
18534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18535         LDKUpdateFailMalformedHTLC this_ptr_conv;
18536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18537         this_ptr_conv.is_owned = false;
18538         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
18539 }
18540
18541 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
18542         LDKUpdateFailMalformedHTLC this_ptr_conv;
18543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18544         this_ptr_conv.is_owned = false;
18545         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
18546         return ret_val;
18547 }
18548
18549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18550         LDKUpdateFailMalformedHTLC this_ptr_conv;
18551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18552         this_ptr_conv.is_owned = false;
18553         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
18554 }
18555
18556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18557         LDKUpdateFailMalformedHTLC orig_conv;
18558         orig_conv.inner = (void*)(orig & (~1));
18559         orig_conv.is_owned = false;
18560         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
18561         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18562         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18563         uint64_t ret_ref = (uint64_t)ret_var.inner;
18564         if (ret_var.is_owned) {
18565                 ret_ref |= 1;
18566         }
18567         return ret_ref;
18568 }
18569
18570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18571         LDKCommitmentSigned this_obj_conv;
18572         this_obj_conv.inner = (void*)(this_obj & (~1));
18573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18574         CommitmentSigned_free(this_obj_conv);
18575 }
18576
18577 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18578         LDKCommitmentSigned this_ptr_conv;
18579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18580         this_ptr_conv.is_owned = false;
18581         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18582         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
18583         return ret_arr;
18584 }
18585
18586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18587         LDKCommitmentSigned this_ptr_conv;
18588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18589         this_ptr_conv.is_owned = false;
18590         LDKThirtyTwoBytes val_ref;
18591         CHECK((*env)->GetArrayLength(env, val) == 32);
18592         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18593         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
18594 }
18595
18596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18597         LDKCommitmentSigned this_ptr_conv;
18598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18599         this_ptr_conv.is_owned = false;
18600         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
18602         return ret_arr;
18603 }
18604
18605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18606         LDKCommitmentSigned this_ptr_conv;
18607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18608         this_ptr_conv.is_owned = false;
18609         LDKSignature val_ref;
18610         CHECK((*env)->GetArrayLength(env, val) == 64);
18611         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18612         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
18613 }
18614
18615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18616         LDKCommitmentSigned this_ptr_conv;
18617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18618         this_ptr_conv.is_owned = false;
18619         LDKCVec_SignatureZ val_constr;
18620         val_constr.datalen = (*env)->GetArrayLength(env, val);
18621         if (val_constr.datalen > 0)
18622                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18623         else
18624                 val_constr.data = NULL;
18625         for (size_t i = 0; i < val_constr.datalen; i++) {
18626                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18627                 LDKSignature val_conv_8_ref;
18628                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18629                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18630                 val_constr.data[i] = val_conv_8_ref;
18631         }
18632         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
18633 }
18634
18635 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) {
18636         LDKThirtyTwoBytes channel_id_arg_ref;
18637         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18638         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18639         LDKSignature signature_arg_ref;
18640         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18641         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18642         LDKCVec_SignatureZ htlc_signatures_arg_constr;
18643         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
18644         if (htlc_signatures_arg_constr.datalen > 0)
18645                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18646         else
18647                 htlc_signatures_arg_constr.data = NULL;
18648         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
18649                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
18650                 LDKSignature htlc_signatures_arg_conv_8_ref;
18651                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
18652                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
18653                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
18654         }
18655         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
18656         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18657         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18658         uint64_t ret_ref = (uint64_t)ret_var.inner;
18659         if (ret_var.is_owned) {
18660                 ret_ref |= 1;
18661         }
18662         return ret_ref;
18663 }
18664
18665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18666         LDKCommitmentSigned orig_conv;
18667         orig_conv.inner = (void*)(orig & (~1));
18668         orig_conv.is_owned = false;
18669         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
18670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18672         uint64_t ret_ref = (uint64_t)ret_var.inner;
18673         if (ret_var.is_owned) {
18674                 ret_ref |= 1;
18675         }
18676         return ret_ref;
18677 }
18678
18679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18680         LDKRevokeAndACK this_obj_conv;
18681         this_obj_conv.inner = (void*)(this_obj & (~1));
18682         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18683         RevokeAndACK_free(this_obj_conv);
18684 }
18685
18686 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18687         LDKRevokeAndACK this_ptr_conv;
18688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18689         this_ptr_conv.is_owned = false;
18690         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18691         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
18692         return ret_arr;
18693 }
18694
18695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18696         LDKRevokeAndACK this_ptr_conv;
18697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18698         this_ptr_conv.is_owned = false;
18699         LDKThirtyTwoBytes val_ref;
18700         CHECK((*env)->GetArrayLength(env, val) == 32);
18701         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18702         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
18703 }
18704
18705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18706         LDKRevokeAndACK this_ptr_conv;
18707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18708         this_ptr_conv.is_owned = false;
18709         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18710         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
18711         return ret_arr;
18712 }
18713
18714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18715         LDKRevokeAndACK this_ptr_conv;
18716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18717         this_ptr_conv.is_owned = false;
18718         LDKThirtyTwoBytes val_ref;
18719         CHECK((*env)->GetArrayLength(env, val) == 32);
18720         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18721         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
18722 }
18723
18724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18725         LDKRevokeAndACK this_ptr_conv;
18726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18727         this_ptr_conv.is_owned = false;
18728         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18729         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18730         return ret_arr;
18731 }
18732
18733 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) {
18734         LDKRevokeAndACK this_ptr_conv;
18735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18736         this_ptr_conv.is_owned = false;
18737         LDKPublicKey val_ref;
18738         CHECK((*env)->GetArrayLength(env, val) == 33);
18739         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18740         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18741 }
18742
18743 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) {
18744         LDKThirtyTwoBytes channel_id_arg_ref;
18745         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18746         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18747         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
18748         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
18749         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
18750         LDKPublicKey next_per_commitment_point_arg_ref;
18751         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18752         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18753         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
18754         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18755         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18756         uint64_t ret_ref = (uint64_t)ret_var.inner;
18757         if (ret_var.is_owned) {
18758                 ret_ref |= 1;
18759         }
18760         return ret_ref;
18761 }
18762
18763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18764         LDKRevokeAndACK orig_conv;
18765         orig_conv.inner = (void*)(orig & (~1));
18766         orig_conv.is_owned = false;
18767         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
18768         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18769         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18770         uint64_t ret_ref = (uint64_t)ret_var.inner;
18771         if (ret_var.is_owned) {
18772                 ret_ref |= 1;
18773         }
18774         return ret_ref;
18775 }
18776
18777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18778         LDKUpdateFee this_obj_conv;
18779         this_obj_conv.inner = (void*)(this_obj & (~1));
18780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18781         UpdateFee_free(this_obj_conv);
18782 }
18783
18784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18785         LDKUpdateFee this_ptr_conv;
18786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18787         this_ptr_conv.is_owned = false;
18788         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18789         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
18790         return ret_arr;
18791 }
18792
18793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18794         LDKUpdateFee this_ptr_conv;
18795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18796         this_ptr_conv.is_owned = false;
18797         LDKThirtyTwoBytes val_ref;
18798         CHECK((*env)->GetArrayLength(env, val) == 32);
18799         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18800         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
18801 }
18802
18803 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
18804         LDKUpdateFee this_ptr_conv;
18805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18806         this_ptr_conv.is_owned = false;
18807         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
18808         return ret_val;
18809 }
18810
18811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18812         LDKUpdateFee this_ptr_conv;
18813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18814         this_ptr_conv.is_owned = false;
18815         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18816 }
18817
18818 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) {
18819         LDKThirtyTwoBytes channel_id_arg_ref;
18820         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18821         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18822         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18823         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18824         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18825         uint64_t ret_ref = (uint64_t)ret_var.inner;
18826         if (ret_var.is_owned) {
18827                 ret_ref |= 1;
18828         }
18829         return ret_ref;
18830 }
18831
18832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18833         LDKUpdateFee orig_conv;
18834         orig_conv.inner = (void*)(orig & (~1));
18835         orig_conv.is_owned = false;
18836         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18837         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18838         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18839         uint64_t ret_ref = (uint64_t)ret_var.inner;
18840         if (ret_var.is_owned) {
18841                 ret_ref |= 1;
18842         }
18843         return ret_ref;
18844 }
18845
18846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18847         LDKDataLossProtect this_obj_conv;
18848         this_obj_conv.inner = (void*)(this_obj & (~1));
18849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18850         DataLossProtect_free(this_obj_conv);
18851 }
18852
18853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18854         LDKDataLossProtect this_ptr_conv;
18855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18856         this_ptr_conv.is_owned = false;
18857         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18858         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
18859         return ret_arr;
18860 }
18861
18862 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) {
18863         LDKDataLossProtect this_ptr_conv;
18864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18865         this_ptr_conv.is_owned = false;
18866         LDKThirtyTwoBytes val_ref;
18867         CHECK((*env)->GetArrayLength(env, val) == 32);
18868         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18869         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18870 }
18871
18872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18873         LDKDataLossProtect this_ptr_conv;
18874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18875         this_ptr_conv.is_owned = false;
18876         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18877         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
18878         return ret_arr;
18879 }
18880
18881 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) {
18882         LDKDataLossProtect this_ptr_conv;
18883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18884         this_ptr_conv.is_owned = false;
18885         LDKPublicKey val_ref;
18886         CHECK((*env)->GetArrayLength(env, val) == 33);
18887         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18888         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18889 }
18890
18891 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) {
18892         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18893         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
18894         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
18895         LDKPublicKey my_current_per_commitment_point_arg_ref;
18896         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
18897         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
18898         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18901         uint64_t ret_ref = (uint64_t)ret_var.inner;
18902         if (ret_var.is_owned) {
18903                 ret_ref |= 1;
18904         }
18905         return ret_ref;
18906 }
18907
18908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18909         LDKDataLossProtect orig_conv;
18910         orig_conv.inner = (void*)(orig & (~1));
18911         orig_conv.is_owned = false;
18912         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18913         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18914         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18915         uint64_t ret_ref = (uint64_t)ret_var.inner;
18916         if (ret_var.is_owned) {
18917                 ret_ref |= 1;
18918         }
18919         return ret_ref;
18920 }
18921
18922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18923         LDKChannelReestablish this_obj_conv;
18924         this_obj_conv.inner = (void*)(this_obj & (~1));
18925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18926         ChannelReestablish_free(this_obj_conv);
18927 }
18928
18929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18930         LDKChannelReestablish this_ptr_conv;
18931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18932         this_ptr_conv.is_owned = false;
18933         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18934         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
18935         return ret_arr;
18936 }
18937
18938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18939         LDKChannelReestablish this_ptr_conv;
18940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18941         this_ptr_conv.is_owned = false;
18942         LDKThirtyTwoBytes val_ref;
18943         CHECK((*env)->GetArrayLength(env, val) == 32);
18944         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18945         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18946 }
18947
18948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18949         LDKChannelReestablish this_ptr_conv;
18950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18951         this_ptr_conv.is_owned = false;
18952         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18953         return ret_val;
18954 }
18955
18956 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) {
18957         LDKChannelReestablish this_ptr_conv;
18958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18959         this_ptr_conv.is_owned = false;
18960         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18961 }
18962
18963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18964         LDKChannelReestablish this_ptr_conv;
18965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18966         this_ptr_conv.is_owned = false;
18967         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18968         return ret_val;
18969 }
18970
18971 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) {
18972         LDKChannelReestablish this_ptr_conv;
18973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18974         this_ptr_conv.is_owned = false;
18975         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18976 }
18977
18978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18979         LDKChannelReestablish orig_conv;
18980         orig_conv.inner = (void*)(orig & (~1));
18981         orig_conv.is_owned = false;
18982         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18985         uint64_t ret_ref = (uint64_t)ret_var.inner;
18986         if (ret_var.is_owned) {
18987                 ret_ref |= 1;
18988         }
18989         return ret_ref;
18990 }
18991
18992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18993         LDKAnnouncementSignatures this_obj_conv;
18994         this_obj_conv.inner = (void*)(this_obj & (~1));
18995         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18996         AnnouncementSignatures_free(this_obj_conv);
18997 }
18998
18999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19000         LDKAnnouncementSignatures this_ptr_conv;
19001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19002         this_ptr_conv.is_owned = false;
19003         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19004         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
19005         return ret_arr;
19006 }
19007
19008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19009         LDKAnnouncementSignatures this_ptr_conv;
19010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19011         this_ptr_conv.is_owned = false;
19012         LDKThirtyTwoBytes val_ref;
19013         CHECK((*env)->GetArrayLength(env, val) == 32);
19014         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19015         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
19016 }
19017
19018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19019         LDKAnnouncementSignatures this_ptr_conv;
19020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19021         this_ptr_conv.is_owned = false;
19022         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
19023         return ret_val;
19024 }
19025
19026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19027         LDKAnnouncementSignatures this_ptr_conv;
19028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19029         this_ptr_conv.is_owned = false;
19030         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
19031 }
19032
19033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19034         LDKAnnouncementSignatures this_ptr_conv;
19035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19036         this_ptr_conv.is_owned = false;
19037         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19038         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
19039         return ret_arr;
19040 }
19041
19042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19043         LDKAnnouncementSignatures this_ptr_conv;
19044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19045         this_ptr_conv.is_owned = false;
19046         LDKSignature val_ref;
19047         CHECK((*env)->GetArrayLength(env, val) == 64);
19048         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19049         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
19050 }
19051
19052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19053         LDKAnnouncementSignatures this_ptr_conv;
19054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19055         this_ptr_conv.is_owned = false;
19056         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19057         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
19058         return ret_arr;
19059 }
19060
19061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19062         LDKAnnouncementSignatures this_ptr_conv;
19063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19064         this_ptr_conv.is_owned = false;
19065         LDKSignature val_ref;
19066         CHECK((*env)->GetArrayLength(env, val) == 64);
19067         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19068         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
19069 }
19070
19071 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) {
19072         LDKThirtyTwoBytes channel_id_arg_ref;
19073         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19074         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19075         LDKSignature node_signature_arg_ref;
19076         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
19077         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
19078         LDKSignature bitcoin_signature_arg_ref;
19079         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
19080         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
19081         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
19082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19084         uint64_t ret_ref = (uint64_t)ret_var.inner;
19085         if (ret_var.is_owned) {
19086                 ret_ref |= 1;
19087         }
19088         return ret_ref;
19089 }
19090
19091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19092         LDKAnnouncementSignatures orig_conv;
19093         orig_conv.inner = (void*)(orig & (~1));
19094         orig_conv.is_owned = false;
19095         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
19096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19098         uint64_t ret_ref = (uint64_t)ret_var.inner;
19099         if (ret_var.is_owned) {
19100                 ret_ref |= 1;
19101         }
19102         return ret_ref;
19103 }
19104
19105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19106         if ((this_ptr & 1) != 0) return;
19107         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
19108         FREE((void*)this_ptr);
19109         NetAddress_free(this_ptr_conv);
19110 }
19111
19112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19113         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
19114         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19115         *ret_copy = NetAddress_clone(orig_conv);
19116         uint64_t ret_ref = (uint64_t)ret_copy;
19117         return ret_ref;
19118 }
19119
19120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
19121         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
19122         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
19123         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19124         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19125         CVec_u8Z_free(ret_var);
19126         return ret_arr;
19127 }
19128
19129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19130         LDKu8slice ser_ref;
19131         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19132         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19133         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
19134         *ret_conv = Result_read(ser_ref);
19135         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19136         return (uint64_t)ret_conv;
19137 }
19138
19139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19140         LDKu8slice ser_ref;
19141         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19142         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19143         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19144         *ret_conv = NetAddress_read(ser_ref);
19145         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19146         return (uint64_t)ret_conv;
19147 }
19148
19149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19150         LDKUnsignedNodeAnnouncement this_obj_conv;
19151         this_obj_conv.inner = (void*)(this_obj & (~1));
19152         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19153         UnsignedNodeAnnouncement_free(this_obj_conv);
19154 }
19155
19156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19157         LDKUnsignedNodeAnnouncement this_ptr_conv;
19158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19159         this_ptr_conv.is_owned = false;
19160         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
19161         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19162         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19163         uint64_t ret_ref = (uint64_t)ret_var.inner;
19164         if (ret_var.is_owned) {
19165                 ret_ref |= 1;
19166         }
19167         return ret_ref;
19168 }
19169
19170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19171         LDKUnsignedNodeAnnouncement this_ptr_conv;
19172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19173         this_ptr_conv.is_owned = false;
19174         LDKNodeFeatures val_conv;
19175         val_conv.inner = (void*)(val & (~1));
19176         val_conv.is_owned = (val & 1) || (val == 0);
19177         val_conv = NodeFeatures_clone(&val_conv);
19178         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
19179 }
19180
19181 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19182         LDKUnsignedNodeAnnouncement this_ptr_conv;
19183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19184         this_ptr_conv.is_owned = false;
19185         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
19186         return ret_val;
19187 }
19188
19189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19190         LDKUnsignedNodeAnnouncement this_ptr_conv;
19191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19192         this_ptr_conv.is_owned = false;
19193         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
19194 }
19195
19196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19197         LDKUnsignedNodeAnnouncement this_ptr_conv;
19198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19199         this_ptr_conv.is_owned = false;
19200         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
19202         return ret_arr;
19203 }
19204
19205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19206         LDKUnsignedNodeAnnouncement this_ptr_conv;
19207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19208         this_ptr_conv.is_owned = false;
19209         LDKPublicKey val_ref;
19210         CHECK((*env)->GetArrayLength(env, val) == 33);
19211         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19212         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
19213 }
19214
19215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
19216         LDKUnsignedNodeAnnouncement this_ptr_conv;
19217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19218         this_ptr_conv.is_owned = false;
19219         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
19220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
19221         return ret_arr;
19222 }
19223
19224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19225         LDKUnsignedNodeAnnouncement this_ptr_conv;
19226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19227         this_ptr_conv.is_owned = false;
19228         LDKThreeBytes val_ref;
19229         CHECK((*env)->GetArrayLength(env, val) == 3);
19230         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
19231         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
19232 }
19233
19234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
19235         LDKUnsignedNodeAnnouncement this_ptr_conv;
19236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19237         this_ptr_conv.is_owned = false;
19238         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
19240         return ret_arr;
19241 }
19242
19243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19244         LDKUnsignedNodeAnnouncement this_ptr_conv;
19245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19246         this_ptr_conv.is_owned = false;
19247         LDKThirtyTwoBytes val_ref;
19248         CHECK((*env)->GetArrayLength(env, val) == 32);
19249         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19250         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
19251 }
19252
19253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19254         LDKUnsignedNodeAnnouncement this_ptr_conv;
19255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19256         this_ptr_conv.is_owned = false;
19257         LDKCVec_NetAddressZ val_constr;
19258         val_constr.datalen = (*env)->GetArrayLength(env, val);
19259         if (val_constr.datalen > 0)
19260                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19261         else
19262                 val_constr.data = NULL;
19263         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19264         for (size_t m = 0; m < val_constr.datalen; m++) {
19265                 int64_t val_conv_12 = val_vals[m];
19266                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19267                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19268                 val_constr.data[m] = val_conv_12_conv;
19269         }
19270         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19271         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
19272 }
19273
19274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19275         LDKUnsignedNodeAnnouncement orig_conv;
19276         orig_conv.inner = (void*)(orig & (~1));
19277         orig_conv.is_owned = false;
19278         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
19279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19281         uint64_t ret_ref = (uint64_t)ret_var.inner;
19282         if (ret_var.is_owned) {
19283                 ret_ref |= 1;
19284         }
19285         return ret_ref;
19286 }
19287
19288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19289         LDKNodeAnnouncement this_obj_conv;
19290         this_obj_conv.inner = (void*)(this_obj & (~1));
19291         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19292         NodeAnnouncement_free(this_obj_conv);
19293 }
19294
19295 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19296         LDKNodeAnnouncement this_ptr_conv;
19297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19298         this_ptr_conv.is_owned = false;
19299         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19300         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
19301         return ret_arr;
19302 }
19303
19304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19305         LDKNodeAnnouncement this_ptr_conv;
19306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19307         this_ptr_conv.is_owned = false;
19308         LDKSignature val_ref;
19309         CHECK((*env)->GetArrayLength(env, val) == 64);
19310         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19311         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
19312 }
19313
19314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19315         LDKNodeAnnouncement this_ptr_conv;
19316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19317         this_ptr_conv.is_owned = false;
19318         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
19319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19321         uint64_t ret_ref = (uint64_t)ret_var.inner;
19322         if (ret_var.is_owned) {
19323                 ret_ref |= 1;
19324         }
19325         return ret_ref;
19326 }
19327
19328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19329         LDKNodeAnnouncement this_ptr_conv;
19330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19331         this_ptr_conv.is_owned = false;
19332         LDKUnsignedNodeAnnouncement val_conv;
19333         val_conv.inner = (void*)(val & (~1));
19334         val_conv.is_owned = (val & 1) || (val == 0);
19335         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
19336         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
19337 }
19338
19339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19340         LDKSignature signature_arg_ref;
19341         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19342         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19343         LDKUnsignedNodeAnnouncement contents_arg_conv;
19344         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19345         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19346         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
19347         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
19348         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19349         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19350         uint64_t ret_ref = (uint64_t)ret_var.inner;
19351         if (ret_var.is_owned) {
19352                 ret_ref |= 1;
19353         }
19354         return ret_ref;
19355 }
19356
19357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19358         LDKNodeAnnouncement orig_conv;
19359         orig_conv.inner = (void*)(orig & (~1));
19360         orig_conv.is_owned = false;
19361         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
19362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19364         uint64_t ret_ref = (uint64_t)ret_var.inner;
19365         if (ret_var.is_owned) {
19366                 ret_ref |= 1;
19367         }
19368         return ret_ref;
19369 }
19370
19371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19372         LDKUnsignedChannelAnnouncement this_obj_conv;
19373         this_obj_conv.inner = (void*)(this_obj & (~1));
19374         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19375         UnsignedChannelAnnouncement_free(this_obj_conv);
19376 }
19377
19378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19379         LDKUnsignedChannelAnnouncement this_ptr_conv;
19380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19381         this_ptr_conv.is_owned = false;
19382         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
19383         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19384         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19385         uint64_t ret_ref = (uint64_t)ret_var.inner;
19386         if (ret_var.is_owned) {
19387                 ret_ref |= 1;
19388         }
19389         return ret_ref;
19390 }
19391
19392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19393         LDKUnsignedChannelAnnouncement this_ptr_conv;
19394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19395         this_ptr_conv.is_owned = false;
19396         LDKChannelFeatures val_conv;
19397         val_conv.inner = (void*)(val & (~1));
19398         val_conv.is_owned = (val & 1) || (val == 0);
19399         val_conv = ChannelFeatures_clone(&val_conv);
19400         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
19401 }
19402
19403 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19404         LDKUnsignedChannelAnnouncement this_ptr_conv;
19405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19406         this_ptr_conv.is_owned = false;
19407         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19408         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
19409         return ret_arr;
19410 }
19411
19412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19413         LDKUnsignedChannelAnnouncement this_ptr_conv;
19414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19415         this_ptr_conv.is_owned = false;
19416         LDKThirtyTwoBytes val_ref;
19417         CHECK((*env)->GetArrayLength(env, val) == 32);
19418         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19419         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
19420 }
19421
19422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19423         LDKUnsignedChannelAnnouncement this_ptr_conv;
19424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19425         this_ptr_conv.is_owned = false;
19426         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
19427         return ret_val;
19428 }
19429
19430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19431         LDKUnsignedChannelAnnouncement this_ptr_conv;
19432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19433         this_ptr_conv.is_owned = false;
19434         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
19435 }
19436
19437 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19438         LDKUnsignedChannelAnnouncement this_ptr_conv;
19439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19440         this_ptr_conv.is_owned = false;
19441         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19442         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
19443         return ret_arr;
19444 }
19445
19446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19447         LDKUnsignedChannelAnnouncement this_ptr_conv;
19448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19449         this_ptr_conv.is_owned = false;
19450         LDKPublicKey val_ref;
19451         CHECK((*env)->GetArrayLength(env, val) == 33);
19452         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19453         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
19454 }
19455
19456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19457         LDKUnsignedChannelAnnouncement this_ptr_conv;
19458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19459         this_ptr_conv.is_owned = false;
19460         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19461         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
19462         return ret_arr;
19463 }
19464
19465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19466         LDKUnsignedChannelAnnouncement this_ptr_conv;
19467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19468         this_ptr_conv.is_owned = false;
19469         LDKPublicKey val_ref;
19470         CHECK((*env)->GetArrayLength(env, val) == 33);
19471         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19472         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
19473 }
19474
19475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19476         LDKUnsignedChannelAnnouncement this_ptr_conv;
19477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19478         this_ptr_conv.is_owned = false;
19479         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19480         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
19481         return ret_arr;
19482 }
19483
19484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19485         LDKUnsignedChannelAnnouncement this_ptr_conv;
19486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19487         this_ptr_conv.is_owned = false;
19488         LDKPublicKey val_ref;
19489         CHECK((*env)->GetArrayLength(env, val) == 33);
19490         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19491         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
19492 }
19493
19494 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19495         LDKUnsignedChannelAnnouncement this_ptr_conv;
19496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19497         this_ptr_conv.is_owned = false;
19498         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19499         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
19500         return ret_arr;
19501 }
19502
19503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19504         LDKUnsignedChannelAnnouncement this_ptr_conv;
19505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19506         this_ptr_conv.is_owned = false;
19507         LDKPublicKey val_ref;
19508         CHECK((*env)->GetArrayLength(env, val) == 33);
19509         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19510         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
19511 }
19512
19513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19514         LDKUnsignedChannelAnnouncement orig_conv;
19515         orig_conv.inner = (void*)(orig & (~1));
19516         orig_conv.is_owned = false;
19517         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
19518         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19519         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19520         uint64_t ret_ref = (uint64_t)ret_var.inner;
19521         if (ret_var.is_owned) {
19522                 ret_ref |= 1;
19523         }
19524         return ret_ref;
19525 }
19526
19527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19528         LDKChannelAnnouncement this_obj_conv;
19529         this_obj_conv.inner = (void*)(this_obj & (~1));
19530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19531         ChannelAnnouncement_free(this_obj_conv);
19532 }
19533
19534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19535         LDKChannelAnnouncement this_ptr_conv;
19536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19537         this_ptr_conv.is_owned = false;
19538         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19539         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
19540         return ret_arr;
19541 }
19542
19543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19544         LDKChannelAnnouncement this_ptr_conv;
19545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19546         this_ptr_conv.is_owned = false;
19547         LDKSignature val_ref;
19548         CHECK((*env)->GetArrayLength(env, val) == 64);
19549         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19550         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
19551 }
19552
19553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19554         LDKChannelAnnouncement this_ptr_conv;
19555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19556         this_ptr_conv.is_owned = false;
19557         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
19559         return ret_arr;
19560 }
19561
19562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19563         LDKChannelAnnouncement this_ptr_conv;
19564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19565         this_ptr_conv.is_owned = false;
19566         LDKSignature val_ref;
19567         CHECK((*env)->GetArrayLength(env, val) == 64);
19568         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19569         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
19570 }
19571
19572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19573         LDKChannelAnnouncement this_ptr_conv;
19574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19575         this_ptr_conv.is_owned = false;
19576         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19577         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
19578         return ret_arr;
19579 }
19580
19581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19582         LDKChannelAnnouncement this_ptr_conv;
19583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19584         this_ptr_conv.is_owned = false;
19585         LDKSignature val_ref;
19586         CHECK((*env)->GetArrayLength(env, val) == 64);
19587         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19588         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
19589 }
19590
19591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19592         LDKChannelAnnouncement this_ptr_conv;
19593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19594         this_ptr_conv.is_owned = false;
19595         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19596         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
19597         return ret_arr;
19598 }
19599
19600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19601         LDKChannelAnnouncement this_ptr_conv;
19602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19603         this_ptr_conv.is_owned = false;
19604         LDKSignature val_ref;
19605         CHECK((*env)->GetArrayLength(env, val) == 64);
19606         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19607         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
19608 }
19609
19610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19611         LDKChannelAnnouncement this_ptr_conv;
19612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19613         this_ptr_conv.is_owned = false;
19614         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
19615         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19616         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19617         uint64_t ret_ref = (uint64_t)ret_var.inner;
19618         if (ret_var.is_owned) {
19619                 ret_ref |= 1;
19620         }
19621         return ret_ref;
19622 }
19623
19624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19625         LDKChannelAnnouncement this_ptr_conv;
19626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19627         this_ptr_conv.is_owned = false;
19628         LDKUnsignedChannelAnnouncement val_conv;
19629         val_conv.inner = (void*)(val & (~1));
19630         val_conv.is_owned = (val & 1) || (val == 0);
19631         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
19632         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
19633 }
19634
19635 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) {
19636         LDKSignature node_signature_1_arg_ref;
19637         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
19638         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
19639         LDKSignature node_signature_2_arg_ref;
19640         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
19641         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
19642         LDKSignature bitcoin_signature_1_arg_ref;
19643         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
19644         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
19645         LDKSignature bitcoin_signature_2_arg_ref;
19646         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
19647         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
19648         LDKUnsignedChannelAnnouncement contents_arg_conv;
19649         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19650         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19651         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
19652         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);
19653         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19654         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19655         uint64_t ret_ref = (uint64_t)ret_var.inner;
19656         if (ret_var.is_owned) {
19657                 ret_ref |= 1;
19658         }
19659         return ret_ref;
19660 }
19661
19662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19663         LDKChannelAnnouncement orig_conv;
19664         orig_conv.inner = (void*)(orig & (~1));
19665         orig_conv.is_owned = false;
19666         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
19667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19669         uint64_t ret_ref = (uint64_t)ret_var.inner;
19670         if (ret_var.is_owned) {
19671                 ret_ref |= 1;
19672         }
19673         return ret_ref;
19674 }
19675
19676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19677         LDKUnsignedChannelUpdate this_obj_conv;
19678         this_obj_conv.inner = (void*)(this_obj & (~1));
19679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19680         UnsignedChannelUpdate_free(this_obj_conv);
19681 }
19682
19683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19684         LDKUnsignedChannelUpdate this_ptr_conv;
19685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19686         this_ptr_conv.is_owned = false;
19687         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
19689         return ret_arr;
19690 }
19691
19692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19693         LDKUnsignedChannelUpdate this_ptr_conv;
19694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19695         this_ptr_conv.is_owned = false;
19696         LDKThirtyTwoBytes val_ref;
19697         CHECK((*env)->GetArrayLength(env, val) == 32);
19698         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19699         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
19700 }
19701
19702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19703         LDKUnsignedChannelUpdate this_ptr_conv;
19704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19705         this_ptr_conv.is_owned = false;
19706         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
19707         return ret_val;
19708 }
19709
19710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19711         LDKUnsignedChannelUpdate this_ptr_conv;
19712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19713         this_ptr_conv.is_owned = false;
19714         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
19715 }
19716
19717 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19718         LDKUnsignedChannelUpdate this_ptr_conv;
19719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19720         this_ptr_conv.is_owned = false;
19721         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
19722         return ret_val;
19723 }
19724
19725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19726         LDKUnsignedChannelUpdate this_ptr_conv;
19727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19728         this_ptr_conv.is_owned = false;
19729         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
19730 }
19731
19732 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
19733         LDKUnsignedChannelUpdate this_ptr_conv;
19734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19735         this_ptr_conv.is_owned = false;
19736         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
19737         return ret_val;
19738 }
19739
19740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
19741         LDKUnsignedChannelUpdate this_ptr_conv;
19742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19743         this_ptr_conv.is_owned = false;
19744         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
19745 }
19746
19747 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19748         LDKUnsignedChannelUpdate this_ptr_conv;
19749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19750         this_ptr_conv.is_owned = false;
19751         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
19752         return ret_val;
19753 }
19754
19755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19756         LDKUnsignedChannelUpdate this_ptr_conv;
19757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19758         this_ptr_conv.is_owned = false;
19759         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
19760 }
19761
19762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19763         LDKUnsignedChannelUpdate this_ptr_conv;
19764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19765         this_ptr_conv.is_owned = false;
19766         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
19767         return ret_val;
19768 }
19769
19770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19771         LDKUnsignedChannelUpdate this_ptr_conv;
19772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19773         this_ptr_conv.is_owned = false;
19774         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
19775 }
19776
19777 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19778         LDKUnsignedChannelUpdate this_ptr_conv;
19779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19780         this_ptr_conv.is_owned = false;
19781         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
19782         return ret_val;
19783 }
19784
19785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19786         LDKUnsignedChannelUpdate this_ptr_conv;
19787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19788         this_ptr_conv.is_owned = false;
19789         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
19790 }
19791
19792 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
19793         LDKUnsignedChannelUpdate this_ptr_conv;
19794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19795         this_ptr_conv.is_owned = false;
19796         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
19797         return ret_val;
19798 }
19799
19800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19801         LDKUnsignedChannelUpdate this_ptr_conv;
19802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19803         this_ptr_conv.is_owned = false;
19804         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
19805 }
19806
19807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19808         LDKUnsignedChannelUpdate orig_conv;
19809         orig_conv.inner = (void*)(orig & (~1));
19810         orig_conv.is_owned = false;
19811         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19812         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19813         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19814         uint64_t ret_ref = (uint64_t)ret_var.inner;
19815         if (ret_var.is_owned) {
19816                 ret_ref |= 1;
19817         }
19818         return ret_ref;
19819 }
19820
19821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19822         LDKChannelUpdate this_obj_conv;
19823         this_obj_conv.inner = (void*)(this_obj & (~1));
19824         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19825         ChannelUpdate_free(this_obj_conv);
19826 }
19827
19828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19829         LDKChannelUpdate this_ptr_conv;
19830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19831         this_ptr_conv.is_owned = false;
19832         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19833         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
19834         return ret_arr;
19835 }
19836
19837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19838         LDKChannelUpdate this_ptr_conv;
19839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19840         this_ptr_conv.is_owned = false;
19841         LDKSignature val_ref;
19842         CHECK((*env)->GetArrayLength(env, val) == 64);
19843         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19844         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19845 }
19846
19847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19848         LDKChannelUpdate this_ptr_conv;
19849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19850         this_ptr_conv.is_owned = false;
19851         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19852         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19853         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19854         uint64_t ret_ref = (uint64_t)ret_var.inner;
19855         if (ret_var.is_owned) {
19856                 ret_ref |= 1;
19857         }
19858         return ret_ref;
19859 }
19860
19861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19862         LDKChannelUpdate this_ptr_conv;
19863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19864         this_ptr_conv.is_owned = false;
19865         LDKUnsignedChannelUpdate val_conv;
19866         val_conv.inner = (void*)(val & (~1));
19867         val_conv.is_owned = (val & 1) || (val == 0);
19868         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19869         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19870 }
19871
19872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19873         LDKSignature signature_arg_ref;
19874         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19875         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19876         LDKUnsignedChannelUpdate contents_arg_conv;
19877         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19878         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19879         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19880         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19881         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19882         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19883         uint64_t ret_ref = (uint64_t)ret_var.inner;
19884         if (ret_var.is_owned) {
19885                 ret_ref |= 1;
19886         }
19887         return ret_ref;
19888 }
19889
19890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19891         LDKChannelUpdate orig_conv;
19892         orig_conv.inner = (void*)(orig & (~1));
19893         orig_conv.is_owned = false;
19894         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19897         uint64_t ret_ref = (uint64_t)ret_var.inner;
19898         if (ret_var.is_owned) {
19899                 ret_ref |= 1;
19900         }
19901         return ret_ref;
19902 }
19903
19904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19905         LDKQueryChannelRange this_obj_conv;
19906         this_obj_conv.inner = (void*)(this_obj & (~1));
19907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19908         QueryChannelRange_free(this_obj_conv);
19909 }
19910
19911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19912         LDKQueryChannelRange this_ptr_conv;
19913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19914         this_ptr_conv.is_owned = false;
19915         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
19917         return ret_arr;
19918 }
19919
19920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19921         LDKQueryChannelRange this_ptr_conv;
19922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19923         this_ptr_conv.is_owned = false;
19924         LDKThirtyTwoBytes val_ref;
19925         CHECK((*env)->GetArrayLength(env, val) == 32);
19926         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19927         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19928 }
19929
19930 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19931         LDKQueryChannelRange this_ptr_conv;
19932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19933         this_ptr_conv.is_owned = false;
19934         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19935         return ret_val;
19936 }
19937
19938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19939         LDKQueryChannelRange this_ptr_conv;
19940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19941         this_ptr_conv.is_owned = false;
19942         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19943 }
19944
19945 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19946         LDKQueryChannelRange this_ptr_conv;
19947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19948         this_ptr_conv.is_owned = false;
19949         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19950         return ret_val;
19951 }
19952
19953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19954         LDKQueryChannelRange this_ptr_conv;
19955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19956         this_ptr_conv.is_owned = false;
19957         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19958 }
19959
19960 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) {
19961         LDKThirtyTwoBytes chain_hash_arg_ref;
19962         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19963         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19964         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19965         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19966         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19967         uint64_t ret_ref = (uint64_t)ret_var.inner;
19968         if (ret_var.is_owned) {
19969                 ret_ref |= 1;
19970         }
19971         return ret_ref;
19972 }
19973
19974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19975         LDKQueryChannelRange orig_conv;
19976         orig_conv.inner = (void*)(orig & (~1));
19977         orig_conv.is_owned = false;
19978         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19981         uint64_t ret_ref = (uint64_t)ret_var.inner;
19982         if (ret_var.is_owned) {
19983                 ret_ref |= 1;
19984         }
19985         return ret_ref;
19986 }
19987
19988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19989         LDKReplyChannelRange this_obj_conv;
19990         this_obj_conv.inner = (void*)(this_obj & (~1));
19991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19992         ReplyChannelRange_free(this_obj_conv);
19993 }
19994
19995 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19996         LDKReplyChannelRange this_ptr_conv;
19997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19998         this_ptr_conv.is_owned = false;
19999         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
20001         return ret_arr;
20002 }
20003
20004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20005         LDKReplyChannelRange this_ptr_conv;
20006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20007         this_ptr_conv.is_owned = false;
20008         LDKThirtyTwoBytes val_ref;
20009         CHECK((*env)->GetArrayLength(env, val) == 32);
20010         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20011         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20012 }
20013
20014 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20015         LDKReplyChannelRange this_ptr_conv;
20016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20017         this_ptr_conv.is_owned = false;
20018         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
20019         return ret_val;
20020 }
20021
20022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20023         LDKReplyChannelRange this_ptr_conv;
20024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20025         this_ptr_conv.is_owned = false;
20026         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
20027 }
20028
20029 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20030         LDKReplyChannelRange this_ptr_conv;
20031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20032         this_ptr_conv.is_owned = false;
20033         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
20034         return ret_val;
20035 }
20036
20037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20038         LDKReplyChannelRange this_ptr_conv;
20039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20040         this_ptr_conv.is_owned = false;
20041         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20042 }
20043
20044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
20045         LDKReplyChannelRange this_ptr_conv;
20046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20047         this_ptr_conv.is_owned = false;
20048         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
20049         return ret_val;
20050 }
20051
20052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20053         LDKReplyChannelRange this_ptr_conv;
20054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20055         this_ptr_conv.is_owned = false;
20056         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
20057 }
20058
20059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20060         LDKReplyChannelRange this_ptr_conv;
20061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20062         this_ptr_conv.is_owned = false;
20063         LDKCVec_u64Z val_constr;
20064         val_constr.datalen = (*env)->GetArrayLength(env, val);
20065         if (val_constr.datalen > 0)
20066                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20067         else
20068                 val_constr.data = NULL;
20069         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20070         for (size_t g = 0; g < val_constr.datalen; g++) {
20071                 int64_t val_conv_6 = val_vals[g];
20072                 val_constr.data[g] = val_conv_6;
20073         }
20074         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20075         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
20076 }
20077
20078 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) {
20079         LDKThirtyTwoBytes chain_hash_arg_ref;
20080         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20081         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20082         LDKCVec_u64Z short_channel_ids_arg_constr;
20083         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20084         if (short_channel_ids_arg_constr.datalen > 0)
20085                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20086         else
20087                 short_channel_ids_arg_constr.data = NULL;
20088         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20089         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20090                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20091                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20092         }
20093         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20094         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
20095         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20096         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20097         uint64_t ret_ref = (uint64_t)ret_var.inner;
20098         if (ret_var.is_owned) {
20099                 ret_ref |= 1;
20100         }
20101         return ret_ref;
20102 }
20103
20104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20105         LDKReplyChannelRange orig_conv;
20106         orig_conv.inner = (void*)(orig & (~1));
20107         orig_conv.is_owned = false;
20108         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
20109         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20110         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20111         uint64_t ret_ref = (uint64_t)ret_var.inner;
20112         if (ret_var.is_owned) {
20113                 ret_ref |= 1;
20114         }
20115         return ret_ref;
20116 }
20117
20118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20119         LDKQueryShortChannelIds this_obj_conv;
20120         this_obj_conv.inner = (void*)(this_obj & (~1));
20121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20122         QueryShortChannelIds_free(this_obj_conv);
20123 }
20124
20125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20126         LDKQueryShortChannelIds this_ptr_conv;
20127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20128         this_ptr_conv.is_owned = false;
20129         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20130         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
20131         return ret_arr;
20132 }
20133
20134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20135         LDKQueryShortChannelIds this_ptr_conv;
20136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20137         this_ptr_conv.is_owned = false;
20138         LDKThirtyTwoBytes val_ref;
20139         CHECK((*env)->GetArrayLength(env, val) == 32);
20140         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20141         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
20142 }
20143
20144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20145         LDKQueryShortChannelIds this_ptr_conv;
20146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20147         this_ptr_conv.is_owned = false;
20148         LDKCVec_u64Z val_constr;
20149         val_constr.datalen = (*env)->GetArrayLength(env, val);
20150         if (val_constr.datalen > 0)
20151                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20152         else
20153                 val_constr.data = NULL;
20154         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20155         for (size_t g = 0; g < val_constr.datalen; g++) {
20156                 int64_t val_conv_6 = val_vals[g];
20157                 val_constr.data[g] = val_conv_6;
20158         }
20159         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20160         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
20161 }
20162
20163 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) {
20164         LDKThirtyTwoBytes chain_hash_arg_ref;
20165         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20166         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20167         LDKCVec_u64Z short_channel_ids_arg_constr;
20168         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20169         if (short_channel_ids_arg_constr.datalen > 0)
20170                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20171         else
20172                 short_channel_ids_arg_constr.data = NULL;
20173         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20174         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20175                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20176                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20177         }
20178         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20179         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
20180         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20181         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20182         uint64_t ret_ref = (uint64_t)ret_var.inner;
20183         if (ret_var.is_owned) {
20184                 ret_ref |= 1;
20185         }
20186         return ret_ref;
20187 }
20188
20189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20190         LDKQueryShortChannelIds orig_conv;
20191         orig_conv.inner = (void*)(orig & (~1));
20192         orig_conv.is_owned = false;
20193         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
20194         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20195         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20196         uint64_t ret_ref = (uint64_t)ret_var.inner;
20197         if (ret_var.is_owned) {
20198                 ret_ref |= 1;
20199         }
20200         return ret_ref;
20201 }
20202
20203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20204         LDKReplyShortChannelIdsEnd this_obj_conv;
20205         this_obj_conv.inner = (void*)(this_obj & (~1));
20206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20207         ReplyShortChannelIdsEnd_free(this_obj_conv);
20208 }
20209
20210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20211         LDKReplyShortChannelIdsEnd this_ptr_conv;
20212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20213         this_ptr_conv.is_owned = false;
20214         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20215         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
20216         return ret_arr;
20217 }
20218
20219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20220         LDKReplyShortChannelIdsEnd this_ptr_conv;
20221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20222         this_ptr_conv.is_owned = false;
20223         LDKThirtyTwoBytes val_ref;
20224         CHECK((*env)->GetArrayLength(env, val) == 32);
20225         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20226         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
20227 }
20228
20229 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
20230         LDKReplyShortChannelIdsEnd this_ptr_conv;
20231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20232         this_ptr_conv.is_owned = false;
20233         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
20234         return ret_val;
20235 }
20236
20237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20238         LDKReplyShortChannelIdsEnd this_ptr_conv;
20239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20240         this_ptr_conv.is_owned = false;
20241         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
20242 }
20243
20244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
20245         LDKThirtyTwoBytes chain_hash_arg_ref;
20246         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20247         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20248         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
20249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20251         uint64_t ret_ref = (uint64_t)ret_var.inner;
20252         if (ret_var.is_owned) {
20253                 ret_ref |= 1;
20254         }
20255         return ret_ref;
20256 }
20257
20258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20259         LDKReplyShortChannelIdsEnd orig_conv;
20260         orig_conv.inner = (void*)(orig & (~1));
20261         orig_conv.is_owned = false;
20262         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
20263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20265         uint64_t ret_ref = (uint64_t)ret_var.inner;
20266         if (ret_var.is_owned) {
20267                 ret_ref |= 1;
20268         }
20269         return ret_ref;
20270 }
20271
20272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20273         LDKGossipTimestampFilter this_obj_conv;
20274         this_obj_conv.inner = (void*)(this_obj & (~1));
20275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20276         GossipTimestampFilter_free(this_obj_conv);
20277 }
20278
20279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20280         LDKGossipTimestampFilter this_ptr_conv;
20281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20282         this_ptr_conv.is_owned = false;
20283         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
20285         return ret_arr;
20286 }
20287
20288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20289         LDKGossipTimestampFilter this_ptr_conv;
20290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20291         this_ptr_conv.is_owned = false;
20292         LDKThirtyTwoBytes val_ref;
20293         CHECK((*env)->GetArrayLength(env, val) == 32);
20294         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20295         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
20296 }
20297
20298 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20299         LDKGossipTimestampFilter this_ptr_conv;
20300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20301         this_ptr_conv.is_owned = false;
20302         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
20303         return ret_val;
20304 }
20305
20306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20307         LDKGossipTimestampFilter this_ptr_conv;
20308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20309         this_ptr_conv.is_owned = false;
20310         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
20311 }
20312
20313 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
20314         LDKGossipTimestampFilter this_ptr_conv;
20315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20316         this_ptr_conv.is_owned = false;
20317         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
20318         return ret_val;
20319 }
20320
20321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20322         LDKGossipTimestampFilter this_ptr_conv;
20323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20324         this_ptr_conv.is_owned = false;
20325         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
20326 }
20327
20328 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) {
20329         LDKThirtyTwoBytes chain_hash_arg_ref;
20330         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20331         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20332         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
20333         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20334         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20335         uint64_t ret_ref = (uint64_t)ret_var.inner;
20336         if (ret_var.is_owned) {
20337                 ret_ref |= 1;
20338         }
20339         return ret_ref;
20340 }
20341
20342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20343         LDKGossipTimestampFilter orig_conv;
20344         orig_conv.inner = (void*)(orig & (~1));
20345         orig_conv.is_owned = false;
20346         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
20347         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20348         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20349         uint64_t ret_ref = (uint64_t)ret_var.inner;
20350         if (ret_var.is_owned) {
20351                 ret_ref |= 1;
20352         }
20353         return ret_ref;
20354 }
20355
20356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20357         if ((this_ptr & 1) != 0) return;
20358         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
20359         FREE((void*)this_ptr);
20360         ErrorAction_free(this_ptr_conv);
20361 }
20362
20363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20364         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
20365         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20366         *ret_copy = ErrorAction_clone(orig_conv);
20367         uint64_t ret_ref = (uint64_t)ret_copy;
20368         return ret_ref;
20369 }
20370
20371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20372         LDKLightningError this_obj_conv;
20373         this_obj_conv.inner = (void*)(this_obj & (~1));
20374         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20375         LightningError_free(this_obj_conv);
20376 }
20377
20378 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
20379         LDKLightningError this_ptr_conv;
20380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20381         this_ptr_conv.is_owned = false;
20382         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
20383         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20384         Str_free(ret_str);
20385         return ret_conv;
20386 }
20387
20388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20389         LDKLightningError this_ptr_conv;
20390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20391         this_ptr_conv.is_owned = false;
20392         LDKStr val_conv = java_to_owned_str(env, val);
20393         LightningError_set_err(&this_ptr_conv, val_conv);
20394 }
20395
20396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
20397         LDKLightningError this_ptr_conv;
20398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20399         this_ptr_conv.is_owned = false;
20400         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20401         *ret_copy = LightningError_get_action(&this_ptr_conv);
20402         uint64_t ret_ref = (uint64_t)ret_copy;
20403         return ret_ref;
20404 }
20405
20406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20407         LDKLightningError this_ptr_conv;
20408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20409         this_ptr_conv.is_owned = false;
20410         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
20411         LightningError_set_action(&this_ptr_conv, val_conv);
20412 }
20413
20414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
20415         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
20416         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
20417         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
20418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20420         uint64_t ret_ref = (uint64_t)ret_var.inner;
20421         if (ret_var.is_owned) {
20422                 ret_ref |= 1;
20423         }
20424         return ret_ref;
20425 }
20426
20427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20428         LDKLightningError orig_conv;
20429         orig_conv.inner = (void*)(orig & (~1));
20430         orig_conv.is_owned = false;
20431         LDKLightningError ret_var = LightningError_clone(&orig_conv);
20432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20434         uint64_t ret_ref = (uint64_t)ret_var.inner;
20435         if (ret_var.is_owned) {
20436                 ret_ref |= 1;
20437         }
20438         return ret_ref;
20439 }
20440
20441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20442         LDKCommitmentUpdate this_obj_conv;
20443         this_obj_conv.inner = (void*)(this_obj & (~1));
20444         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20445         CommitmentUpdate_free(this_obj_conv);
20446 }
20447
20448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20449         LDKCommitmentUpdate this_ptr_conv;
20450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20451         this_ptr_conv.is_owned = false;
20452         LDKCVec_UpdateAddHTLCZ val_constr;
20453         val_constr.datalen = (*env)->GetArrayLength(env, val);
20454         if (val_constr.datalen > 0)
20455                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20456         else
20457                 val_constr.data = NULL;
20458         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20459         for (size_t p = 0; p < val_constr.datalen; p++) {
20460                 int64_t val_conv_15 = val_vals[p];
20461                 LDKUpdateAddHTLC val_conv_15_conv;
20462                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
20463                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
20464                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
20465                 val_constr.data[p] = val_conv_15_conv;
20466         }
20467         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20468         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
20469 }
20470
20471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20472         LDKCommitmentUpdate this_ptr_conv;
20473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20474         this_ptr_conv.is_owned = false;
20475         LDKCVec_UpdateFulfillHTLCZ val_constr;
20476         val_constr.datalen = (*env)->GetArrayLength(env, val);
20477         if (val_constr.datalen > 0)
20478                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20479         else
20480                 val_constr.data = NULL;
20481         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20482         for (size_t t = 0; t < val_constr.datalen; t++) {
20483                 int64_t val_conv_19 = val_vals[t];
20484                 LDKUpdateFulfillHTLC val_conv_19_conv;
20485                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
20486                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
20487                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
20488                 val_constr.data[t] = val_conv_19_conv;
20489         }
20490         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20491         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
20492 }
20493
20494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20495         LDKCommitmentUpdate this_ptr_conv;
20496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20497         this_ptr_conv.is_owned = false;
20498         LDKCVec_UpdateFailHTLCZ val_constr;
20499         val_constr.datalen = (*env)->GetArrayLength(env, val);
20500         if (val_constr.datalen > 0)
20501                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20502         else
20503                 val_constr.data = NULL;
20504         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20505         for (size_t q = 0; q < val_constr.datalen; q++) {
20506                 int64_t val_conv_16 = val_vals[q];
20507                 LDKUpdateFailHTLC val_conv_16_conv;
20508                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
20509                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
20510                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
20511                 val_constr.data[q] = val_conv_16_conv;
20512         }
20513         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20514         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
20515 }
20516
20517 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) {
20518         LDKCommitmentUpdate this_ptr_conv;
20519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20520         this_ptr_conv.is_owned = false;
20521         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
20522         val_constr.datalen = (*env)->GetArrayLength(env, val);
20523         if (val_constr.datalen > 0)
20524                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20525         else
20526                 val_constr.data = NULL;
20527         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20528         for (size_t z = 0; z < val_constr.datalen; z++) {
20529                 int64_t val_conv_25 = val_vals[z];
20530                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
20531                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
20532                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
20533                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
20534                 val_constr.data[z] = val_conv_25_conv;
20535         }
20536         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20537         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
20538 }
20539
20540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
20541         LDKCommitmentUpdate this_ptr_conv;
20542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20543         this_ptr_conv.is_owned = false;
20544         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
20545         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20546         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20547         uint64_t ret_ref = (uint64_t)ret_var.inner;
20548         if (ret_var.is_owned) {
20549                 ret_ref |= 1;
20550         }
20551         return ret_ref;
20552 }
20553
20554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20555         LDKCommitmentUpdate this_ptr_conv;
20556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20557         this_ptr_conv.is_owned = false;
20558         LDKUpdateFee val_conv;
20559         val_conv.inner = (void*)(val & (~1));
20560         val_conv.is_owned = (val & 1) || (val == 0);
20561         val_conv = UpdateFee_clone(&val_conv);
20562         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
20563 }
20564
20565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
20566         LDKCommitmentUpdate this_ptr_conv;
20567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20568         this_ptr_conv.is_owned = false;
20569         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
20570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20572         uint64_t ret_ref = (uint64_t)ret_var.inner;
20573         if (ret_var.is_owned) {
20574                 ret_ref |= 1;
20575         }
20576         return ret_ref;
20577 }
20578
20579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20580         LDKCommitmentUpdate this_ptr_conv;
20581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20582         this_ptr_conv.is_owned = false;
20583         LDKCommitmentSigned val_conv;
20584         val_conv.inner = (void*)(val & (~1));
20585         val_conv.is_owned = (val & 1) || (val == 0);
20586         val_conv = CommitmentSigned_clone(&val_conv);
20587         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
20588 }
20589
20590 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) {
20591         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
20592         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
20593         if (update_add_htlcs_arg_constr.datalen > 0)
20594                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20595         else
20596                 update_add_htlcs_arg_constr.data = NULL;
20597         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
20598         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
20599                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
20600                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
20601                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
20602                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
20603                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
20604                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
20605         }
20606         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
20607         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
20608         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
20609         if (update_fulfill_htlcs_arg_constr.datalen > 0)
20610                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20611         else
20612                 update_fulfill_htlcs_arg_constr.data = NULL;
20613         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
20614         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
20615                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
20616                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
20617                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
20618                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
20619                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
20620                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
20621         }
20622         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
20623         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
20624         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
20625         if (update_fail_htlcs_arg_constr.datalen > 0)
20626                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20627         else
20628                 update_fail_htlcs_arg_constr.data = NULL;
20629         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
20630         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
20631                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
20632                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
20633                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
20634                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
20635                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
20636                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
20637         }
20638         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
20639         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
20640         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
20641         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
20642                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20643         else
20644                 update_fail_malformed_htlcs_arg_constr.data = NULL;
20645         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
20646         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
20647                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
20648                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
20649                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
20650                 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);
20651                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
20652                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
20653         }
20654         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
20655         LDKUpdateFee update_fee_arg_conv;
20656         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
20657         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
20658         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
20659         LDKCommitmentSigned commitment_signed_arg_conv;
20660         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
20661         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
20662         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
20663         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);
20664         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20665         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20666         uint64_t ret_ref = (uint64_t)ret_var.inner;
20667         if (ret_var.is_owned) {
20668                 ret_ref |= 1;
20669         }
20670         return ret_ref;
20671 }
20672
20673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20674         LDKCommitmentUpdate orig_conv;
20675         orig_conv.inner = (void*)(orig & (~1));
20676         orig_conv.is_owned = false;
20677         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
20678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20680         uint64_t ret_ref = (uint64_t)ret_var.inner;
20681         if (ret_var.is_owned) {
20682                 ret_ref |= 1;
20683         }
20684         return ret_ref;
20685 }
20686
20687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20688         if ((this_ptr & 1) != 0) return;
20689         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
20690         FREE((void*)this_ptr);
20691         HTLCFailChannelUpdate_free(this_ptr_conv);
20692 }
20693
20694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20695         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
20696         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
20697         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
20698         uint64_t ret_ref = (uint64_t)ret_copy;
20699         return ret_ref;
20700 }
20701
20702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20703         if ((this_ptr & 1) != 0) return;
20704         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
20705         FREE((void*)this_ptr);
20706         ChannelMessageHandler_free(this_ptr_conv);
20707 }
20708
20709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20710         if ((this_ptr & 1) != 0) return;
20711         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
20712         FREE((void*)this_ptr);
20713         RoutingMessageHandler_free(this_ptr_conv);
20714 }
20715
20716 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20717         LDKAcceptChannel obj_conv;
20718         obj_conv.inner = (void*)(obj & (~1));
20719         obj_conv.is_owned = false;
20720         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
20721         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20722         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20723         CVec_u8Z_free(ret_var);
20724         return ret_arr;
20725 }
20726
20727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20728         LDKu8slice ser_ref;
20729         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20730         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20731         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20732         *ret_conv = AcceptChannel_read(ser_ref);
20733         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20734         return (uint64_t)ret_conv;
20735 }
20736
20737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
20738         LDKAnnouncementSignatures obj_conv;
20739         obj_conv.inner = (void*)(obj & (~1));
20740         obj_conv.is_owned = false;
20741         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
20742         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20743         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20744         CVec_u8Z_free(ret_var);
20745         return ret_arr;
20746 }
20747
20748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20749         LDKu8slice ser_ref;
20750         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20751         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20752         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20753         *ret_conv = AnnouncementSignatures_read(ser_ref);
20754         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20755         return (uint64_t)ret_conv;
20756 }
20757
20758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
20759         LDKChannelReestablish obj_conv;
20760         obj_conv.inner = (void*)(obj & (~1));
20761         obj_conv.is_owned = false;
20762         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
20763         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20764         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20765         CVec_u8Z_free(ret_var);
20766         return ret_arr;
20767 }
20768
20769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20770         LDKu8slice ser_ref;
20771         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20772         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20773         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20774         *ret_conv = ChannelReestablish_read(ser_ref);
20775         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20776         return (uint64_t)ret_conv;
20777 }
20778
20779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20780         LDKClosingSigned obj_conv;
20781         obj_conv.inner = (void*)(obj & (~1));
20782         obj_conv.is_owned = false;
20783         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
20784         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20785         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20786         CVec_u8Z_free(ret_var);
20787         return ret_arr;
20788 }
20789
20790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20791         LDKu8slice ser_ref;
20792         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20793         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20794         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20795         *ret_conv = ClosingSigned_read(ser_ref);
20796         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20797         return (uint64_t)ret_conv;
20798 }
20799
20800 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20801         LDKCommitmentSigned obj_conv;
20802         obj_conv.inner = (void*)(obj & (~1));
20803         obj_conv.is_owned = false;
20804         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
20805         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20806         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20807         CVec_u8Z_free(ret_var);
20808         return ret_arr;
20809 }
20810
20811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20812         LDKu8slice ser_ref;
20813         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20814         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20815         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20816         *ret_conv = CommitmentSigned_read(ser_ref);
20817         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20818         return (uint64_t)ret_conv;
20819 }
20820
20821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
20822         LDKFundingCreated obj_conv;
20823         obj_conv.inner = (void*)(obj & (~1));
20824         obj_conv.is_owned = false;
20825         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20826         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20827         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20828         CVec_u8Z_free(ret_var);
20829         return ret_arr;
20830 }
20831
20832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20833         LDKu8slice ser_ref;
20834         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20835         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20836         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20837         *ret_conv = FundingCreated_read(ser_ref);
20838         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20839         return (uint64_t)ret_conv;
20840 }
20841
20842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20843         LDKFundingSigned obj_conv;
20844         obj_conv.inner = (void*)(obj & (~1));
20845         obj_conv.is_owned = false;
20846         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20847         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20848         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20849         CVec_u8Z_free(ret_var);
20850         return ret_arr;
20851 }
20852
20853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20854         LDKu8slice ser_ref;
20855         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20856         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20857         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20858         *ret_conv = FundingSigned_read(ser_ref);
20859         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20860         return (uint64_t)ret_conv;
20861 }
20862
20863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
20864         LDKFundingLocked obj_conv;
20865         obj_conv.inner = (void*)(obj & (~1));
20866         obj_conv.is_owned = false;
20867         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20868         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20869         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20870         CVec_u8Z_free(ret_var);
20871         return ret_arr;
20872 }
20873
20874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20875         LDKu8slice ser_ref;
20876         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20877         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20878         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20879         *ret_conv = FundingLocked_read(ser_ref);
20880         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20881         return (uint64_t)ret_conv;
20882 }
20883
20884 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
20885         LDKInit obj_conv;
20886         obj_conv.inner = (void*)(obj & (~1));
20887         obj_conv.is_owned = false;
20888         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20889         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20890         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20891         CVec_u8Z_free(ret_var);
20892         return ret_arr;
20893 }
20894
20895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20896         LDKu8slice ser_ref;
20897         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20898         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20899         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20900         *ret_conv = Init_read(ser_ref);
20901         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20902         return (uint64_t)ret_conv;
20903 }
20904
20905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20906         LDKOpenChannel obj_conv;
20907         obj_conv.inner = (void*)(obj & (~1));
20908         obj_conv.is_owned = false;
20909         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20910         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20911         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20912         CVec_u8Z_free(ret_var);
20913         return ret_arr;
20914 }
20915
20916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20917         LDKu8slice ser_ref;
20918         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20919         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20920         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20921         *ret_conv = OpenChannel_read(ser_ref);
20922         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20923         return (uint64_t)ret_conv;
20924 }
20925
20926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
20927         LDKRevokeAndACK obj_conv;
20928         obj_conv.inner = (void*)(obj & (~1));
20929         obj_conv.is_owned = false;
20930         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20931         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20932         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20933         CVec_u8Z_free(ret_var);
20934         return ret_arr;
20935 }
20936
20937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20938         LDKu8slice ser_ref;
20939         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20940         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20941         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20942         *ret_conv = RevokeAndACK_read(ser_ref);
20943         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20944         return (uint64_t)ret_conv;
20945 }
20946
20947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
20948         LDKShutdown obj_conv;
20949         obj_conv.inner = (void*)(obj & (~1));
20950         obj_conv.is_owned = false;
20951         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20952         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20953         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20954         CVec_u8Z_free(ret_var);
20955         return ret_arr;
20956 }
20957
20958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20959         LDKu8slice ser_ref;
20960         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20961         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20962         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20963         *ret_conv = Shutdown_read(ser_ref);
20964         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20965         return (uint64_t)ret_conv;
20966 }
20967
20968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20969         LDKUpdateFailHTLC obj_conv;
20970         obj_conv.inner = (void*)(obj & (~1));
20971         obj_conv.is_owned = false;
20972         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20973         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20974         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20975         CVec_u8Z_free(ret_var);
20976         return ret_arr;
20977 }
20978
20979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20980         LDKu8slice ser_ref;
20981         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20982         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20983         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20984         *ret_conv = UpdateFailHTLC_read(ser_ref);
20985         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20986         return (uint64_t)ret_conv;
20987 }
20988
20989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20990         LDKUpdateFailMalformedHTLC obj_conv;
20991         obj_conv.inner = (void*)(obj & (~1));
20992         obj_conv.is_owned = false;
20993         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20994         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20995         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20996         CVec_u8Z_free(ret_var);
20997         return ret_arr;
20998 }
20999
21000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21001         LDKu8slice ser_ref;
21002         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21003         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21004         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21005         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
21006         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21007         return (uint64_t)ret_conv;
21008 }
21009
21010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
21011         LDKUpdateFee obj_conv;
21012         obj_conv.inner = (void*)(obj & (~1));
21013         obj_conv.is_owned = false;
21014         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
21015         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21016         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21017         CVec_u8Z_free(ret_var);
21018         return ret_arr;
21019 }
21020
21021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21022         LDKu8slice ser_ref;
21023         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21024         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21025         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21026         *ret_conv = UpdateFee_read(ser_ref);
21027         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21028         return (uint64_t)ret_conv;
21029 }
21030
21031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21032         LDKUpdateFulfillHTLC obj_conv;
21033         obj_conv.inner = (void*)(obj & (~1));
21034         obj_conv.is_owned = false;
21035         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
21036         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21037         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21038         CVec_u8Z_free(ret_var);
21039         return ret_arr;
21040 }
21041
21042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21043         LDKu8slice ser_ref;
21044         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21045         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21046         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21047         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
21048         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21049         return (uint64_t)ret_conv;
21050 }
21051
21052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21053         LDKUpdateAddHTLC obj_conv;
21054         obj_conv.inner = (void*)(obj & (~1));
21055         obj_conv.is_owned = false;
21056         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
21057         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21058         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21059         CVec_u8Z_free(ret_var);
21060         return ret_arr;
21061 }
21062
21063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21064         LDKu8slice ser_ref;
21065         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21066         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21067         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21068         *ret_conv = UpdateAddHTLC_read(ser_ref);
21069         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21070         return (uint64_t)ret_conv;
21071 }
21072
21073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
21074         LDKPing obj_conv;
21075         obj_conv.inner = (void*)(obj & (~1));
21076         obj_conv.is_owned = false;
21077         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
21078         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21079         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21080         CVec_u8Z_free(ret_var);
21081         return ret_arr;
21082 }
21083
21084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21085         LDKu8slice ser_ref;
21086         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21087         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21088         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21089         *ret_conv = Ping_read(ser_ref);
21090         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21091         return (uint64_t)ret_conv;
21092 }
21093
21094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
21095         LDKPong obj_conv;
21096         obj_conv.inner = (void*)(obj & (~1));
21097         obj_conv.is_owned = false;
21098         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
21099         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21100         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21101         CVec_u8Z_free(ret_var);
21102         return ret_arr;
21103 }
21104
21105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21106         LDKu8slice ser_ref;
21107         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21108         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21109         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21110         *ret_conv = Pong_read(ser_ref);
21111         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21112         return (uint64_t)ret_conv;
21113 }
21114
21115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21116         LDKUnsignedChannelAnnouncement obj_conv;
21117         obj_conv.inner = (void*)(obj & (~1));
21118         obj_conv.is_owned = false;
21119         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
21120         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21121         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21122         CVec_u8Z_free(ret_var);
21123         return ret_arr;
21124 }
21125
21126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21127         LDKu8slice ser_ref;
21128         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21129         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21130         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21131         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
21132         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21133         return (uint64_t)ret_conv;
21134 }
21135
21136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21137         LDKChannelAnnouncement obj_conv;
21138         obj_conv.inner = (void*)(obj & (~1));
21139         obj_conv.is_owned = false;
21140         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
21141         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21142         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21143         CVec_u8Z_free(ret_var);
21144         return ret_arr;
21145 }
21146
21147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21148         LDKu8slice ser_ref;
21149         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21150         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21151         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21152         *ret_conv = ChannelAnnouncement_read(ser_ref);
21153         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21154         return (uint64_t)ret_conv;
21155 }
21156
21157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21158         LDKUnsignedChannelUpdate obj_conv;
21159         obj_conv.inner = (void*)(obj & (~1));
21160         obj_conv.is_owned = false;
21161         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
21162         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21163         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21164         CVec_u8Z_free(ret_var);
21165         return ret_arr;
21166 }
21167
21168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21169         LDKu8slice ser_ref;
21170         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21171         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21172         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21173         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
21174         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21175         return (uint64_t)ret_conv;
21176 }
21177
21178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21179         LDKChannelUpdate obj_conv;
21180         obj_conv.inner = (void*)(obj & (~1));
21181         obj_conv.is_owned = false;
21182         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
21183         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21184         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21185         CVec_u8Z_free(ret_var);
21186         return ret_arr;
21187 }
21188
21189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21190         LDKu8slice ser_ref;
21191         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21192         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21193         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21194         *ret_conv = ChannelUpdate_read(ser_ref);
21195         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21196         return (uint64_t)ret_conv;
21197 }
21198
21199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
21200         LDKErrorMessage obj_conv;
21201         obj_conv.inner = (void*)(obj & (~1));
21202         obj_conv.is_owned = false;
21203         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
21204         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21205         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21206         CVec_u8Z_free(ret_var);
21207         return ret_arr;
21208 }
21209
21210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21211         LDKu8slice ser_ref;
21212         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21213         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21214         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21215         *ret_conv = ErrorMessage_read(ser_ref);
21216         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21217         return (uint64_t)ret_conv;
21218 }
21219
21220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21221         LDKUnsignedNodeAnnouncement obj_conv;
21222         obj_conv.inner = (void*)(obj & (~1));
21223         obj_conv.is_owned = false;
21224         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
21225         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21226         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21227         CVec_u8Z_free(ret_var);
21228         return ret_arr;
21229 }
21230
21231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21232         LDKu8slice ser_ref;
21233         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21234         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21235         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
21236         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
21237         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21238         return (uint64_t)ret_conv;
21239 }
21240
21241 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21242         LDKNodeAnnouncement obj_conv;
21243         obj_conv.inner = (void*)(obj & (~1));
21244         obj_conv.is_owned = false;
21245         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
21246         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21247         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21248         CVec_u8Z_free(ret_var);
21249         return ret_arr;
21250 }
21251
21252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21253         LDKu8slice ser_ref;
21254         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21255         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21256         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
21257         *ret_conv = NodeAnnouncement_read(ser_ref);
21258         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21259         return (uint64_t)ret_conv;
21260 }
21261
21262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21263         LDKu8slice ser_ref;
21264         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21265         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21266         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21267         *ret_conv = QueryShortChannelIds_read(ser_ref);
21268         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21269         return (uint64_t)ret_conv;
21270 }
21271
21272 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
21273         LDKQueryShortChannelIds obj_conv;
21274         obj_conv.inner = (void*)(obj & (~1));
21275         obj_conv.is_owned = false;
21276         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
21277         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21278         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21279         CVec_u8Z_free(ret_var);
21280         return ret_arr;
21281 }
21282
21283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21284         LDKu8slice ser_ref;
21285         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21286         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21287         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21288         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
21289         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21290         return (uint64_t)ret_conv;
21291 }
21292
21293 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
21294         LDKReplyShortChannelIdsEnd obj_conv;
21295         obj_conv.inner = (void*)(obj & (~1));
21296         obj_conv.is_owned = false;
21297         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
21298         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21299         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21300         CVec_u8Z_free(ret_var);
21301         return ret_arr;
21302 }
21303
21304 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
21305         LDKQueryChannelRange this_arg_conv;
21306         this_arg_conv.inner = (void*)(this_arg & (~1));
21307         this_arg_conv.is_owned = false;
21308         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
21309         return ret_val;
21310 }
21311
21312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21313         LDKu8slice ser_ref;
21314         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21315         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21316         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21317         *ret_conv = QueryChannelRange_read(ser_ref);
21318         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21319         return (uint64_t)ret_conv;
21320 }
21321
21322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21323         LDKQueryChannelRange obj_conv;
21324         obj_conv.inner = (void*)(obj & (~1));
21325         obj_conv.is_owned = false;
21326         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
21327         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21328         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21329         CVec_u8Z_free(ret_var);
21330         return ret_arr;
21331 }
21332
21333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21334         LDKu8slice ser_ref;
21335         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21336         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21337         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21338         *ret_conv = ReplyChannelRange_read(ser_ref);
21339         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21340         return (uint64_t)ret_conv;
21341 }
21342
21343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21344         LDKReplyChannelRange obj_conv;
21345         obj_conv.inner = (void*)(obj & (~1));
21346         obj_conv.is_owned = false;
21347         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
21348         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21349         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21350         CVec_u8Z_free(ret_var);
21351         return ret_arr;
21352 }
21353
21354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21355         LDKu8slice ser_ref;
21356         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21357         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21358         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21359         *ret_conv = GossipTimestampFilter_read(ser_ref);
21360         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21361         return (uint64_t)ret_conv;
21362 }
21363
21364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
21365         LDKGossipTimestampFilter obj_conv;
21366         obj_conv.inner = (void*)(obj & (~1));
21367         obj_conv.is_owned = false;
21368         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
21369         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21370         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21371         CVec_u8Z_free(ret_var);
21372         return ret_arr;
21373 }
21374
21375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21376         LDKIgnoringMessageHandler this_obj_conv;
21377         this_obj_conv.inner = (void*)(this_obj & (~1));
21378         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21379         IgnoringMessageHandler_free(this_obj_conv);
21380 }
21381
21382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
21383         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
21384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21386         uint64_t ret_ref = (uint64_t)ret_var.inner;
21387         if (ret_var.is_owned) {
21388                 ret_ref |= 1;
21389         }
21390         return ret_ref;
21391 }
21392
21393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21394         LDKIgnoringMessageHandler this_arg_conv;
21395         this_arg_conv.inner = (void*)(this_arg & (~1));
21396         this_arg_conv.is_owned = false;
21397         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21398         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21399         return (uint64_t)ret;
21400 }
21401
21402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21403         LDKIgnoringMessageHandler this_arg_conv;
21404         this_arg_conv.inner = (void*)(this_arg & (~1));
21405         this_arg_conv.is_owned = false;
21406         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21407         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
21408         return (uint64_t)ret;
21409 }
21410
21411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21412         LDKErroringMessageHandler this_obj_conv;
21413         this_obj_conv.inner = (void*)(this_obj & (~1));
21414         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21415         ErroringMessageHandler_free(this_obj_conv);
21416 }
21417
21418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
21419         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
21420         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21421         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21422         uint64_t ret_ref = (uint64_t)ret_var.inner;
21423         if (ret_var.is_owned) {
21424                 ret_ref |= 1;
21425         }
21426         return ret_ref;
21427 }
21428
21429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21430         LDKErroringMessageHandler this_arg_conv;
21431         this_arg_conv.inner = (void*)(this_arg & (~1));
21432         this_arg_conv.is_owned = false;
21433         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21434         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21435         return (uint64_t)ret;
21436 }
21437
21438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21439         LDKErroringMessageHandler this_arg_conv;
21440         this_arg_conv.inner = (void*)(this_arg & (~1));
21441         this_arg_conv.is_owned = false;
21442         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21443         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
21444         return (uint64_t)ret;
21445 }
21446
21447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21448         LDKMessageHandler this_obj_conv;
21449         this_obj_conv.inner = (void*)(this_obj & (~1));
21450         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21451         MessageHandler_free(this_obj_conv);
21452 }
21453
21454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21455         LDKMessageHandler this_ptr_conv;
21456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21457         this_ptr_conv.is_owned = false;
21458         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
21459         return ret_ret;
21460 }
21461
21462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21463         LDKMessageHandler this_ptr_conv;
21464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21465         this_ptr_conv.is_owned = false;
21466         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
21467         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
21468                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21469                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
21470         }
21471         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
21472 }
21473
21474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21475         LDKMessageHandler this_ptr_conv;
21476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21477         this_ptr_conv.is_owned = false;
21478         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
21479         return ret_ret;
21480 }
21481
21482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21483         LDKMessageHandler this_ptr_conv;
21484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21485         this_ptr_conv.is_owned = false;
21486         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
21487         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21488                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21489                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
21490         }
21491         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
21492 }
21493
21494 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) {
21495         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
21496         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
21497                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21498                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
21499         }
21500         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
21501         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21502                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21503                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
21504         }
21505         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
21506         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21507         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21508         uint64_t ret_ref = (uint64_t)ret_var.inner;
21509         if (ret_var.is_owned) {
21510                 ret_ref |= 1;
21511         }
21512         return ret_ref;
21513 }
21514
21515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21516         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
21517         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
21518         *ret = SocketDescriptor_clone(orig_conv);
21519         return (uint64_t)ret;
21520 }
21521
21522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21523         if ((this_ptr & 1) != 0) return;
21524         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
21525         FREE((void*)this_ptr);
21526         SocketDescriptor_free(this_ptr_conv);
21527 }
21528
21529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21530         LDKPeerHandleError this_obj_conv;
21531         this_obj_conv.inner = (void*)(this_obj & (~1));
21532         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21533         PeerHandleError_free(this_obj_conv);
21534 }
21535
21536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
21537         LDKPeerHandleError this_ptr_conv;
21538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21539         this_ptr_conv.is_owned = false;
21540         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
21541         return ret_val;
21542 }
21543
21544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21545         LDKPeerHandleError this_ptr_conv;
21546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21547         this_ptr_conv.is_owned = false;
21548         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
21549 }
21550
21551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
21552         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
21553         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21554         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21555         uint64_t ret_ref = (uint64_t)ret_var.inner;
21556         if (ret_var.is_owned) {
21557                 ret_ref |= 1;
21558         }
21559         return ret_ref;
21560 }
21561
21562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21563         LDKPeerHandleError orig_conv;
21564         orig_conv.inner = (void*)(orig & (~1));
21565         orig_conv.is_owned = false;
21566         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
21567         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21568         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21569         uint64_t ret_ref = (uint64_t)ret_var.inner;
21570         if (ret_var.is_owned) {
21571                 ret_ref |= 1;
21572         }
21573         return ret_ref;
21574 }
21575
21576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21577         LDKPeerManager this_obj_conv;
21578         this_obj_conv.inner = (void*)(this_obj & (~1));
21579         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21580         PeerManager_free(this_obj_conv);
21581 }
21582
21583 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) {
21584         LDKMessageHandler message_handler_conv;
21585         message_handler_conv.inner = (void*)(message_handler & (~1));
21586         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
21587         // Warning: we need a move here but no clone is available for LDKMessageHandler
21588         LDKSecretKey our_node_secret_ref;
21589         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
21590         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
21591         unsigned char ephemeral_random_data_arr[32];
21592         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
21593         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
21594         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
21595         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21596         if (logger_conv.free == LDKLogger_JCalls_free) {
21597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21598                 LDKLogger_JCalls_cloned(&logger_conv);
21599         }
21600         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
21601         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21602         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21603         uint64_t ret_ref = (uint64_t)ret_var.inner;
21604         if (ret_var.is_owned) {
21605                 ret_ref |= 1;
21606         }
21607         return ret_ref;
21608 }
21609
21610 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
21611         LDKPeerManager this_arg_conv;
21612         this_arg_conv.inner = (void*)(this_arg & (~1));
21613         this_arg_conv.is_owned = false;
21614         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
21615         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
21616         ;
21617         for (size_t i = 0; i < ret_var.datalen; i++) {
21618                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
21619                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
21620                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
21621         }
21622         FREE(ret_var.data);
21623         return ret_arr;
21624 }
21625
21626 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) {
21627         LDKPeerManager this_arg_conv;
21628         this_arg_conv.inner = (void*)(this_arg & (~1));
21629         this_arg_conv.is_owned = false;
21630         LDKPublicKey their_node_id_ref;
21631         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
21632         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
21633         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21634         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
21635                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21636                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
21637         }
21638         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21639         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
21640         return (uint64_t)ret_conv;
21641 }
21642
21643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21644         LDKPeerManager this_arg_conv;
21645         this_arg_conv.inner = (void*)(this_arg & (~1));
21646         this_arg_conv.is_owned = false;
21647         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21648         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
21649                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21650                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
21651         }
21652         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21653         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
21654         return (uint64_t)ret_conv;
21655 }
21656
21657 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) {
21658         LDKPeerManager this_arg_conv;
21659         this_arg_conv.inner = (void*)(this_arg & (~1));
21660         this_arg_conv.is_owned = false;
21661         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21662         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21663         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
21664         return (uint64_t)ret_conv;
21665 }
21666
21667 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) {
21668         LDKPeerManager this_arg_conv;
21669         this_arg_conv.inner = (void*)(this_arg & (~1));
21670         this_arg_conv.is_owned = false;
21671         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
21672         LDKu8slice data_ref;
21673         data_ref.datalen = (*env)->GetArrayLength(env, data);
21674         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
21675         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21676         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
21677         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
21678         return (uint64_t)ret_conv;
21679 }
21680
21681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
21682         LDKPeerManager this_arg_conv;
21683         this_arg_conv.inner = (void*)(this_arg & (~1));
21684         this_arg_conv.is_owned = false;
21685         PeerManager_process_events(&this_arg_conv);
21686 }
21687
21688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21689         LDKPeerManager this_arg_conv;
21690         this_arg_conv.inner = (void*)(this_arg & (~1));
21691         this_arg_conv.is_owned = false;
21692         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21693         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
21694 }
21695
21696 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) {
21697         LDKPeerManager this_arg_conv;
21698         this_arg_conv.inner = (void*)(this_arg & (~1));
21699         this_arg_conv.is_owned = false;
21700         LDKPublicKey node_id_ref;
21701         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21702         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21703         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
21704 }
21705
21706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
21707         LDKPeerManager this_arg_conv;
21708         this_arg_conv.inner = (void*)(this_arg & (~1));
21709         this_arg_conv.is_owned = false;
21710         PeerManager_timer_tick_occurred(&this_arg_conv);
21711 }
21712
21713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
21714         unsigned char commitment_seed_arr[32];
21715         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
21716         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
21717         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
21718         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21719         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
21720         return ret_arr;
21721 }
21722
21723 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) {
21724         LDKPublicKey per_commitment_point_ref;
21725         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21726         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21727         unsigned char base_secret_arr[32];
21728         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
21729         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
21730         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
21731         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21732         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
21733         return (uint64_t)ret_conv;
21734 }
21735
21736 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) {
21737         LDKPublicKey per_commitment_point_ref;
21738         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21739         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21740         LDKPublicKey base_point_ref;
21741         CHECK((*env)->GetArrayLength(env, base_point) == 33);
21742         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
21743         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21744         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
21745         return (uint64_t)ret_conv;
21746 }
21747
21748 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) {
21749         unsigned char per_commitment_secret_arr[32];
21750         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
21751         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
21752         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
21753         unsigned char countersignatory_revocation_base_secret_arr[32];
21754         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
21755         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
21756         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
21757         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21758         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
21759         return (uint64_t)ret_conv;
21760 }
21761
21762 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) {
21763         LDKPublicKey per_commitment_point_ref;
21764         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21765         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21766         LDKPublicKey countersignatory_revocation_base_point_ref;
21767         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
21768         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
21769         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21770         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
21771         return (uint64_t)ret_conv;
21772 }
21773
21774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21775         LDKTxCreationKeys this_obj_conv;
21776         this_obj_conv.inner = (void*)(this_obj & (~1));
21777         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21778         TxCreationKeys_free(this_obj_conv);
21779 }
21780
21781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21782         LDKTxCreationKeys this_ptr_conv;
21783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21784         this_ptr_conv.is_owned = false;
21785         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21786         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
21787         return ret_arr;
21788 }
21789
21790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21791         LDKTxCreationKeys this_ptr_conv;
21792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21793         this_ptr_conv.is_owned = false;
21794         LDKPublicKey val_ref;
21795         CHECK((*env)->GetArrayLength(env, val) == 33);
21796         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21797         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
21798 }
21799
21800 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21801         LDKTxCreationKeys this_ptr_conv;
21802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21803         this_ptr_conv.is_owned = false;
21804         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21805         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
21806         return ret_arr;
21807 }
21808
21809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21810         LDKTxCreationKeys this_ptr_conv;
21811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21812         this_ptr_conv.is_owned = false;
21813         LDKPublicKey val_ref;
21814         CHECK((*env)->GetArrayLength(env, val) == 33);
21815         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21816         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21817 }
21818
21819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21820         LDKTxCreationKeys this_ptr_conv;
21821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21822         this_ptr_conv.is_owned = false;
21823         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
21825         return ret_arr;
21826 }
21827
21828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21829         LDKTxCreationKeys this_ptr_conv;
21830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21831         this_ptr_conv.is_owned = false;
21832         LDKPublicKey val_ref;
21833         CHECK((*env)->GetArrayLength(env, val) == 33);
21834         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21835         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21836 }
21837
21838 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21839         LDKTxCreationKeys this_ptr_conv;
21840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21841         this_ptr_conv.is_owned = false;
21842         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21843         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
21844         return ret_arr;
21845 }
21846
21847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21848         LDKTxCreationKeys this_ptr_conv;
21849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21850         this_ptr_conv.is_owned = false;
21851         LDKPublicKey val_ref;
21852         CHECK((*env)->GetArrayLength(env, val) == 33);
21853         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21854         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21855 }
21856
21857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21858         LDKTxCreationKeys this_ptr_conv;
21859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21860         this_ptr_conv.is_owned = false;
21861         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21862         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
21863         return ret_arr;
21864 }
21865
21866 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) {
21867         LDKTxCreationKeys this_ptr_conv;
21868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21869         this_ptr_conv.is_owned = false;
21870         LDKPublicKey val_ref;
21871         CHECK((*env)->GetArrayLength(env, val) == 33);
21872         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21873         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21874 }
21875
21876 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) {
21877         LDKPublicKey per_commitment_point_arg_ref;
21878         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
21879         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
21880         LDKPublicKey revocation_key_arg_ref;
21881         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
21882         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
21883         LDKPublicKey broadcaster_htlc_key_arg_ref;
21884         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
21885         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
21886         LDKPublicKey countersignatory_htlc_key_arg_ref;
21887         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
21888         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
21889         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21890         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
21891         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
21892         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);
21893         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21894         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21895         uint64_t ret_ref = (uint64_t)ret_var.inner;
21896         if (ret_var.is_owned) {
21897                 ret_ref |= 1;
21898         }
21899         return ret_ref;
21900 }
21901
21902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21903         LDKTxCreationKeys orig_conv;
21904         orig_conv.inner = (void*)(orig & (~1));
21905         orig_conv.is_owned = false;
21906         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21907         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21908         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21909         uint64_t ret_ref = (uint64_t)ret_var.inner;
21910         if (ret_var.is_owned) {
21911                 ret_ref |= 1;
21912         }
21913         return ret_ref;
21914 }
21915
21916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21917         LDKTxCreationKeys obj_conv;
21918         obj_conv.inner = (void*)(obj & (~1));
21919         obj_conv.is_owned = false;
21920         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21921         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21922         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21923         CVec_u8Z_free(ret_var);
21924         return ret_arr;
21925 }
21926
21927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21928         LDKu8slice ser_ref;
21929         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21930         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21931         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21932         *ret_conv = TxCreationKeys_read(ser_ref);
21933         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21934         return (uint64_t)ret_conv;
21935 }
21936
21937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21938         LDKChannelPublicKeys this_obj_conv;
21939         this_obj_conv.inner = (void*)(this_obj & (~1));
21940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21941         ChannelPublicKeys_free(this_obj_conv);
21942 }
21943
21944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21945         LDKChannelPublicKeys this_ptr_conv;
21946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21947         this_ptr_conv.is_owned = false;
21948         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
21950         return ret_arr;
21951 }
21952
21953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21954         LDKChannelPublicKeys this_ptr_conv;
21955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21956         this_ptr_conv.is_owned = false;
21957         LDKPublicKey val_ref;
21958         CHECK((*env)->GetArrayLength(env, val) == 33);
21959         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21960         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21961 }
21962
21963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21964         LDKChannelPublicKeys this_ptr_conv;
21965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21966         this_ptr_conv.is_owned = false;
21967         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21969         return ret_arr;
21970 }
21971
21972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21973         LDKChannelPublicKeys this_ptr_conv;
21974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21975         this_ptr_conv.is_owned = false;
21976         LDKPublicKey val_ref;
21977         CHECK((*env)->GetArrayLength(env, val) == 33);
21978         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21979         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21980 }
21981
21982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21983         LDKChannelPublicKeys this_ptr_conv;
21984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21985         this_ptr_conv.is_owned = false;
21986         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
21988         return ret_arr;
21989 }
21990
21991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21992         LDKChannelPublicKeys this_ptr_conv;
21993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21994         this_ptr_conv.is_owned = false;
21995         LDKPublicKey val_ref;
21996         CHECK((*env)->GetArrayLength(env, val) == 33);
21997         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21998         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21999 }
22000
22001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22002         LDKChannelPublicKeys this_ptr_conv;
22003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22004         this_ptr_conv.is_owned = false;
22005         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22006         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
22007         return ret_arr;
22008 }
22009
22010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22011         LDKChannelPublicKeys this_ptr_conv;
22012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22013         this_ptr_conv.is_owned = false;
22014         LDKPublicKey val_ref;
22015         CHECK((*env)->GetArrayLength(env, val) == 33);
22016         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22017         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22018 }
22019
22020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22021         LDKChannelPublicKeys this_ptr_conv;
22022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22023         this_ptr_conv.is_owned = false;
22024         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22025         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
22026         return ret_arr;
22027 }
22028
22029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22030         LDKChannelPublicKeys this_ptr_conv;
22031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22032         this_ptr_conv.is_owned = false;
22033         LDKPublicKey val_ref;
22034         CHECK((*env)->GetArrayLength(env, val) == 33);
22035         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22036         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
22037 }
22038
22039 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) {
22040         LDKPublicKey funding_pubkey_arg_ref;
22041         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
22042         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
22043         LDKPublicKey revocation_basepoint_arg_ref;
22044         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
22045         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
22046         LDKPublicKey payment_point_arg_ref;
22047         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
22048         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
22049         LDKPublicKey delayed_payment_basepoint_arg_ref;
22050         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
22051         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
22052         LDKPublicKey htlc_basepoint_arg_ref;
22053         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
22054         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
22055         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);
22056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22058         uint64_t ret_ref = (uint64_t)ret_var.inner;
22059         if (ret_var.is_owned) {
22060                 ret_ref |= 1;
22061         }
22062         return ret_ref;
22063 }
22064
22065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22066         LDKChannelPublicKeys orig_conv;
22067         orig_conv.inner = (void*)(orig & (~1));
22068         orig_conv.is_owned = false;
22069         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
22070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22072         uint64_t ret_ref = (uint64_t)ret_var.inner;
22073         if (ret_var.is_owned) {
22074                 ret_ref |= 1;
22075         }
22076         return ret_ref;
22077 }
22078
22079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
22080         LDKChannelPublicKeys obj_conv;
22081         obj_conv.inner = (void*)(obj & (~1));
22082         obj_conv.is_owned = false;
22083         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
22084         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22085         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22086         CVec_u8Z_free(ret_var);
22087         return ret_arr;
22088 }
22089
22090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22091         LDKu8slice ser_ref;
22092         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22093         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22094         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
22095         *ret_conv = ChannelPublicKeys_read(ser_ref);
22096         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22097         return (uint64_t)ret_conv;
22098 }
22099
22100 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) {
22101         LDKPublicKey per_commitment_point_ref;
22102         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22103         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22104         LDKPublicKey broadcaster_delayed_payment_base_ref;
22105         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
22106         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
22107         LDKPublicKey broadcaster_htlc_base_ref;
22108         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
22109         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
22110         LDKPublicKey countersignatory_revocation_base_ref;
22111         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
22112         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
22113         LDKPublicKey countersignatory_htlc_base_ref;
22114         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
22115         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
22116         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22117         *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);
22118         return (uint64_t)ret_conv;
22119 }
22120
22121 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) {
22122         LDKPublicKey per_commitment_point_ref;
22123         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22124         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22125         LDKChannelPublicKeys broadcaster_keys_conv;
22126         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22127         broadcaster_keys_conv.is_owned = false;
22128         LDKChannelPublicKeys countersignatory_keys_conv;
22129         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22130         countersignatory_keys_conv.is_owned = false;
22131         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22132         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
22133         return (uint64_t)ret_conv;
22134 }
22135
22136 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) {
22137         LDKPublicKey revocation_key_ref;
22138         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22139         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22140         LDKPublicKey broadcaster_delayed_payment_key_ref;
22141         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22142         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22143         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
22144         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22145         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22146         CVec_u8Z_free(ret_var);
22147         return ret_arr;
22148 }
22149
22150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22151         LDKHTLCOutputInCommitment this_obj_conv;
22152         this_obj_conv.inner = (void*)(this_obj & (~1));
22153         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22154         HTLCOutputInCommitment_free(this_obj_conv);
22155 }
22156
22157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
22158         LDKHTLCOutputInCommitment this_ptr_conv;
22159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22160         this_ptr_conv.is_owned = false;
22161         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
22162         return ret_val;
22163 }
22164
22165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22166         LDKHTLCOutputInCommitment this_ptr_conv;
22167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22168         this_ptr_conv.is_owned = false;
22169         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
22170 }
22171
22172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22173         LDKHTLCOutputInCommitment this_ptr_conv;
22174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22175         this_ptr_conv.is_owned = false;
22176         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
22177         return ret_val;
22178 }
22179
22180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22181         LDKHTLCOutputInCommitment this_ptr_conv;
22182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22183         this_ptr_conv.is_owned = false;
22184         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
22185 }
22186
22187 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
22188         LDKHTLCOutputInCommitment this_ptr_conv;
22189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22190         this_ptr_conv.is_owned = false;
22191         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
22192         return ret_val;
22193 }
22194
22195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22196         LDKHTLCOutputInCommitment this_ptr_conv;
22197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22198         this_ptr_conv.is_owned = false;
22199         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
22200 }
22201
22202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22203         LDKHTLCOutputInCommitment this_ptr_conv;
22204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22205         this_ptr_conv.is_owned = false;
22206         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22207         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
22208         return ret_arr;
22209 }
22210
22211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22212         LDKHTLCOutputInCommitment this_ptr_conv;
22213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22214         this_ptr_conv.is_owned = false;
22215         LDKThirtyTwoBytes val_ref;
22216         CHECK((*env)->GetArrayLength(env, val) == 32);
22217         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22218         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
22219 }
22220
22221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
22222         LDKHTLCOutputInCommitment this_ptr_conv;
22223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22224         this_ptr_conv.is_owned = false;
22225         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
22226         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
22227         uint64_t ret_ref = (uint64_t)ret_copy;
22228         return ret_ref;
22229 }
22230
22231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22232         LDKHTLCOutputInCommitment this_ptr_conv;
22233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22234         this_ptr_conv.is_owned = false;
22235         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
22236         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
22237 }
22238
22239 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) {
22240         LDKThirtyTwoBytes payment_hash_arg_ref;
22241         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
22242         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
22243         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
22244         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
22245         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22246         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22247         uint64_t ret_ref = (uint64_t)ret_var.inner;
22248         if (ret_var.is_owned) {
22249                 ret_ref |= 1;
22250         }
22251         return ret_ref;
22252 }
22253
22254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22255         LDKHTLCOutputInCommitment orig_conv;
22256         orig_conv.inner = (void*)(orig & (~1));
22257         orig_conv.is_owned = false;
22258         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
22259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22261         uint64_t ret_ref = (uint64_t)ret_var.inner;
22262         if (ret_var.is_owned) {
22263                 ret_ref |= 1;
22264         }
22265         return ret_ref;
22266 }
22267
22268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
22269         LDKHTLCOutputInCommitment obj_conv;
22270         obj_conv.inner = (void*)(obj & (~1));
22271         obj_conv.is_owned = false;
22272         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
22273         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22274         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22275         CVec_u8Z_free(ret_var);
22276         return ret_arr;
22277 }
22278
22279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22280         LDKu8slice ser_ref;
22281         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22282         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22283         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
22284         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
22285         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22286         return (uint64_t)ret_conv;
22287 }
22288
22289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
22290         LDKHTLCOutputInCommitment htlc_conv;
22291         htlc_conv.inner = (void*)(htlc & (~1));
22292         htlc_conv.is_owned = false;
22293         LDKTxCreationKeys keys_conv;
22294         keys_conv.inner = (void*)(keys & (~1));
22295         keys_conv.is_owned = false;
22296         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
22297         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22298         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22299         CVec_u8Z_free(ret_var);
22300         return ret_arr;
22301 }
22302
22303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
22304         LDKPublicKey broadcaster_ref;
22305         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
22306         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
22307         LDKPublicKey countersignatory_ref;
22308         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
22309         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
22310         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
22311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22313         CVec_u8Z_free(ret_var);
22314         return ret_arr;
22315 }
22316
22317 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) {
22318         unsigned char commitment_txid_arr[32];
22319         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
22320         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
22321         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
22322         LDKHTLCOutputInCommitment htlc_conv;
22323         htlc_conv.inner = (void*)(htlc & (~1));
22324         htlc_conv.is_owned = false;
22325         LDKPublicKey broadcaster_delayed_payment_key_ref;
22326         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22327         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22328         LDKPublicKey revocation_key_ref;
22329         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22330         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22331         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
22332         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22333         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22334         Transaction_free(ret_var);
22335         return ret_arr;
22336 }
22337
22338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22339         LDKChannelTransactionParameters this_obj_conv;
22340         this_obj_conv.inner = (void*)(this_obj & (~1));
22341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22342         ChannelTransactionParameters_free(this_obj_conv);
22343 }
22344
22345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22346         LDKChannelTransactionParameters this_ptr_conv;
22347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22348         this_ptr_conv.is_owned = false;
22349         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
22350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22352         uint64_t ret_ref = (uint64_t)ret_var.inner;
22353         if (ret_var.is_owned) {
22354                 ret_ref |= 1;
22355         }
22356         return ret_ref;
22357 }
22358
22359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22360         LDKChannelTransactionParameters this_ptr_conv;
22361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22362         this_ptr_conv.is_owned = false;
22363         LDKChannelPublicKeys val_conv;
22364         val_conv.inner = (void*)(val & (~1));
22365         val_conv.is_owned = (val & 1) || (val == 0);
22366         val_conv = ChannelPublicKeys_clone(&val_conv);
22367         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
22368 }
22369
22370 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22371         LDKChannelTransactionParameters this_ptr_conv;
22372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22373         this_ptr_conv.is_owned = false;
22374         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
22375         return ret_val;
22376 }
22377
22378 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) {
22379         LDKChannelTransactionParameters this_ptr_conv;
22380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22381         this_ptr_conv.is_owned = false;
22382         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
22383 }
22384
22385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
22386         LDKChannelTransactionParameters this_ptr_conv;
22387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22388         this_ptr_conv.is_owned = false;
22389         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
22390         return ret_val;
22391 }
22392
22393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22394         LDKChannelTransactionParameters this_ptr_conv;
22395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22396         this_ptr_conv.is_owned = false;
22397         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
22398 }
22399
22400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
22401         LDKChannelTransactionParameters this_ptr_conv;
22402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22403         this_ptr_conv.is_owned = false;
22404         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
22405         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22406         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22407         uint64_t ret_ref = (uint64_t)ret_var.inner;
22408         if (ret_var.is_owned) {
22409                 ret_ref |= 1;
22410         }
22411         return ret_ref;
22412 }
22413
22414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22415         LDKChannelTransactionParameters this_ptr_conv;
22416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22417         this_ptr_conv.is_owned = false;
22418         LDKCounterpartyChannelTransactionParameters val_conv;
22419         val_conv.inner = (void*)(val & (~1));
22420         val_conv.is_owned = (val & 1) || (val == 0);
22421         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
22422         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
22423 }
22424
22425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22426         LDKChannelTransactionParameters this_ptr_conv;
22427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22428         this_ptr_conv.is_owned = false;
22429         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
22430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22432         uint64_t ret_ref = (uint64_t)ret_var.inner;
22433         if (ret_var.is_owned) {
22434                 ret_ref |= 1;
22435         }
22436         return ret_ref;
22437 }
22438
22439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22440         LDKChannelTransactionParameters this_ptr_conv;
22441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22442         this_ptr_conv.is_owned = false;
22443         LDKOutPoint val_conv;
22444         val_conv.inner = (void*)(val & (~1));
22445         val_conv.is_owned = (val & 1) || (val == 0);
22446         val_conv = OutPoint_clone(&val_conv);
22447         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
22448 }
22449
22450 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) {
22451         LDKChannelPublicKeys holder_pubkeys_arg_conv;
22452         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
22453         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
22454         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
22455         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
22456         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
22457         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
22458         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
22459         LDKOutPoint funding_outpoint_arg_conv;
22460         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
22461         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
22462         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
22463         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);
22464         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22465         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22466         uint64_t ret_ref = (uint64_t)ret_var.inner;
22467         if (ret_var.is_owned) {
22468                 ret_ref |= 1;
22469         }
22470         return ret_ref;
22471 }
22472
22473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22474         LDKChannelTransactionParameters orig_conv;
22475         orig_conv.inner = (void*)(orig & (~1));
22476         orig_conv.is_owned = false;
22477         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
22478         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22479         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22480         uint64_t ret_ref = (uint64_t)ret_var.inner;
22481         if (ret_var.is_owned) {
22482                 ret_ref |= 1;
22483         }
22484         return ret_ref;
22485 }
22486
22487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22488         LDKCounterpartyChannelTransactionParameters this_obj_conv;
22489         this_obj_conv.inner = (void*)(this_obj & (~1));
22490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22491         CounterpartyChannelTransactionParameters_free(this_obj_conv);
22492 }
22493
22494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22495         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22497         this_ptr_conv.is_owned = false;
22498         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
22499         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22500         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22501         uint64_t ret_ref = (uint64_t)ret_var.inner;
22502         if (ret_var.is_owned) {
22503                 ret_ref |= 1;
22504         }
22505         return ret_ref;
22506 }
22507
22508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22509         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22511         this_ptr_conv.is_owned = false;
22512         LDKChannelPublicKeys val_conv;
22513         val_conv.inner = (void*)(val & (~1));
22514         val_conv.is_owned = (val & 1) || (val == 0);
22515         val_conv = ChannelPublicKeys_clone(&val_conv);
22516         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
22517 }
22518
22519 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22520         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22522         this_ptr_conv.is_owned = false;
22523         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
22524         return ret_val;
22525 }
22526
22527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22528         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22530         this_ptr_conv.is_owned = false;
22531         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
22532 }
22533
22534 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) {
22535         LDKChannelPublicKeys pubkeys_arg_conv;
22536         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
22537         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
22538         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
22539         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
22540         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22541         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22542         uint64_t ret_ref = (uint64_t)ret_var.inner;
22543         if (ret_var.is_owned) {
22544                 ret_ref |= 1;
22545         }
22546         return ret_ref;
22547 }
22548
22549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22550         LDKCounterpartyChannelTransactionParameters orig_conv;
22551         orig_conv.inner = (void*)(orig & (~1));
22552         orig_conv.is_owned = false;
22553         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
22554         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22555         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22556         uint64_t ret_ref = (uint64_t)ret_var.inner;
22557         if (ret_var.is_owned) {
22558                 ret_ref |= 1;
22559         }
22560         return ret_ref;
22561 }
22562
22563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
22564         LDKChannelTransactionParameters this_arg_conv;
22565         this_arg_conv.inner = (void*)(this_arg & (~1));
22566         this_arg_conv.is_owned = false;
22567         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
22568         return ret_val;
22569 }
22570
22571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
22572         LDKChannelTransactionParameters this_arg_conv;
22573         this_arg_conv.inner = (void*)(this_arg & (~1));
22574         this_arg_conv.is_owned = false;
22575         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
22576         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22577         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22578         uint64_t ret_ref = (uint64_t)ret_var.inner;
22579         if (ret_var.is_owned) {
22580                 ret_ref |= 1;
22581         }
22582         return ret_ref;
22583 }
22584
22585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
22586         LDKChannelTransactionParameters this_arg_conv;
22587         this_arg_conv.inner = (void*)(this_arg & (~1));
22588         this_arg_conv.is_owned = false;
22589         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
22590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22592         uint64_t ret_ref = (uint64_t)ret_var.inner;
22593         if (ret_var.is_owned) {
22594                 ret_ref |= 1;
22595         }
22596         return ret_ref;
22597 }
22598
22599 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
22600         LDKCounterpartyChannelTransactionParameters obj_conv;
22601         obj_conv.inner = (void*)(obj & (~1));
22602         obj_conv.is_owned = false;
22603         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
22604         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22605         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22606         CVec_u8Z_free(ret_var);
22607         return ret_arr;
22608 }
22609
22610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22611         LDKu8slice ser_ref;
22612         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22613         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22614         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
22615         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
22616         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22617         return (uint64_t)ret_conv;
22618 }
22619
22620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
22621         LDKChannelTransactionParameters obj_conv;
22622         obj_conv.inner = (void*)(obj & (~1));
22623         obj_conv.is_owned = false;
22624         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
22625         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22626         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22627         CVec_u8Z_free(ret_var);
22628         return ret_arr;
22629 }
22630
22631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22632         LDKu8slice ser_ref;
22633         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22634         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22635         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
22636         *ret_conv = ChannelTransactionParameters_read(ser_ref);
22637         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22638         return (uint64_t)ret_conv;
22639 }
22640
22641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22642         LDKDirectedChannelTransactionParameters this_obj_conv;
22643         this_obj_conv.inner = (void*)(this_obj & (~1));
22644         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22645         DirectedChannelTransactionParameters_free(this_obj_conv);
22646 }
22647
22648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
22649         LDKDirectedChannelTransactionParameters this_arg_conv;
22650         this_arg_conv.inner = (void*)(this_arg & (~1));
22651         this_arg_conv.is_owned = false;
22652         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
22653         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22654         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22655         uint64_t ret_ref = (uint64_t)ret_var.inner;
22656         if (ret_var.is_owned) {
22657                 ret_ref |= 1;
22658         }
22659         return ret_ref;
22660 }
22661
22662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
22663         LDKDirectedChannelTransactionParameters this_arg_conv;
22664         this_arg_conv.inner = (void*)(this_arg & (~1));
22665         this_arg_conv.is_owned = false;
22666         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
22667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22669         uint64_t ret_ref = (uint64_t)ret_var.inner;
22670         if (ret_var.is_owned) {
22671                 ret_ref |= 1;
22672         }
22673         return ret_ref;
22674 }
22675
22676 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
22677         LDKDirectedChannelTransactionParameters this_arg_conv;
22678         this_arg_conv.inner = (void*)(this_arg & (~1));
22679         this_arg_conv.is_owned = false;
22680         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
22681         return ret_val;
22682 }
22683
22684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
22685         LDKDirectedChannelTransactionParameters this_arg_conv;
22686         this_arg_conv.inner = (void*)(this_arg & (~1));
22687         this_arg_conv.is_owned = false;
22688         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
22689         return ret_val;
22690 }
22691
22692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
22693         LDKDirectedChannelTransactionParameters this_arg_conv;
22694         this_arg_conv.inner = (void*)(this_arg & (~1));
22695         this_arg_conv.is_owned = false;
22696         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
22697         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22698         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22699         uint64_t ret_ref = (uint64_t)ret_var.inner;
22700         if (ret_var.is_owned) {
22701                 ret_ref |= 1;
22702         }
22703         return ret_ref;
22704 }
22705
22706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22707         LDKHolderCommitmentTransaction this_obj_conv;
22708         this_obj_conv.inner = (void*)(this_obj & (~1));
22709         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22710         HolderCommitmentTransaction_free(this_obj_conv);
22711 }
22712
22713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
22714         LDKHolderCommitmentTransaction this_ptr_conv;
22715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22716         this_ptr_conv.is_owned = false;
22717         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22718         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
22719         return ret_arr;
22720 }
22721
22722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22723         LDKHolderCommitmentTransaction this_ptr_conv;
22724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22725         this_ptr_conv.is_owned = false;
22726         LDKSignature val_ref;
22727         CHECK((*env)->GetArrayLength(env, val) == 64);
22728         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22729         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
22730 }
22731
22732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
22733         LDKHolderCommitmentTransaction this_ptr_conv;
22734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22735         this_ptr_conv.is_owned = false;
22736         LDKCVec_SignatureZ val_constr;
22737         val_constr.datalen = (*env)->GetArrayLength(env, val);
22738         if (val_constr.datalen > 0)
22739                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22740         else
22741                 val_constr.data = NULL;
22742         for (size_t i = 0; i < val_constr.datalen; i++) {
22743                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
22744                 LDKSignature val_conv_8_ref;
22745                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
22746                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
22747                 val_constr.data[i] = val_conv_8_ref;
22748         }
22749         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
22750 }
22751
22752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22753         LDKHolderCommitmentTransaction orig_conv;
22754         orig_conv.inner = (void*)(orig & (~1));
22755         orig_conv.is_owned = false;
22756         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
22757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22759         uint64_t ret_ref = (uint64_t)ret_var.inner;
22760         if (ret_var.is_owned) {
22761                 ret_ref |= 1;
22762         }
22763         return ret_ref;
22764 }
22765
22766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22767         LDKHolderCommitmentTransaction obj_conv;
22768         obj_conv.inner = (void*)(obj & (~1));
22769         obj_conv.is_owned = false;
22770         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
22771         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22772         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22773         CVec_u8Z_free(ret_var);
22774         return ret_arr;
22775 }
22776
22777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22778         LDKu8slice ser_ref;
22779         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22780         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22781         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
22782         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
22783         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22784         return (uint64_t)ret_conv;
22785 }
22786
22787 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) {
22788         LDKCommitmentTransaction commitment_tx_conv;
22789         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
22790         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
22791         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
22792         LDKSignature counterparty_sig_ref;
22793         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
22794         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
22795         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
22796         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
22797         if (counterparty_htlc_sigs_constr.datalen > 0)
22798                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22799         else
22800                 counterparty_htlc_sigs_constr.data = NULL;
22801         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
22802                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
22803                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
22804                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
22805                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
22806                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
22807         }
22808         LDKPublicKey holder_funding_key_ref;
22809         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
22810         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
22811         LDKPublicKey counterparty_funding_key_ref;
22812         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
22813         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
22814         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22815         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22816         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22817         uint64_t ret_ref = (uint64_t)ret_var.inner;
22818         if (ret_var.is_owned) {
22819                 ret_ref |= 1;
22820         }
22821         return ret_ref;
22822 }
22823
22824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22825         LDKBuiltCommitmentTransaction this_obj_conv;
22826         this_obj_conv.inner = (void*)(this_obj & (~1));
22827         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22828         BuiltCommitmentTransaction_free(this_obj_conv);
22829 }
22830
22831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
22832         LDKBuiltCommitmentTransaction this_ptr_conv;
22833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22834         this_ptr_conv.is_owned = false;
22835         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22836         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22837         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22838         Transaction_free(ret_var);
22839         return ret_arr;
22840 }
22841
22842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22843         LDKBuiltCommitmentTransaction this_ptr_conv;
22844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22845         this_ptr_conv.is_owned = false;
22846         LDKTransaction val_ref;
22847         val_ref.datalen = (*env)->GetArrayLength(env, val);
22848         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22849         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
22850         val_ref.data_is_owned = true;
22851         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22852 }
22853
22854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22855         LDKBuiltCommitmentTransaction this_ptr_conv;
22856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22857         this_ptr_conv.is_owned = false;
22858         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22859         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
22860         return ret_arr;
22861 }
22862
22863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22864         LDKBuiltCommitmentTransaction this_ptr_conv;
22865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22866         this_ptr_conv.is_owned = false;
22867         LDKThirtyTwoBytes val_ref;
22868         CHECK((*env)->GetArrayLength(env, val) == 32);
22869         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22870         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22871 }
22872
22873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
22874         LDKTransaction transaction_arg_ref;
22875         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
22876         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22877         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
22878         transaction_arg_ref.data_is_owned = true;
22879         LDKThirtyTwoBytes txid_arg_ref;
22880         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22881         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22882         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22883         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22884         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22885         uint64_t ret_ref = (uint64_t)ret_var.inner;
22886         if (ret_var.is_owned) {
22887                 ret_ref |= 1;
22888         }
22889         return ret_ref;
22890 }
22891
22892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22893         LDKBuiltCommitmentTransaction orig_conv;
22894         orig_conv.inner = (void*)(orig & (~1));
22895         orig_conv.is_owned = false;
22896         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22899         uint64_t ret_ref = (uint64_t)ret_var.inner;
22900         if (ret_var.is_owned) {
22901                 ret_ref |= 1;
22902         }
22903         return ret_ref;
22904 }
22905
22906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22907         LDKBuiltCommitmentTransaction obj_conv;
22908         obj_conv.inner = (void*)(obj & (~1));
22909         obj_conv.is_owned = false;
22910         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22911         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22912         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22913         CVec_u8Z_free(ret_var);
22914         return ret_arr;
22915 }
22916
22917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22918         LDKu8slice ser_ref;
22919         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22920         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22921         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22922         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22923         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22924         return (uint64_t)ret_conv;
22925 }
22926
22927 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) {
22928         LDKBuiltCommitmentTransaction this_arg_conv;
22929         this_arg_conv.inner = (void*)(this_arg & (~1));
22930         this_arg_conv.is_owned = false;
22931         LDKu8slice funding_redeemscript_ref;
22932         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22933         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22934         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
22936         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22937         return ret_arr;
22938 }
22939
22940 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) {
22941         LDKBuiltCommitmentTransaction this_arg_conv;
22942         this_arg_conv.inner = (void*)(this_arg & (~1));
22943         this_arg_conv.is_owned = false;
22944         unsigned char funding_key_arr[32];
22945         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
22946         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
22947         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22948         LDKu8slice funding_redeemscript_ref;
22949         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22950         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22951         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
22953         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22954         return ret_arr;
22955 }
22956
22957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22958         LDKCommitmentTransaction this_obj_conv;
22959         this_obj_conv.inner = (void*)(this_obj & (~1));
22960         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22961         CommitmentTransaction_free(this_obj_conv);
22962 }
22963
22964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22965         LDKCommitmentTransaction orig_conv;
22966         orig_conv.inner = (void*)(orig & (~1));
22967         orig_conv.is_owned = false;
22968         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22971         uint64_t ret_ref = (uint64_t)ret_var.inner;
22972         if (ret_var.is_owned) {
22973                 ret_ref |= 1;
22974         }
22975         return ret_ref;
22976 }
22977
22978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22979         LDKCommitmentTransaction obj_conv;
22980         obj_conv.inner = (void*)(obj & (~1));
22981         obj_conv.is_owned = false;
22982         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22983         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22984         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22985         CVec_u8Z_free(ret_var);
22986         return ret_arr;
22987 }
22988
22989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22990         LDKu8slice ser_ref;
22991         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22992         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22993         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22994         *ret_conv = CommitmentTransaction_read(ser_ref);
22995         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22996         return (uint64_t)ret_conv;
22997 }
22998
22999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
23000         LDKCommitmentTransaction this_arg_conv;
23001         this_arg_conv.inner = (void*)(this_arg & (~1));
23002         this_arg_conv.is_owned = false;
23003         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
23004         return ret_val;
23005 }
23006
23007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23008         LDKCommitmentTransaction this_arg_conv;
23009         this_arg_conv.inner = (void*)(this_arg & (~1));
23010         this_arg_conv.is_owned = false;
23011         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
23012         return ret_val;
23013 }
23014
23015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23016         LDKCommitmentTransaction this_arg_conv;
23017         this_arg_conv.inner = (void*)(this_arg & (~1));
23018         this_arg_conv.is_owned = false;
23019         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
23020         return ret_val;
23021 }
23022
23023 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
23024         LDKCommitmentTransaction this_arg_conv;
23025         this_arg_conv.inner = (void*)(this_arg & (~1));
23026         this_arg_conv.is_owned = false;
23027         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
23028         return ret_val;
23029 }
23030
23031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
23032         LDKCommitmentTransaction this_arg_conv;
23033         this_arg_conv.inner = (void*)(this_arg & (~1));
23034         this_arg_conv.is_owned = false;
23035         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
23036         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23037         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23038         uint64_t ret_ref = (uint64_t)ret_var.inner;
23039         if (ret_var.is_owned) {
23040                 ret_ref |= 1;
23041         }
23042         return ret_ref;
23043 }
23044
23045 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) {
23046         LDKCommitmentTransaction this_arg_conv;
23047         this_arg_conv.inner = (void*)(this_arg & (~1));
23048         this_arg_conv.is_owned = false;
23049         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23050         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23051         channel_parameters_conv.is_owned = false;
23052         LDKChannelPublicKeys broadcaster_keys_conv;
23053         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
23054         broadcaster_keys_conv.is_owned = false;
23055         LDKChannelPublicKeys countersignatory_keys_conv;
23056         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
23057         countersignatory_keys_conv.is_owned = false;
23058         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
23059         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
23060         return (uint64_t)ret_conv;
23061 }
23062
23063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23064         LDKTrustedCommitmentTransaction this_obj_conv;
23065         this_obj_conv.inner = (void*)(this_obj & (~1));
23066         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23067         TrustedCommitmentTransaction_free(this_obj_conv);
23068 }
23069
23070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
23071         LDKTrustedCommitmentTransaction this_arg_conv;
23072         this_arg_conv.inner = (void*)(this_arg & (~1));
23073         this_arg_conv.is_owned = false;
23074         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23075         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
23076         return ret_arr;
23077 }
23078
23079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
23080         LDKTrustedCommitmentTransaction this_arg_conv;
23081         this_arg_conv.inner = (void*)(this_arg & (~1));
23082         this_arg_conv.is_owned = false;
23083         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
23084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23086         uint64_t ret_ref = (uint64_t)ret_var.inner;
23087         if (ret_var.is_owned) {
23088                 ret_ref |= 1;
23089         }
23090         return ret_ref;
23091 }
23092
23093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
23094         LDKTrustedCommitmentTransaction this_arg_conv;
23095         this_arg_conv.inner = (void*)(this_arg & (~1));
23096         this_arg_conv.is_owned = false;
23097         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
23098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23100         uint64_t ret_ref = (uint64_t)ret_var.inner;
23101         if (ret_var.is_owned) {
23102                 ret_ref |= 1;
23103         }
23104         return ret_ref;
23105 }
23106
23107 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) {
23108         LDKTrustedCommitmentTransaction this_arg_conv;
23109         this_arg_conv.inner = (void*)(this_arg & (~1));
23110         this_arg_conv.is_owned = false;
23111         unsigned char htlc_base_key_arr[32];
23112         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
23113         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
23114         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
23115         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23116         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23117         channel_parameters_conv.is_owned = false;
23118         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
23119         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
23120         return (uint64_t)ret_conv;
23121 }
23122
23123 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) {
23124         LDKPublicKey broadcaster_payment_basepoint_ref;
23125         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
23126         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
23127         LDKPublicKey countersignatory_payment_basepoint_ref;
23128         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
23129         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
23130         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
23131         return ret_val;
23132 }
23133
23134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23135         LDKInitFeatures a_conv;
23136         a_conv.inner = (void*)(a & (~1));
23137         a_conv.is_owned = false;
23138         LDKInitFeatures b_conv;
23139         b_conv.inner = (void*)(b & (~1));
23140         b_conv.is_owned = false;
23141         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
23142         return ret_val;
23143 }
23144
23145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23146         LDKNodeFeatures a_conv;
23147         a_conv.inner = (void*)(a & (~1));
23148         a_conv.is_owned = false;
23149         LDKNodeFeatures b_conv;
23150         b_conv.inner = (void*)(b & (~1));
23151         b_conv.is_owned = false;
23152         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
23153         return ret_val;
23154 }
23155
23156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23157         LDKChannelFeatures a_conv;
23158         a_conv.inner = (void*)(a & (~1));
23159         a_conv.is_owned = false;
23160         LDKChannelFeatures b_conv;
23161         b_conv.inner = (void*)(b & (~1));
23162         b_conv.is_owned = false;
23163         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
23164         return ret_val;
23165 }
23166
23167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23168         LDKInvoiceFeatures a_conv;
23169         a_conv.inner = (void*)(a & (~1));
23170         a_conv.is_owned = false;
23171         LDKInvoiceFeatures b_conv;
23172         b_conv.inner = (void*)(b & (~1));
23173         b_conv.is_owned = false;
23174         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
23175         return ret_val;
23176 }
23177
23178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23179         LDKInitFeatures orig_conv;
23180         orig_conv.inner = (void*)(orig & (~1));
23181         orig_conv.is_owned = false;
23182         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
23183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23185         uint64_t ret_ref = (uint64_t)ret_var.inner;
23186         if (ret_var.is_owned) {
23187                 ret_ref |= 1;
23188         }
23189         return ret_ref;
23190 }
23191
23192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23193         LDKNodeFeatures orig_conv;
23194         orig_conv.inner = (void*)(orig & (~1));
23195         orig_conv.is_owned = false;
23196         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
23197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23199         uint64_t ret_ref = (uint64_t)ret_var.inner;
23200         if (ret_var.is_owned) {
23201                 ret_ref |= 1;
23202         }
23203         return ret_ref;
23204 }
23205
23206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23207         LDKChannelFeatures orig_conv;
23208         orig_conv.inner = (void*)(orig & (~1));
23209         orig_conv.is_owned = false;
23210         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
23211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23213         uint64_t ret_ref = (uint64_t)ret_var.inner;
23214         if (ret_var.is_owned) {
23215                 ret_ref |= 1;
23216         }
23217         return ret_ref;
23218 }
23219
23220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23221         LDKInvoiceFeatures orig_conv;
23222         orig_conv.inner = (void*)(orig & (~1));
23223         orig_conv.is_owned = false;
23224         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
23225         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23226         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23227         uint64_t ret_ref = (uint64_t)ret_var.inner;
23228         if (ret_var.is_owned) {
23229                 ret_ref |= 1;
23230         }
23231         return ret_ref;
23232 }
23233
23234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23235         LDKInitFeatures this_obj_conv;
23236         this_obj_conv.inner = (void*)(this_obj & (~1));
23237         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23238         InitFeatures_free(this_obj_conv);
23239 }
23240
23241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23242         LDKNodeFeatures this_obj_conv;
23243         this_obj_conv.inner = (void*)(this_obj & (~1));
23244         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23245         NodeFeatures_free(this_obj_conv);
23246 }
23247
23248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23249         LDKChannelFeatures this_obj_conv;
23250         this_obj_conv.inner = (void*)(this_obj & (~1));
23251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23252         ChannelFeatures_free(this_obj_conv);
23253 }
23254
23255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23256         LDKInvoiceFeatures this_obj_conv;
23257         this_obj_conv.inner = (void*)(this_obj & (~1));
23258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23259         InvoiceFeatures_free(this_obj_conv);
23260 }
23261
23262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
23263         LDKInitFeatures ret_var = InitFeatures_empty();
23264         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23265         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23266         uint64_t ret_ref = (uint64_t)ret_var.inner;
23267         if (ret_var.is_owned) {
23268                 ret_ref |= 1;
23269         }
23270         return ret_ref;
23271 }
23272
23273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
23274         LDKInitFeatures ret_var = InitFeatures_known();
23275         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23276         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23277         uint64_t ret_ref = (uint64_t)ret_var.inner;
23278         if (ret_var.is_owned) {
23279                 ret_ref |= 1;
23280         }
23281         return ret_ref;
23282 }
23283
23284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
23285         LDKNodeFeatures ret_var = NodeFeatures_empty();
23286         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23287         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23288         uint64_t ret_ref = (uint64_t)ret_var.inner;
23289         if (ret_var.is_owned) {
23290                 ret_ref |= 1;
23291         }
23292         return ret_ref;
23293 }
23294
23295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
23296         LDKNodeFeatures ret_var = NodeFeatures_known();
23297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23299         uint64_t ret_ref = (uint64_t)ret_var.inner;
23300         if (ret_var.is_owned) {
23301                 ret_ref |= 1;
23302         }
23303         return ret_ref;
23304 }
23305
23306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
23307         LDKChannelFeatures ret_var = ChannelFeatures_empty();
23308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23310         uint64_t ret_ref = (uint64_t)ret_var.inner;
23311         if (ret_var.is_owned) {
23312                 ret_ref |= 1;
23313         }
23314         return ret_ref;
23315 }
23316
23317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
23318         LDKChannelFeatures ret_var = ChannelFeatures_known();
23319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23321         uint64_t ret_ref = (uint64_t)ret_var.inner;
23322         if (ret_var.is_owned) {
23323                 ret_ref |= 1;
23324         }
23325         return ret_ref;
23326 }
23327
23328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
23329         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
23330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23332         uint64_t ret_ref = (uint64_t)ret_var.inner;
23333         if (ret_var.is_owned) {
23334                 ret_ref |= 1;
23335         }
23336         return ret_ref;
23337 }
23338
23339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
23340         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
23341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23343         uint64_t ret_ref = (uint64_t)ret_var.inner;
23344         if (ret_var.is_owned) {
23345                 ret_ref |= 1;
23346         }
23347         return ret_ref;
23348 }
23349
23350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23351         LDKInitFeatures this_arg_conv;
23352         this_arg_conv.inner = (void*)(this_arg & (~1));
23353         this_arg_conv.is_owned = false;
23354         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
23355         return ret_val;
23356 }
23357
23358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23359         LDKNodeFeatures this_arg_conv;
23360         this_arg_conv.inner = (void*)(this_arg & (~1));
23361         this_arg_conv.is_owned = false;
23362         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
23363         return ret_val;
23364 }
23365
23366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23367         LDKInvoiceFeatures this_arg_conv;
23368         this_arg_conv.inner = (void*)(this_arg & (~1));
23369         this_arg_conv.is_owned = false;
23370         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
23371         return ret_val;
23372 }
23373
23374 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23375         LDKInitFeatures obj_conv;
23376         obj_conv.inner = (void*)(obj & (~1));
23377         obj_conv.is_owned = false;
23378         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
23379         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23380         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23381         CVec_u8Z_free(ret_var);
23382         return ret_arr;
23383 }
23384
23385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23386         LDKNodeFeatures obj_conv;
23387         obj_conv.inner = (void*)(obj & (~1));
23388         obj_conv.is_owned = false;
23389         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
23390         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23391         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23392         CVec_u8Z_free(ret_var);
23393         return ret_arr;
23394 }
23395
23396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23397         LDKChannelFeatures obj_conv;
23398         obj_conv.inner = (void*)(obj & (~1));
23399         obj_conv.is_owned = false;
23400         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
23401         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23402         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23403         CVec_u8Z_free(ret_var);
23404         return ret_arr;
23405 }
23406
23407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23408         LDKInvoiceFeatures obj_conv;
23409         obj_conv.inner = (void*)(obj & (~1));
23410         obj_conv.is_owned = false;
23411         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
23412         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23413         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23414         CVec_u8Z_free(ret_var);
23415         return ret_arr;
23416 }
23417
23418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23419         LDKu8slice ser_ref;
23420         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23421         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23422         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
23423         *ret_conv = InitFeatures_read(ser_ref);
23424         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23425         return (uint64_t)ret_conv;
23426 }
23427
23428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23429         LDKu8slice ser_ref;
23430         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23431         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23432         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
23433         *ret_conv = NodeFeatures_read(ser_ref);
23434         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23435         return (uint64_t)ret_conv;
23436 }
23437
23438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23439         LDKu8slice ser_ref;
23440         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23441         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23442         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
23443         *ret_conv = ChannelFeatures_read(ser_ref);
23444         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23445         return (uint64_t)ret_conv;
23446 }
23447
23448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23449         LDKu8slice ser_ref;
23450         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23451         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23452         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
23453         *ret_conv = InvoiceFeatures_read(ser_ref);
23454         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23455         return (uint64_t)ret_conv;
23456 }
23457
23458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23459         LDKRouteHop this_obj_conv;
23460         this_obj_conv.inner = (void*)(this_obj & (~1));
23461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23462         RouteHop_free(this_obj_conv);
23463 }
23464
23465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23466         LDKRouteHop this_ptr_conv;
23467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23468         this_ptr_conv.is_owned = false;
23469         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
23471         return ret_arr;
23472 }
23473
23474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23475         LDKRouteHop this_ptr_conv;
23476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23477         this_ptr_conv.is_owned = false;
23478         LDKPublicKey val_ref;
23479         CHECK((*env)->GetArrayLength(env, val) == 33);
23480         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23481         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
23482 }
23483
23484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23485         LDKRouteHop this_ptr_conv;
23486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23487         this_ptr_conv.is_owned = false;
23488         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
23489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23491         uint64_t ret_ref = (uint64_t)ret_var.inner;
23492         if (ret_var.is_owned) {
23493                 ret_ref |= 1;
23494         }
23495         return ret_ref;
23496 }
23497
23498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23499         LDKRouteHop this_ptr_conv;
23500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23501         this_ptr_conv.is_owned = false;
23502         LDKNodeFeatures val_conv;
23503         val_conv.inner = (void*)(val & (~1));
23504         val_conv.is_owned = (val & 1) || (val == 0);
23505         val_conv = NodeFeatures_clone(&val_conv);
23506         RouteHop_set_node_features(&this_ptr_conv, val_conv);
23507 }
23508
23509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23510         LDKRouteHop this_ptr_conv;
23511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23512         this_ptr_conv.is_owned = false;
23513         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
23514         return ret_val;
23515 }
23516
23517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23518         LDKRouteHop this_ptr_conv;
23519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23520         this_ptr_conv.is_owned = false;
23521         RouteHop_set_short_channel_id(&this_ptr_conv, val);
23522 }
23523
23524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23525         LDKRouteHop this_ptr_conv;
23526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23527         this_ptr_conv.is_owned = false;
23528         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
23529         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23530         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23531         uint64_t ret_ref = (uint64_t)ret_var.inner;
23532         if (ret_var.is_owned) {
23533                 ret_ref |= 1;
23534         }
23535         return ret_ref;
23536 }
23537
23538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23539         LDKRouteHop this_ptr_conv;
23540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23541         this_ptr_conv.is_owned = false;
23542         LDKChannelFeatures val_conv;
23543         val_conv.inner = (void*)(val & (~1));
23544         val_conv.is_owned = (val & 1) || (val == 0);
23545         val_conv = ChannelFeatures_clone(&val_conv);
23546         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
23547 }
23548
23549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23550         LDKRouteHop this_ptr_conv;
23551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23552         this_ptr_conv.is_owned = false;
23553         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
23554         return ret_val;
23555 }
23556
23557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23558         LDKRouteHop this_ptr_conv;
23559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23560         this_ptr_conv.is_owned = false;
23561         RouteHop_set_fee_msat(&this_ptr_conv, val);
23562 }
23563
23564 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23565         LDKRouteHop this_ptr_conv;
23566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23567         this_ptr_conv.is_owned = false;
23568         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
23569         return ret_val;
23570 }
23571
23572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23573         LDKRouteHop this_ptr_conv;
23574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23575         this_ptr_conv.is_owned = false;
23576         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23577 }
23578
23579 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) {
23580         LDKPublicKey pubkey_arg_ref;
23581         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
23582         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
23583         LDKNodeFeatures node_features_arg_conv;
23584         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
23585         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
23586         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
23587         LDKChannelFeatures channel_features_arg_conv;
23588         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
23589         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
23590         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
23591         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);
23592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23594         uint64_t ret_ref = (uint64_t)ret_var.inner;
23595         if (ret_var.is_owned) {
23596                 ret_ref |= 1;
23597         }
23598         return ret_ref;
23599 }
23600
23601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23602         LDKRouteHop orig_conv;
23603         orig_conv.inner = (void*)(orig & (~1));
23604         orig_conv.is_owned = false;
23605         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
23606         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23607         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23608         uint64_t ret_ref = (uint64_t)ret_var.inner;
23609         if (ret_var.is_owned) {
23610                 ret_ref |= 1;
23611         }
23612         return ret_ref;
23613 }
23614
23615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
23616         LDKRouteHop obj_conv;
23617         obj_conv.inner = (void*)(obj & (~1));
23618         obj_conv.is_owned = false;
23619         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
23620         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23621         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23622         CVec_u8Z_free(ret_var);
23623         return ret_arr;
23624 }
23625
23626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23627         LDKu8slice ser_ref;
23628         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23629         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23630         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
23631         *ret_conv = RouteHop_read(ser_ref);
23632         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23633         return (uint64_t)ret_conv;
23634 }
23635
23636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23637         LDKRoute this_obj_conv;
23638         this_obj_conv.inner = (void*)(this_obj & (~1));
23639         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23640         Route_free(this_obj_conv);
23641 }
23642
23643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23644         LDKRoute this_ptr_conv;
23645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23646         this_ptr_conv.is_owned = false;
23647         LDKCVec_CVec_RouteHopZZ val_constr;
23648         val_constr.datalen = (*env)->GetArrayLength(env, val);
23649         if (val_constr.datalen > 0)
23650                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23651         else
23652                 val_constr.data = NULL;
23653         for (size_t m = 0; m < val_constr.datalen; m++) {
23654                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
23655                 LDKCVec_RouteHopZ val_conv_12_constr;
23656                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
23657                 if (val_conv_12_constr.datalen > 0)
23658                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23659                 else
23660                         val_conv_12_constr.data = NULL;
23661                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
23662                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
23663                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
23664                         LDKRouteHop val_conv_12_conv_10_conv;
23665                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
23666                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
23667                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
23668                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
23669                 }
23670                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
23671                 val_constr.data[m] = val_conv_12_constr;
23672         }
23673         Route_set_paths(&this_ptr_conv, val_constr);
23674 }
23675
23676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
23677         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
23678         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
23679         if (paths_arg_constr.datalen > 0)
23680                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23681         else
23682                 paths_arg_constr.data = NULL;
23683         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
23684                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
23685                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
23686                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
23687                 if (paths_arg_conv_12_constr.datalen > 0)
23688                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23689                 else
23690                         paths_arg_conv_12_constr.data = NULL;
23691                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
23692                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
23693                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
23694                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
23695                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
23696                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
23697                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
23698                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
23699                 }
23700                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
23701                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
23702         }
23703         LDKRoute ret_var = Route_new(paths_arg_constr);
23704         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23705         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23706         uint64_t ret_ref = (uint64_t)ret_var.inner;
23707         if (ret_var.is_owned) {
23708                 ret_ref |= 1;
23709         }
23710         return ret_ref;
23711 }
23712
23713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23714         LDKRoute orig_conv;
23715         orig_conv.inner = (void*)(orig & (~1));
23716         orig_conv.is_owned = false;
23717         LDKRoute ret_var = Route_clone(&orig_conv);
23718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23720         uint64_t ret_ref = (uint64_t)ret_var.inner;
23721         if (ret_var.is_owned) {
23722                 ret_ref |= 1;
23723         }
23724         return ret_ref;
23725 }
23726
23727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
23728         LDKRoute obj_conv;
23729         obj_conv.inner = (void*)(obj & (~1));
23730         obj_conv.is_owned = false;
23731         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
23732         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23733         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23734         CVec_u8Z_free(ret_var);
23735         return ret_arr;
23736 }
23737
23738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23739         LDKu8slice ser_ref;
23740         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23741         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23742         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
23743         *ret_conv = Route_read(ser_ref);
23744         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23745         return (uint64_t)ret_conv;
23746 }
23747
23748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23749         LDKRouteHint this_obj_conv;
23750         this_obj_conv.inner = (void*)(this_obj & (~1));
23751         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23752         RouteHint_free(this_obj_conv);
23753 }
23754
23755 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23756         LDKRouteHint a_conv;
23757         a_conv.inner = (void*)(a & (~1));
23758         a_conv.is_owned = false;
23759         LDKRouteHint b_conv;
23760         b_conv.inner = (void*)(b & (~1));
23761         b_conv.is_owned = false;
23762         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
23763         return ret_val;
23764 }
23765
23766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23767         LDKRouteHint orig_conv;
23768         orig_conv.inner = (void*)(orig & (~1));
23769         orig_conv.is_owned = false;
23770         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
23771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23773         uint64_t ret_ref = (uint64_t)ret_var.inner;
23774         if (ret_var.is_owned) {
23775                 ret_ref |= 1;
23776         }
23777         return ret_ref;
23778 }
23779
23780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23781         LDKRouteHintHop this_obj_conv;
23782         this_obj_conv.inner = (void*)(this_obj & (~1));
23783         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23784         RouteHintHop_free(this_obj_conv);
23785 }
23786
23787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23788         LDKRouteHintHop this_ptr_conv;
23789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23790         this_ptr_conv.is_owned = false;
23791         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
23793         return ret_arr;
23794 }
23795
23796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23797         LDKRouteHintHop this_ptr_conv;
23798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23799         this_ptr_conv.is_owned = false;
23800         LDKPublicKey val_ref;
23801         CHECK((*env)->GetArrayLength(env, val) == 33);
23802         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23803         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
23804 }
23805
23806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23807         LDKRouteHintHop this_ptr_conv;
23808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23809         this_ptr_conv.is_owned = false;
23810         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
23811         return ret_val;
23812 }
23813
23814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23815         LDKRouteHintHop this_ptr_conv;
23816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23817         this_ptr_conv.is_owned = false;
23818         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23819 }
23820
23821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23822         LDKRouteHintHop this_ptr_conv;
23823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23824         this_ptr_conv.is_owned = false;
23825         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23826         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23827         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23828         uint64_t ret_ref = (uint64_t)ret_var.inner;
23829         if (ret_var.is_owned) {
23830                 ret_ref |= 1;
23831         }
23832         return ret_ref;
23833 }
23834
23835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23836         LDKRouteHintHop this_ptr_conv;
23837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23838         this_ptr_conv.is_owned = false;
23839         LDKRoutingFees val_conv;
23840         val_conv.inner = (void*)(val & (~1));
23841         val_conv.is_owned = (val & 1) || (val == 0);
23842         val_conv = RoutingFees_clone(&val_conv);
23843         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23844 }
23845
23846 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23847         LDKRouteHintHop this_ptr_conv;
23848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23849         this_ptr_conv.is_owned = false;
23850         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23851         return ret_val;
23852 }
23853
23854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23855         LDKRouteHintHop this_ptr_conv;
23856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23857         this_ptr_conv.is_owned = false;
23858         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23859 }
23860
23861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23862         LDKRouteHintHop this_ptr_conv;
23863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23864         this_ptr_conv.is_owned = false;
23865         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23866         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23867         uint64_t ret_ref = (uint64_t)ret_copy;
23868         return ret_ref;
23869 }
23870
23871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23872         LDKRouteHintHop this_ptr_conv;
23873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23874         this_ptr_conv.is_owned = false;
23875         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23876         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23877 }
23878
23879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23880         LDKRouteHintHop this_ptr_conv;
23881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23882         this_ptr_conv.is_owned = false;
23883         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23884         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23885         uint64_t ret_ref = (uint64_t)ret_copy;
23886         return ret_ref;
23887 }
23888
23889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23890         LDKRouteHintHop this_ptr_conv;
23891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23892         this_ptr_conv.is_owned = false;
23893         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23894         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23895 }
23896
23897 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) {
23898         LDKPublicKey src_node_id_arg_ref;
23899         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
23900         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
23901         LDKRoutingFees fees_arg_conv;
23902         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23903         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23904         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23905         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23906         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23907         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);
23908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23910         uint64_t ret_ref = (uint64_t)ret_var.inner;
23911         if (ret_var.is_owned) {
23912                 ret_ref |= 1;
23913         }
23914         return ret_ref;
23915 }
23916
23917 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23918         LDKRouteHintHop a_conv;
23919         a_conv.inner = (void*)(a & (~1));
23920         a_conv.is_owned = false;
23921         LDKRouteHintHop b_conv;
23922         b_conv.inner = (void*)(b & (~1));
23923         b_conv.is_owned = false;
23924         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23925         return ret_val;
23926 }
23927
23928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23929         LDKRouteHintHop orig_conv;
23930         orig_conv.inner = (void*)(orig & (~1));
23931         orig_conv.is_owned = false;
23932         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23933         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23934         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23935         uint64_t ret_ref = (uint64_t)ret_var.inner;
23936         if (ret_var.is_owned) {
23937                 ret_ref |= 1;
23938         }
23939         return ret_ref;
23940 }
23941
23942 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) {
23943         LDKPublicKey our_node_id_ref;
23944         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23945         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23946         LDKNetworkGraph network_conv;
23947         network_conv.inner = (void*)(network & (~1));
23948         network_conv.is_owned = false;
23949         LDKPublicKey payee_ref;
23950         CHECK((*env)->GetArrayLength(env, payee) == 33);
23951         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
23952         LDKCVec_ChannelDetailsZ first_hops_constr;
23953         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
23954         if (first_hops_constr.datalen > 0)
23955                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23956         else
23957                 first_hops_constr.data = NULL;
23958         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
23959         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23960                 int64_t first_hops_conv_16 = first_hops_vals[q];
23961                 LDKChannelDetails first_hops_conv_16_conv;
23962                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23963                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23964                 first_hops_constr.data[q] = first_hops_conv_16_conv;
23965         }
23966         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
23967         LDKCVec_RouteHintZ last_hops_constr;
23968         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
23969         if (last_hops_constr.datalen > 0)
23970                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23971         else
23972                 last_hops_constr.data = NULL;
23973         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
23974         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23975                 int64_t last_hops_conv_11 = last_hops_vals[l];
23976                 LDKRouteHint last_hops_conv_11_conv;
23977                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23978                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23979                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23980                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23981         }
23982         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
23983         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23984         if (logger_conv.free == LDKLogger_JCalls_free) {
23985                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23986                 LDKLogger_JCalls_cloned(&logger_conv);
23987         }
23988         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23989         *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);
23990         FREE(first_hops_constr.data);
23991         return (uint64_t)ret_conv;
23992 }
23993
23994 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) {
23995         LDKPublicKey our_node_id_ref;
23996         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23997         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23998         LDKNetworkGraph network_conv;
23999         network_conv.inner = (void*)(network & (~1));
24000         network_conv.is_owned = false;
24001         LDKPublicKey payee_ref;
24002         CHECK((*env)->GetArrayLength(env, payee) == 33);
24003         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
24004         LDKInvoiceFeatures payee_features_conv;
24005         payee_features_conv.inner = (void*)(payee_features & (~1));
24006         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
24007         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
24008         LDKCVec_ChannelDetailsZ first_hops_constr;
24009         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
24010         if (first_hops_constr.datalen > 0)
24011                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24012         else
24013                 first_hops_constr.data = NULL;
24014         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
24015         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
24016                 int64_t first_hops_conv_16 = first_hops_vals[q];
24017                 LDKChannelDetails first_hops_conv_16_conv;
24018                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
24019                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
24020                 first_hops_constr.data[q] = first_hops_conv_16_conv;
24021         }
24022         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
24023         LDKCVec_RouteHintZ last_hops_constr;
24024         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
24025         if (last_hops_constr.datalen > 0)
24026                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
24027         else
24028                 last_hops_constr.data = NULL;
24029         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
24030         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
24031                 int64_t last_hops_conv_11 = last_hops_vals[l];
24032                 LDKRouteHint last_hops_conv_11_conv;
24033                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
24034                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
24035                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
24036                 last_hops_constr.data[l] = last_hops_conv_11_conv;
24037         }
24038         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
24039         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24040         if (logger_conv.free == LDKLogger_JCalls_free) {
24041                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24042                 LDKLogger_JCalls_cloned(&logger_conv);
24043         }
24044         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
24045         *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);
24046         FREE(first_hops_constr.data);
24047         return (uint64_t)ret_conv;
24048 }
24049
24050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24051         LDKNetworkGraph this_obj_conv;
24052         this_obj_conv.inner = (void*)(this_obj & (~1));
24053         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24054         NetworkGraph_free(this_obj_conv);
24055 }
24056
24057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24058         LDKNetworkGraph orig_conv;
24059         orig_conv.inner = (void*)(orig & (~1));
24060         orig_conv.is_owned = false;
24061         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
24062         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24063         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24064         uint64_t ret_ref = (uint64_t)ret_var.inner;
24065         if (ret_var.is_owned) {
24066                 ret_ref |= 1;
24067         }
24068         return ret_ref;
24069 }
24070
24071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24072         LDKLockedNetworkGraph this_obj_conv;
24073         this_obj_conv.inner = (void*)(this_obj & (~1));
24074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24075         LockedNetworkGraph_free(this_obj_conv);
24076 }
24077
24078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24079         LDKNetGraphMsgHandler this_obj_conv;
24080         this_obj_conv.inner = (void*)(this_obj & (~1));
24081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24082         NetGraphMsgHandler_free(this_obj_conv);
24083 }
24084
24085 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) {
24086         LDKThirtyTwoBytes genesis_hash_ref;
24087         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24088         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24089         LDKAccess *chain_access_conv_ptr = NULL;
24090         if (chain_access != 0) {
24091                 LDKAccess chain_access_conv;
24092                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24093                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24094                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24095                         LDKAccess_JCalls_cloned(&chain_access_conv);
24096                 }
24097                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24098                 *chain_access_conv_ptr = chain_access_conv;
24099         }
24100         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24101         if (logger_conv.free == LDKLogger_JCalls_free) {
24102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24103                 LDKLogger_JCalls_cloned(&logger_conv);
24104         }
24105         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
24106         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24107         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24108         uint64_t ret_ref = (uint64_t)ret_var.inner;
24109         if (ret_var.is_owned) {
24110                 ret_ref |= 1;
24111         }
24112         return ret_ref;
24113 }
24114
24115 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) {
24116         LDKAccess *chain_access_conv_ptr = NULL;
24117         if (chain_access != 0) {
24118                 LDKAccess chain_access_conv;
24119                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24120                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24121                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24122                         LDKAccess_JCalls_cloned(&chain_access_conv);
24123                 }
24124                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24125                 *chain_access_conv_ptr = chain_access_conv;
24126         }
24127         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24128         if (logger_conv.free == LDKLogger_JCalls_free) {
24129                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24130                 LDKLogger_JCalls_cloned(&logger_conv);
24131         }
24132         LDKNetworkGraph network_graph_conv;
24133         network_graph_conv.inner = (void*)(network_graph & (~1));
24134         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
24135         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
24136         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
24137         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24138         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24139         uint64_t ret_ref = (uint64_t)ret_var.inner;
24140         if (ret_var.is_owned) {
24141                 ret_ref |= 1;
24142         }
24143         return ret_ref;
24144 }
24145
24146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
24147         LDKNetGraphMsgHandler this_arg_conv;
24148         this_arg_conv.inner = (void*)(this_arg & (~1));
24149         this_arg_conv.is_owned = false;
24150         LDKAccess *chain_access_conv_ptr = NULL;
24151         if (chain_access != 0) {
24152                 LDKAccess chain_access_conv;
24153                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24154                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24155                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24156                         LDKAccess_JCalls_cloned(&chain_access_conv);
24157                 }
24158                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24159                 *chain_access_conv_ptr = chain_access_conv;
24160         }
24161         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
24162 }
24163
24164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
24165         LDKNetGraphMsgHandler this_arg_conv;
24166         this_arg_conv.inner = (void*)(this_arg & (~1));
24167         this_arg_conv.is_owned = false;
24168         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
24169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24171         uint64_t ret_ref = (uint64_t)ret_var.inner;
24172         if (ret_var.is_owned) {
24173                 ret_ref |= 1;
24174         }
24175         return ret_ref;
24176 }
24177
24178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
24179         LDKLockedNetworkGraph this_arg_conv;
24180         this_arg_conv.inner = (void*)(this_arg & (~1));
24181         this_arg_conv.is_owned = false;
24182         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
24183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24185         uint64_t ret_ref = (uint64_t)ret_var.inner;
24186         if (ret_var.is_owned) {
24187                 ret_ref |= 1;
24188         }
24189         return ret_ref;
24190 }
24191
24192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24193         LDKNetGraphMsgHandler this_arg_conv;
24194         this_arg_conv.inner = (void*)(this_arg & (~1));
24195         this_arg_conv.is_owned = false;
24196         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
24197         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
24198         return (uint64_t)ret;
24199 }
24200
24201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24202         LDKNetGraphMsgHandler this_arg_conv;
24203         this_arg_conv.inner = (void*)(this_arg & (~1));
24204         this_arg_conv.is_owned = false;
24205         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24206         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
24207         return (uint64_t)ret;
24208 }
24209
24210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24211         LDKDirectionalChannelInfo this_obj_conv;
24212         this_obj_conv.inner = (void*)(this_obj & (~1));
24213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24214         DirectionalChannelInfo_free(this_obj_conv);
24215 }
24216
24217 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
24218         LDKDirectionalChannelInfo this_ptr_conv;
24219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24220         this_ptr_conv.is_owned = false;
24221         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
24222         return ret_val;
24223 }
24224
24225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24226         LDKDirectionalChannelInfo this_ptr_conv;
24227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24228         this_ptr_conv.is_owned = false;
24229         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
24230 }
24231
24232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
24233         LDKDirectionalChannelInfo this_ptr_conv;
24234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24235         this_ptr_conv.is_owned = false;
24236         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
24237         return ret_val;
24238 }
24239
24240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24241         LDKDirectionalChannelInfo this_ptr_conv;
24242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24243         this_ptr_conv.is_owned = false;
24244         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
24245 }
24246
24247 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24248         LDKDirectionalChannelInfo this_ptr_conv;
24249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24250         this_ptr_conv.is_owned = false;
24251         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
24252         return ret_val;
24253 }
24254
24255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24256         LDKDirectionalChannelInfo this_ptr_conv;
24257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24258         this_ptr_conv.is_owned = false;
24259         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24260 }
24261
24262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24263         LDKDirectionalChannelInfo this_ptr_conv;
24264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24265         this_ptr_conv.is_owned = false;
24266         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
24267         return ret_val;
24268 }
24269
24270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24271         LDKDirectionalChannelInfo this_ptr_conv;
24272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24273         this_ptr_conv.is_owned = false;
24274         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
24275 }
24276
24277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24278         LDKDirectionalChannelInfo this_ptr_conv;
24279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24280         this_ptr_conv.is_owned = false;
24281         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24282         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
24283         uint64_t ret_ref = (uint64_t)ret_copy;
24284         return ret_ref;
24285 }
24286
24287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24288         LDKDirectionalChannelInfo this_ptr_conv;
24289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24290         this_ptr_conv.is_owned = false;
24291         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24292         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24293 }
24294
24295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24296         LDKDirectionalChannelInfo this_ptr_conv;
24297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24298         this_ptr_conv.is_owned = false;
24299         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24302         uint64_t ret_ref = (uint64_t)ret_var.inner;
24303         if (ret_var.is_owned) {
24304                 ret_ref |= 1;
24305         }
24306         return ret_ref;
24307 }
24308
24309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24310         LDKDirectionalChannelInfo this_ptr_conv;
24311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24312         this_ptr_conv.is_owned = false;
24313         LDKRoutingFees val_conv;
24314         val_conv.inner = (void*)(val & (~1));
24315         val_conv.is_owned = (val & 1) || (val == 0);
24316         val_conv = RoutingFees_clone(&val_conv);
24317         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24318 }
24319
24320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24321         LDKDirectionalChannelInfo this_ptr_conv;
24322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24323         this_ptr_conv.is_owned = false;
24324         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
24325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24327         uint64_t ret_ref = (uint64_t)ret_var.inner;
24328         if (ret_var.is_owned) {
24329                 ret_ref |= 1;
24330         }
24331         return ret_ref;
24332 }
24333
24334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24335         LDKDirectionalChannelInfo this_ptr_conv;
24336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24337         this_ptr_conv.is_owned = false;
24338         LDKChannelUpdate val_conv;
24339         val_conv.inner = (void*)(val & (~1));
24340         val_conv.is_owned = (val & 1) || (val == 0);
24341         val_conv = ChannelUpdate_clone(&val_conv);
24342         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24343 }
24344
24345 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) {
24346         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24347         LDKRoutingFees fees_arg_conv;
24348         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24349         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24350         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24351         LDKChannelUpdate last_update_message_arg_conv;
24352         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24353         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24354         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24355         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);
24356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24358         uint64_t ret_ref = (uint64_t)ret_var.inner;
24359         if (ret_var.is_owned) {
24360                 ret_ref |= 1;
24361         }
24362         return ret_ref;
24363 }
24364
24365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24366         LDKDirectionalChannelInfo orig_conv;
24367         orig_conv.inner = (void*)(orig & (~1));
24368         orig_conv.is_owned = false;
24369         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
24370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24372         uint64_t ret_ref = (uint64_t)ret_var.inner;
24373         if (ret_var.is_owned) {
24374                 ret_ref |= 1;
24375         }
24376         return ret_ref;
24377 }
24378
24379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24380         LDKDirectionalChannelInfo obj_conv;
24381         obj_conv.inner = (void*)(obj & (~1));
24382         obj_conv.is_owned = false;
24383         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24384         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24385         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24386         CVec_u8Z_free(ret_var);
24387         return ret_arr;
24388 }
24389
24390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24391         LDKu8slice ser_ref;
24392         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24393         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24394         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24395         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24396         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24397         return (uint64_t)ret_conv;
24398 }
24399
24400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24401         LDKChannelInfo this_obj_conv;
24402         this_obj_conv.inner = (void*)(this_obj & (~1));
24403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24404         ChannelInfo_free(this_obj_conv);
24405 }
24406
24407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24408         LDKChannelInfo this_ptr_conv;
24409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24410         this_ptr_conv.is_owned = false;
24411         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24414         uint64_t ret_ref = (uint64_t)ret_var.inner;
24415         if (ret_var.is_owned) {
24416                 ret_ref |= 1;
24417         }
24418         return ret_ref;
24419 }
24420
24421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24422         LDKChannelInfo this_ptr_conv;
24423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24424         this_ptr_conv.is_owned = false;
24425         LDKChannelFeatures val_conv;
24426         val_conv.inner = (void*)(val & (~1));
24427         val_conv.is_owned = (val & 1) || (val == 0);
24428         val_conv = ChannelFeatures_clone(&val_conv);
24429         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24430 }
24431
24432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24433         LDKChannelInfo this_ptr_conv;
24434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24435         this_ptr_conv.is_owned = false;
24436         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
24438         return ret_arr;
24439 }
24440
24441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24442         LDKChannelInfo this_ptr_conv;
24443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24444         this_ptr_conv.is_owned = false;
24445         LDKPublicKey val_ref;
24446         CHECK((*env)->GetArrayLength(env, val) == 33);
24447         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24448         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
24449 }
24450
24451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24452         LDKChannelInfo this_ptr_conv;
24453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24454         this_ptr_conv.is_owned = false;
24455         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24456         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24457         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24458         uint64_t ret_ref = (uint64_t)ret_var.inner;
24459         if (ret_var.is_owned) {
24460                 ret_ref |= 1;
24461         }
24462         return ret_ref;
24463 }
24464
24465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24466         LDKChannelInfo this_ptr_conv;
24467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24468         this_ptr_conv.is_owned = false;
24469         LDKDirectionalChannelInfo val_conv;
24470         val_conv.inner = (void*)(val & (~1));
24471         val_conv.is_owned = (val & 1) || (val == 0);
24472         val_conv = DirectionalChannelInfo_clone(&val_conv);
24473         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24474 }
24475
24476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24477         LDKChannelInfo this_ptr_conv;
24478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24479         this_ptr_conv.is_owned = false;
24480         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24481         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
24482         return ret_arr;
24483 }
24484
24485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24486         LDKChannelInfo this_ptr_conv;
24487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24488         this_ptr_conv.is_owned = false;
24489         LDKPublicKey val_ref;
24490         CHECK((*env)->GetArrayLength(env, val) == 33);
24491         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24492         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
24493 }
24494
24495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24496         LDKChannelInfo this_ptr_conv;
24497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24498         this_ptr_conv.is_owned = false;
24499         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24502         uint64_t ret_ref = (uint64_t)ret_var.inner;
24503         if (ret_var.is_owned) {
24504                 ret_ref |= 1;
24505         }
24506         return ret_ref;
24507 }
24508
24509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24510         LDKChannelInfo this_ptr_conv;
24511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24512         this_ptr_conv.is_owned = false;
24513         LDKDirectionalChannelInfo val_conv;
24514         val_conv.inner = (void*)(val & (~1));
24515         val_conv.is_owned = (val & 1) || (val == 0);
24516         val_conv = DirectionalChannelInfo_clone(&val_conv);
24517         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24518 }
24519
24520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
24521         LDKChannelInfo this_ptr_conv;
24522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24523         this_ptr_conv.is_owned = false;
24524         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24525         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24526         uint64_t ret_ref = (uint64_t)ret_copy;
24527         return ret_ref;
24528 }
24529
24530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24531         LDKChannelInfo this_ptr_conv;
24532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24533         this_ptr_conv.is_owned = false;
24534         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24535         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24536 }
24537
24538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24539         LDKChannelInfo this_ptr_conv;
24540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24541         this_ptr_conv.is_owned = false;
24542         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24545         uint64_t ret_ref = (uint64_t)ret_var.inner;
24546         if (ret_var.is_owned) {
24547                 ret_ref |= 1;
24548         }
24549         return ret_ref;
24550 }
24551
24552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24553         LDKChannelInfo this_ptr_conv;
24554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24555         this_ptr_conv.is_owned = false;
24556         LDKChannelAnnouncement val_conv;
24557         val_conv.inner = (void*)(val & (~1));
24558         val_conv.is_owned = (val & 1) || (val == 0);
24559         val_conv = ChannelAnnouncement_clone(&val_conv);
24560         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24561 }
24562
24563 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) {
24564         LDKChannelFeatures features_arg_conv;
24565         features_arg_conv.inner = (void*)(features_arg & (~1));
24566         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24567         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24568         LDKPublicKey node_one_arg_ref;
24569         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
24570         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
24571         LDKDirectionalChannelInfo one_to_two_arg_conv;
24572         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24573         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24574         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24575         LDKPublicKey node_two_arg_ref;
24576         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
24577         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
24578         LDKDirectionalChannelInfo two_to_one_arg_conv;
24579         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24580         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
24581         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
24582         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
24583         LDKChannelAnnouncement announcement_message_arg_conv;
24584         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24585         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24586         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
24587         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);
24588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24590         uint64_t ret_ref = (uint64_t)ret_var.inner;
24591         if (ret_var.is_owned) {
24592                 ret_ref |= 1;
24593         }
24594         return ret_ref;
24595 }
24596
24597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24598         LDKChannelInfo orig_conv;
24599         orig_conv.inner = (void*)(orig & (~1));
24600         orig_conv.is_owned = false;
24601         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
24602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24604         uint64_t ret_ref = (uint64_t)ret_var.inner;
24605         if (ret_var.is_owned) {
24606                 ret_ref |= 1;
24607         }
24608         return ret_ref;
24609 }
24610
24611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24612         LDKChannelInfo obj_conv;
24613         obj_conv.inner = (void*)(obj & (~1));
24614         obj_conv.is_owned = false;
24615         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
24616         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24617         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24618         CVec_u8Z_free(ret_var);
24619         return ret_arr;
24620 }
24621
24622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24623         LDKu8slice ser_ref;
24624         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24625         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24626         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
24627         *ret_conv = ChannelInfo_read(ser_ref);
24628         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24629         return (uint64_t)ret_conv;
24630 }
24631
24632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24633         LDKRoutingFees this_obj_conv;
24634         this_obj_conv.inner = (void*)(this_obj & (~1));
24635         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24636         RoutingFees_free(this_obj_conv);
24637 }
24638
24639 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24640         LDKRoutingFees this_ptr_conv;
24641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24642         this_ptr_conv.is_owned = false;
24643         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
24644         return ret_val;
24645 }
24646
24647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24648         LDKRoutingFees this_ptr_conv;
24649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24650         this_ptr_conv.is_owned = false;
24651         RoutingFees_set_base_msat(&this_ptr_conv, val);
24652 }
24653
24654 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24655         LDKRoutingFees this_ptr_conv;
24656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24657         this_ptr_conv.is_owned = false;
24658         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
24659         return ret_val;
24660 }
24661
24662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24663         LDKRoutingFees this_ptr_conv;
24664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24665         this_ptr_conv.is_owned = false;
24666         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
24667 }
24668
24669 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) {
24670         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
24671         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24672         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24673         uint64_t ret_ref = (uint64_t)ret_var.inner;
24674         if (ret_var.is_owned) {
24675                 ret_ref |= 1;
24676         }
24677         return ret_ref;
24678 }
24679
24680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24681         LDKRoutingFees a_conv;
24682         a_conv.inner = (void*)(a & (~1));
24683         a_conv.is_owned = false;
24684         LDKRoutingFees b_conv;
24685         b_conv.inner = (void*)(b & (~1));
24686         b_conv.is_owned = false;
24687         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
24688         return ret_val;
24689 }
24690
24691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24692         LDKRoutingFees orig_conv;
24693         orig_conv.inner = (void*)(orig & (~1));
24694         orig_conv.is_owned = false;
24695         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
24696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24698         uint64_t ret_ref = (uint64_t)ret_var.inner;
24699         if (ret_var.is_owned) {
24700                 ret_ref |= 1;
24701         }
24702         return ret_ref;
24703 }
24704
24705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
24706         LDKRoutingFees obj_conv;
24707         obj_conv.inner = (void*)(obj & (~1));
24708         obj_conv.is_owned = false;
24709         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
24710         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24711         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24712         CVec_u8Z_free(ret_var);
24713         return ret_arr;
24714 }
24715
24716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24717         LDKu8slice ser_ref;
24718         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24719         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24720         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
24721         *ret_conv = RoutingFees_read(ser_ref);
24722         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24723         return (uint64_t)ret_conv;
24724 }
24725
24726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24727         LDKNodeAnnouncementInfo this_obj_conv;
24728         this_obj_conv.inner = (void*)(this_obj & (~1));
24729         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24730         NodeAnnouncementInfo_free(this_obj_conv);
24731 }
24732
24733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24734         LDKNodeAnnouncementInfo this_ptr_conv;
24735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24736         this_ptr_conv.is_owned = false;
24737         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
24738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24740         uint64_t ret_ref = (uint64_t)ret_var.inner;
24741         if (ret_var.is_owned) {
24742                 ret_ref |= 1;
24743         }
24744         return ret_ref;
24745 }
24746
24747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24748         LDKNodeAnnouncementInfo this_ptr_conv;
24749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24750         this_ptr_conv.is_owned = false;
24751         LDKNodeFeatures val_conv;
24752         val_conv.inner = (void*)(val & (~1));
24753         val_conv.is_owned = (val & 1) || (val == 0);
24754         val_conv = NodeFeatures_clone(&val_conv);
24755         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
24756 }
24757
24758 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
24759         LDKNodeAnnouncementInfo this_ptr_conv;
24760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24761         this_ptr_conv.is_owned = false;
24762         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
24763         return ret_val;
24764 }
24765
24766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24767         LDKNodeAnnouncementInfo this_ptr_conv;
24768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24769         this_ptr_conv.is_owned = false;
24770         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
24771 }
24772
24773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
24774         LDKNodeAnnouncementInfo this_ptr_conv;
24775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24776         this_ptr_conv.is_owned = false;
24777         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
24778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
24779         return ret_arr;
24780 }
24781
24782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24783         LDKNodeAnnouncementInfo this_ptr_conv;
24784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24785         this_ptr_conv.is_owned = false;
24786         LDKThreeBytes val_ref;
24787         CHECK((*env)->GetArrayLength(env, val) == 3);
24788         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
24789         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
24790 }
24791
24792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
24793         LDKNodeAnnouncementInfo this_ptr_conv;
24794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24795         this_ptr_conv.is_owned = false;
24796         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
24798         return ret_arr;
24799 }
24800
24801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24802         LDKNodeAnnouncementInfo this_ptr_conv;
24803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24804         this_ptr_conv.is_owned = false;
24805         LDKThirtyTwoBytes val_ref;
24806         CHECK((*env)->GetArrayLength(env, val) == 32);
24807         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24808         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
24809 }
24810
24811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24812         LDKNodeAnnouncementInfo this_ptr_conv;
24813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24814         this_ptr_conv.is_owned = false;
24815         LDKCVec_NetAddressZ val_constr;
24816         val_constr.datalen = (*env)->GetArrayLength(env, val);
24817         if (val_constr.datalen > 0)
24818                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24819         else
24820                 val_constr.data = NULL;
24821         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24822         for (size_t m = 0; m < val_constr.datalen; m++) {
24823                 int64_t val_conv_12 = val_vals[m];
24824                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
24825                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
24826                 val_constr.data[m] = val_conv_12_conv;
24827         }
24828         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24829         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
24830 }
24831
24832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24833         LDKNodeAnnouncementInfo this_ptr_conv;
24834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24835         this_ptr_conv.is_owned = false;
24836         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
24837         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24838         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24839         uint64_t ret_ref = (uint64_t)ret_var.inner;
24840         if (ret_var.is_owned) {
24841                 ret_ref |= 1;
24842         }
24843         return ret_ref;
24844 }
24845
24846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24847         LDKNodeAnnouncementInfo this_ptr_conv;
24848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24849         this_ptr_conv.is_owned = false;
24850         LDKNodeAnnouncement val_conv;
24851         val_conv.inner = (void*)(val & (~1));
24852         val_conv.is_owned = (val & 1) || (val == 0);
24853         val_conv = NodeAnnouncement_clone(&val_conv);
24854         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
24855 }
24856
24857 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) {
24858         LDKNodeFeatures features_arg_conv;
24859         features_arg_conv.inner = (void*)(features_arg & (~1));
24860         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24861         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
24862         LDKThreeBytes rgb_arg_ref;
24863         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
24864         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
24865         LDKThirtyTwoBytes alias_arg_ref;
24866         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
24867         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
24868         LDKCVec_NetAddressZ addresses_arg_constr;
24869         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
24870         if (addresses_arg_constr.datalen > 0)
24871                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24872         else
24873                 addresses_arg_constr.data = NULL;
24874         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
24875         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24876                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
24877                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24878                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24879         }
24880         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
24881         LDKNodeAnnouncement announcement_message_arg_conv;
24882         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24883         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24884         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24885         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24886         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24887         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24888         uint64_t ret_ref = (uint64_t)ret_var.inner;
24889         if (ret_var.is_owned) {
24890                 ret_ref |= 1;
24891         }
24892         return ret_ref;
24893 }
24894
24895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24896         LDKNodeAnnouncementInfo orig_conv;
24897         orig_conv.inner = (void*)(orig & (~1));
24898         orig_conv.is_owned = false;
24899         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24900         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24901         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24902         uint64_t ret_ref = (uint64_t)ret_var.inner;
24903         if (ret_var.is_owned) {
24904                 ret_ref |= 1;
24905         }
24906         return ret_ref;
24907 }
24908
24909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24910         LDKNodeAnnouncementInfo obj_conv;
24911         obj_conv.inner = (void*)(obj & (~1));
24912         obj_conv.is_owned = false;
24913         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24914         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24915         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24916         CVec_u8Z_free(ret_var);
24917         return ret_arr;
24918 }
24919
24920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24921         LDKu8slice ser_ref;
24922         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24923         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24924         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24925         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24926         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24927         return (uint64_t)ret_conv;
24928 }
24929
24930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24931         LDKNodeInfo this_obj_conv;
24932         this_obj_conv.inner = (void*)(this_obj & (~1));
24933         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24934         NodeInfo_free(this_obj_conv);
24935 }
24936
24937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24938         LDKNodeInfo this_ptr_conv;
24939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24940         this_ptr_conv.is_owned = false;
24941         LDKCVec_u64Z val_constr;
24942         val_constr.datalen = (*env)->GetArrayLength(env, val);
24943         if (val_constr.datalen > 0)
24944                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24945         else
24946                 val_constr.data = NULL;
24947         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24948         for (size_t g = 0; g < val_constr.datalen; g++) {
24949                 int64_t val_conv_6 = val_vals[g];
24950                 val_constr.data[g] = val_conv_6;
24951         }
24952         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24953         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24954 }
24955
24956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24957         LDKNodeInfo this_ptr_conv;
24958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24959         this_ptr_conv.is_owned = false;
24960         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24963         uint64_t ret_ref = (uint64_t)ret_var.inner;
24964         if (ret_var.is_owned) {
24965                 ret_ref |= 1;
24966         }
24967         return ret_ref;
24968 }
24969
24970 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) {
24971         LDKNodeInfo this_ptr_conv;
24972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24973         this_ptr_conv.is_owned = false;
24974         LDKRoutingFees val_conv;
24975         val_conv.inner = (void*)(val & (~1));
24976         val_conv.is_owned = (val & 1) || (val == 0);
24977         val_conv = RoutingFees_clone(&val_conv);
24978         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24979 }
24980
24981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
24982         LDKNodeInfo this_ptr_conv;
24983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24984         this_ptr_conv.is_owned = false;
24985         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24986         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24987         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24988         uint64_t ret_ref = (uint64_t)ret_var.inner;
24989         if (ret_var.is_owned) {
24990                 ret_ref |= 1;
24991         }
24992         return ret_ref;
24993 }
24994
24995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24996         LDKNodeInfo this_ptr_conv;
24997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24998         this_ptr_conv.is_owned = false;
24999         LDKNodeAnnouncementInfo val_conv;
25000         val_conv.inner = (void*)(val & (~1));
25001         val_conv.is_owned = (val & 1) || (val == 0);
25002         val_conv = NodeAnnouncementInfo_clone(&val_conv);
25003         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
25004 }
25005
25006 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) {
25007         LDKCVec_u64Z channels_arg_constr;
25008         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
25009         if (channels_arg_constr.datalen > 0)
25010                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25011         else
25012                 channels_arg_constr.data = NULL;
25013         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
25014         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
25015                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
25016                 channels_arg_constr.data[g] = channels_arg_conv_6;
25017         }
25018         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
25019         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
25020         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
25021         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
25022         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
25023         LDKNodeAnnouncementInfo announcement_info_arg_conv;
25024         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
25025         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
25026         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
25027         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
25028         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25029         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25030         uint64_t ret_ref = (uint64_t)ret_var.inner;
25031         if (ret_var.is_owned) {
25032                 ret_ref |= 1;
25033         }
25034         return ret_ref;
25035 }
25036
25037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25038         LDKNodeInfo orig_conv;
25039         orig_conv.inner = (void*)(orig & (~1));
25040         orig_conv.is_owned = false;
25041         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
25042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25044         uint64_t ret_ref = (uint64_t)ret_var.inner;
25045         if (ret_var.is_owned) {
25046                 ret_ref |= 1;
25047         }
25048         return ret_ref;
25049 }
25050
25051 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25052         LDKNodeInfo obj_conv;
25053         obj_conv.inner = (void*)(obj & (~1));
25054         obj_conv.is_owned = false;
25055         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
25056         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25057         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25058         CVec_u8Z_free(ret_var);
25059         return ret_arr;
25060 }
25061
25062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25063         LDKu8slice ser_ref;
25064         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25065         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25066         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
25067         *ret_conv = NodeInfo_read(ser_ref);
25068         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25069         return (uint64_t)ret_conv;
25070 }
25071
25072 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
25073         LDKNetworkGraph obj_conv;
25074         obj_conv.inner = (void*)(obj & (~1));
25075         obj_conv.is_owned = false;
25076         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
25077         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25078         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25079         CVec_u8Z_free(ret_var);
25080         return ret_arr;
25081 }
25082
25083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25084         LDKu8slice ser_ref;
25085         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25086         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25087         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
25088         *ret_conv = NetworkGraph_read(ser_ref);
25089         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25090         return (uint64_t)ret_conv;
25091 }
25092
25093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
25094         LDKThirtyTwoBytes genesis_hash_ref;
25095         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
25096         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
25097         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
25098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25100         uint64_t ret_ref = (uint64_t)ret_var.inner;
25101         if (ret_var.is_owned) {
25102                 ret_ref |= 1;
25103         }
25104         return ret_ref;
25105 }
25106
25107 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) {
25108         LDKNetworkGraph this_arg_conv;
25109         this_arg_conv.inner = (void*)(this_arg & (~1));
25110         this_arg_conv.is_owned = false;
25111         LDKNodeAnnouncement msg_conv;
25112         msg_conv.inner = (void*)(msg & (~1));
25113         msg_conv.is_owned = false;
25114         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25115         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
25116         return (uint64_t)ret_conv;
25117 }
25118
25119 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) {
25120         LDKNetworkGraph this_arg_conv;
25121         this_arg_conv.inner = (void*)(this_arg & (~1));
25122         this_arg_conv.is_owned = false;
25123         LDKUnsignedNodeAnnouncement msg_conv;
25124         msg_conv.inner = (void*)(msg & (~1));
25125         msg_conv.is_owned = false;
25126         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25127         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
25128         return (uint64_t)ret_conv;
25129 }
25130
25131 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) {
25132         LDKNetworkGraph this_arg_conv;
25133         this_arg_conv.inner = (void*)(this_arg & (~1));
25134         this_arg_conv.is_owned = false;
25135         LDKChannelAnnouncement msg_conv;
25136         msg_conv.inner = (void*)(msg & (~1));
25137         msg_conv.is_owned = false;
25138         LDKAccess *chain_access_conv_ptr = NULL;
25139         if (chain_access != 0) {
25140                 LDKAccess chain_access_conv;
25141                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25142                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25143                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25144                         LDKAccess_JCalls_cloned(&chain_access_conv);
25145                 }
25146                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25147                 *chain_access_conv_ptr = chain_access_conv;
25148         }
25149         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25150         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
25151         return (uint64_t)ret_conv;
25152 }
25153
25154 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) {
25155         LDKNetworkGraph this_arg_conv;
25156         this_arg_conv.inner = (void*)(this_arg & (~1));
25157         this_arg_conv.is_owned = false;
25158         LDKUnsignedChannelAnnouncement msg_conv;
25159         msg_conv.inner = (void*)(msg & (~1));
25160         msg_conv.is_owned = false;
25161         LDKAccess *chain_access_conv_ptr = NULL;
25162         if (chain_access != 0) {
25163                 LDKAccess chain_access_conv;
25164                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25165                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25166                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25167                         LDKAccess_JCalls_cloned(&chain_access_conv);
25168                 }
25169                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25170                 *chain_access_conv_ptr = chain_access_conv;
25171         }
25172         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25173         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
25174         return (uint64_t)ret_conv;
25175 }
25176
25177 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) {
25178         LDKNetworkGraph this_arg_conv;
25179         this_arg_conv.inner = (void*)(this_arg & (~1));
25180         this_arg_conv.is_owned = false;
25181         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
25182 }
25183
25184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
25185         LDKNetworkGraph this_arg_conv;
25186         this_arg_conv.inner = (void*)(this_arg & (~1));
25187         this_arg_conv.is_owned = false;
25188         LDKChannelUpdate msg_conv;
25189         msg_conv.inner = (void*)(msg & (~1));
25190         msg_conv.is_owned = false;
25191         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25192         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
25193         return (uint64_t)ret_conv;
25194 }
25195
25196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
25197         LDKNetworkGraph this_arg_conv;
25198         this_arg_conv.inner = (void*)(this_arg & (~1));
25199         this_arg_conv.is_owned = false;
25200         LDKUnsignedChannelUpdate msg_conv;
25201         msg_conv.inner = (void*)(msg & (~1));
25202         msg_conv.is_owned = false;
25203         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25204         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
25205         return (uint64_t)ret_conv;
25206 }
25207
25208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25209         LDKFilesystemPersister this_obj_conv;
25210         this_obj_conv.inner = (void*)(this_obj & (~1));
25211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25212         FilesystemPersister_free(this_obj_conv);
25213 }
25214
25215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
25216         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
25217         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
25218         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25219         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25220         uint64_t ret_ref = (uint64_t)ret_var.inner;
25221         if (ret_var.is_owned) {
25222                 ret_ref |= 1;
25223         }
25224         return ret_ref;
25225 }
25226
25227 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
25228         LDKFilesystemPersister this_arg_conv;
25229         this_arg_conv.inner = (void*)(this_arg & (~1));
25230         this_arg_conv.is_owned = false;
25231         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
25232         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25233         Str_free(ret_str);
25234         return ret_conv;
25235 }
25236
25237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
25238         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
25239         LDKChannelManager manager_conv;
25240         manager_conv.inner = (void*)(manager & (~1));
25241         manager_conv.is_owned = false;
25242         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25243         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
25244         return (uint64_t)ret_conv;
25245 }
25246
25247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
25248         LDKFilesystemPersister this_arg_conv;
25249         this_arg_conv.inner = (void*)(this_arg & (~1));
25250         this_arg_conv.is_owned = false;
25251         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25252         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25253                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25254                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25255         }
25256         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
25257         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
25258         return (uint64_t)ret_conv;
25259 }
25260
25261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
25262         LDKFilesystemPersister this_arg_conv;
25263         this_arg_conv.inner = (void*)(this_arg & (~1));
25264         this_arg_conv.is_owned = false;
25265         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
25266         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
25267         return (uint64_t)ret;
25268 }
25269
25270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25271         LDKBackgroundProcessor this_obj_conv;
25272         this_obj_conv.inner = (void*)(this_obj & (~1));
25273         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25274         BackgroundProcessor_free(this_obj_conv);
25275 }
25276
25277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25278         if ((this_ptr & 1) != 0) return;
25279         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
25280         FREE((void*)this_ptr);
25281         ChannelManagerPersister_free(this_ptr_conv);
25282 }
25283
25284 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) {
25285         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
25286         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
25287                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25288                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
25289         }
25290         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25291         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
25292                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25293                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
25294         }
25295         LDKChainMonitor chain_monitor_conv;
25296         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
25297         chain_monitor_conv.is_owned = false;
25298         LDKChannelManager channel_manager_conv;
25299         channel_manager_conv.inner = (void*)(channel_manager & (~1));
25300         channel_manager_conv.is_owned = false;
25301         LDKPeerManager peer_manager_conv;
25302         peer_manager_conv.inner = (void*)(peer_manager & (~1));
25303         peer_manager_conv.is_owned = false;
25304         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25305         if (logger_conv.free == LDKLogger_JCalls_free) {
25306                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25307                 LDKLogger_JCalls_cloned(&logger_conv);
25308         }
25309         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
25310         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25311         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25312         uint64_t ret_ref = (uint64_t)ret_var.inner;
25313         if (ret_var.is_owned) {
25314                 ret_ref |= 1;
25315         }
25316         return ret_ref;
25317 }
25318
25319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
25320         LDKBackgroundProcessor this_arg_conv;
25321         this_arg_conv.inner = (void*)(this_arg & (~1));
25322         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25323         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25324         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25325         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
25326         return (uint64_t)ret_conv;
25327 }
25328
25329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
25330         check_platform();
25331 }
25332
25333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25334         LDKInvoice this_obj_conv;
25335         this_obj_conv.inner = (void*)(this_obj & (~1));
25336         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25337         Invoice_free(this_obj_conv);
25338 }
25339
25340 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25341         LDKInvoice a_conv;
25342         a_conv.inner = (void*)(a & (~1));
25343         a_conv.is_owned = false;
25344         LDKInvoice b_conv;
25345         b_conv.inner = (void*)(b & (~1));
25346         b_conv.is_owned = false;
25347         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
25348         return ret_val;
25349 }
25350
25351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25352         LDKInvoice orig_conv;
25353         orig_conv.inner = (void*)(orig & (~1));
25354         orig_conv.is_owned = false;
25355         LDKInvoice ret_var = Invoice_clone(&orig_conv);
25356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25358         uint64_t ret_ref = (uint64_t)ret_var.inner;
25359         if (ret_var.is_owned) {
25360                 ret_ref |= 1;
25361         }
25362         return ret_ref;
25363 }
25364
25365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25366         LDKSignedRawInvoice this_obj_conv;
25367         this_obj_conv.inner = (void*)(this_obj & (~1));
25368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25369         SignedRawInvoice_free(this_obj_conv);
25370 }
25371
25372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25373         LDKSignedRawInvoice a_conv;
25374         a_conv.inner = (void*)(a & (~1));
25375         a_conv.is_owned = false;
25376         LDKSignedRawInvoice b_conv;
25377         b_conv.inner = (void*)(b & (~1));
25378         b_conv.is_owned = false;
25379         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
25380         return ret_val;
25381 }
25382
25383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25384         LDKSignedRawInvoice orig_conv;
25385         orig_conv.inner = (void*)(orig & (~1));
25386         orig_conv.is_owned = false;
25387         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
25388         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25389         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25390         uint64_t ret_ref = (uint64_t)ret_var.inner;
25391         if (ret_var.is_owned) {
25392                 ret_ref |= 1;
25393         }
25394         return ret_ref;
25395 }
25396
25397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25398         LDKRawInvoice this_obj_conv;
25399         this_obj_conv.inner = (void*)(this_obj & (~1));
25400         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25401         RawInvoice_free(this_obj_conv);
25402 }
25403
25404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
25405         LDKRawInvoice this_ptr_conv;
25406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25407         this_ptr_conv.is_owned = false;
25408         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
25409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25411         uint64_t ret_ref = (uint64_t)ret_var.inner;
25412         if (ret_var.is_owned) {
25413                 ret_ref |= 1;
25414         }
25415         return ret_ref;
25416 }
25417
25418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25419         LDKRawInvoice this_ptr_conv;
25420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25421         this_ptr_conv.is_owned = false;
25422         LDKRawDataPart val_conv;
25423         val_conv.inner = (void*)(val & (~1));
25424         val_conv.is_owned = (val & 1) || (val == 0);
25425         val_conv = RawDataPart_clone(&val_conv);
25426         RawInvoice_set_data(&this_ptr_conv, val_conv);
25427 }
25428
25429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25430         LDKRawInvoice a_conv;
25431         a_conv.inner = (void*)(a & (~1));
25432         a_conv.is_owned = false;
25433         LDKRawInvoice b_conv;
25434         b_conv.inner = (void*)(b & (~1));
25435         b_conv.is_owned = false;
25436         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
25437         return ret_val;
25438 }
25439
25440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25441         LDKRawInvoice orig_conv;
25442         orig_conv.inner = (void*)(orig & (~1));
25443         orig_conv.is_owned = false;
25444         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
25445         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25446         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25447         uint64_t ret_ref = (uint64_t)ret_var.inner;
25448         if (ret_var.is_owned) {
25449                 ret_ref |= 1;
25450         }
25451         return ret_ref;
25452 }
25453
25454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25455         LDKRawDataPart this_obj_conv;
25456         this_obj_conv.inner = (void*)(this_obj & (~1));
25457         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25458         RawDataPart_free(this_obj_conv);
25459 }
25460
25461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
25462         LDKRawDataPart this_ptr_conv;
25463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25464         this_ptr_conv.is_owned = false;
25465         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
25466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25468         uint64_t ret_ref = (uint64_t)ret_var.inner;
25469         if (ret_var.is_owned) {
25470                 ret_ref |= 1;
25471         }
25472         return ret_ref;
25473 }
25474
25475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25476         LDKRawDataPart this_ptr_conv;
25477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25478         this_ptr_conv.is_owned = false;
25479         LDKPositiveTimestamp val_conv;
25480         val_conv.inner = (void*)(val & (~1));
25481         val_conv.is_owned = (val & 1) || (val == 0);
25482         val_conv = PositiveTimestamp_clone(&val_conv);
25483         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
25484 }
25485
25486 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25487         LDKRawDataPart a_conv;
25488         a_conv.inner = (void*)(a & (~1));
25489         a_conv.is_owned = false;
25490         LDKRawDataPart b_conv;
25491         b_conv.inner = (void*)(b & (~1));
25492         b_conv.is_owned = false;
25493         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
25494         return ret_val;
25495 }
25496
25497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25498         LDKRawDataPart orig_conv;
25499         orig_conv.inner = (void*)(orig & (~1));
25500         orig_conv.is_owned = false;
25501         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
25502         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25503         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25504         uint64_t ret_ref = (uint64_t)ret_var.inner;
25505         if (ret_var.is_owned) {
25506                 ret_ref |= 1;
25507         }
25508         return ret_ref;
25509 }
25510
25511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25512         LDKPositiveTimestamp this_obj_conv;
25513         this_obj_conv.inner = (void*)(this_obj & (~1));
25514         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25515         PositiveTimestamp_free(this_obj_conv);
25516 }
25517
25518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25519         LDKPositiveTimestamp a_conv;
25520         a_conv.inner = (void*)(a & (~1));
25521         a_conv.is_owned = false;
25522         LDKPositiveTimestamp b_conv;
25523         b_conv.inner = (void*)(b & (~1));
25524         b_conv.is_owned = false;
25525         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
25526         return ret_val;
25527 }
25528
25529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25530         LDKPositiveTimestamp orig_conv;
25531         orig_conv.inner = (void*)(orig & (~1));
25532         orig_conv.is_owned = false;
25533         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
25534         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25535         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25536         uint64_t ret_ref = (uint64_t)ret_var.inner;
25537         if (ret_var.is_owned) {
25538                 ret_ref |= 1;
25539         }
25540         return ret_ref;
25541 }
25542
25543 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25544         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
25545         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
25546         return ret_conv;
25547 }
25548
25549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25550         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
25551         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
25552         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
25553         return ret_val;
25554 }
25555
25556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
25557         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
25558         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
25559         return ret_val;
25560 }
25561
25562 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25563         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
25564         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
25565         return ret_conv;
25566 }
25567
25568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25569         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
25570         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
25571         jboolean ret_val = Currency_eq(a_conv, b_conv);
25572         return ret_val;
25573 }
25574
25575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25576         LDKSha256 this_obj_conv;
25577         this_obj_conv.inner = (void*)(this_obj & (~1));
25578         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25579         Sha256_free(this_obj_conv);
25580 }
25581
25582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25583         LDKSha256 a_conv;
25584         a_conv.inner = (void*)(a & (~1));
25585         a_conv.is_owned = false;
25586         LDKSha256 b_conv;
25587         b_conv.inner = (void*)(b & (~1));
25588         b_conv.is_owned = false;
25589         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
25590         return ret_val;
25591 }
25592
25593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25594         LDKSha256 orig_conv;
25595         orig_conv.inner = (void*)(orig & (~1));
25596         orig_conv.is_owned = false;
25597         LDKSha256 ret_var = Sha256_clone(&orig_conv);
25598         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25599         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25600         uint64_t ret_ref = (uint64_t)ret_var.inner;
25601         if (ret_var.is_owned) {
25602                 ret_ref |= 1;
25603         }
25604         return ret_ref;
25605 }
25606
25607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25608         LDKDescription this_obj_conv;
25609         this_obj_conv.inner = (void*)(this_obj & (~1));
25610         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25611         Description_free(this_obj_conv);
25612 }
25613
25614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25615         LDKDescription a_conv;
25616         a_conv.inner = (void*)(a & (~1));
25617         a_conv.is_owned = false;
25618         LDKDescription b_conv;
25619         b_conv.inner = (void*)(b & (~1));
25620         b_conv.is_owned = false;
25621         jboolean ret_val = Description_eq(&a_conv, &b_conv);
25622         return ret_val;
25623 }
25624
25625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25626         LDKDescription orig_conv;
25627         orig_conv.inner = (void*)(orig & (~1));
25628         orig_conv.is_owned = false;
25629         LDKDescription ret_var = Description_clone(&orig_conv);
25630         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25631         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25632         uint64_t ret_ref = (uint64_t)ret_var.inner;
25633         if (ret_var.is_owned) {
25634                 ret_ref |= 1;
25635         }
25636         return ret_ref;
25637 }
25638
25639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25640         LDKPayeePubKey this_obj_conv;
25641         this_obj_conv.inner = (void*)(this_obj & (~1));
25642         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25643         PayeePubKey_free(this_obj_conv);
25644 }
25645
25646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25647         LDKPayeePubKey a_conv;
25648         a_conv.inner = (void*)(a & (~1));
25649         a_conv.is_owned = false;
25650         LDKPayeePubKey b_conv;
25651         b_conv.inner = (void*)(b & (~1));
25652         b_conv.is_owned = false;
25653         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
25654         return ret_val;
25655 }
25656
25657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25658         LDKPayeePubKey orig_conv;
25659         orig_conv.inner = (void*)(orig & (~1));
25660         orig_conv.is_owned = false;
25661         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
25662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25664         uint64_t ret_ref = (uint64_t)ret_var.inner;
25665         if (ret_var.is_owned) {
25666                 ret_ref |= 1;
25667         }
25668         return ret_ref;
25669 }
25670
25671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25672         LDKExpiryTime this_obj_conv;
25673         this_obj_conv.inner = (void*)(this_obj & (~1));
25674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25675         ExpiryTime_free(this_obj_conv);
25676 }
25677
25678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25679         LDKExpiryTime a_conv;
25680         a_conv.inner = (void*)(a & (~1));
25681         a_conv.is_owned = false;
25682         LDKExpiryTime b_conv;
25683         b_conv.inner = (void*)(b & (~1));
25684         b_conv.is_owned = false;
25685         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
25686         return ret_val;
25687 }
25688
25689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25690         LDKExpiryTime orig_conv;
25691         orig_conv.inner = (void*)(orig & (~1));
25692         orig_conv.is_owned = false;
25693         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
25694         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25695         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25696         uint64_t ret_ref = (uint64_t)ret_var.inner;
25697         if (ret_var.is_owned) {
25698                 ret_ref |= 1;
25699         }
25700         return ret_ref;
25701 }
25702
25703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25704         LDKMinFinalCltvExpiry this_obj_conv;
25705         this_obj_conv.inner = (void*)(this_obj & (~1));
25706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25707         MinFinalCltvExpiry_free(this_obj_conv);
25708 }
25709
25710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25711         LDKMinFinalCltvExpiry a_conv;
25712         a_conv.inner = (void*)(a & (~1));
25713         a_conv.is_owned = false;
25714         LDKMinFinalCltvExpiry b_conv;
25715         b_conv.inner = (void*)(b & (~1));
25716         b_conv.is_owned = false;
25717         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
25718         return ret_val;
25719 }
25720
25721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25722         LDKMinFinalCltvExpiry orig_conv;
25723         orig_conv.inner = (void*)(orig & (~1));
25724         orig_conv.is_owned = false;
25725         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
25726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25728         uint64_t ret_ref = (uint64_t)ret_var.inner;
25729         if (ret_var.is_owned) {
25730                 ret_ref |= 1;
25731         }
25732         return ret_ref;
25733 }
25734
25735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25736         if ((this_ptr & 1) != 0) return;
25737         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
25738         FREE((void*)this_ptr);
25739         Fallback_free(this_ptr_conv);
25740 }
25741
25742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25743         LDKFallback* orig_conv = (LDKFallback*)orig;
25744         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25745         *ret_copy = Fallback_clone(orig_conv);
25746         uint64_t ret_ref = (uint64_t)ret_copy;
25747         return ret_ref;
25748 }
25749
25750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25751         LDKFallback* a_conv = (LDKFallback*)a;
25752         LDKFallback* b_conv = (LDKFallback*)b;
25753         jboolean ret_val = Fallback_eq(a_conv, b_conv);
25754         return ret_val;
25755 }
25756
25757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25758         LDKInvoiceSignature this_obj_conv;
25759         this_obj_conv.inner = (void*)(this_obj & (~1));
25760         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25761         InvoiceSignature_free(this_obj_conv);
25762 }
25763
25764 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25765         LDKInvoiceSignature a_conv;
25766         a_conv.inner = (void*)(a & (~1));
25767         a_conv.is_owned = false;
25768         LDKInvoiceSignature b_conv;
25769         b_conv.inner = (void*)(b & (~1));
25770         b_conv.is_owned = false;
25771         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
25772         return ret_val;
25773 }
25774
25775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25776         LDKInvoiceSignature orig_conv;
25777         orig_conv.inner = (void*)(orig & (~1));
25778         orig_conv.is_owned = false;
25779         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
25780         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25781         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25782         uint64_t ret_ref = (uint64_t)ret_var.inner;
25783         if (ret_var.is_owned) {
25784                 ret_ref |= 1;
25785         }
25786         return ret_ref;
25787 }
25788
25789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25790         LDKPrivateRoute this_obj_conv;
25791         this_obj_conv.inner = (void*)(this_obj & (~1));
25792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25793         PrivateRoute_free(this_obj_conv);
25794 }
25795
25796 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25797         LDKPrivateRoute a_conv;
25798         a_conv.inner = (void*)(a & (~1));
25799         a_conv.is_owned = false;
25800         LDKPrivateRoute b_conv;
25801         b_conv.inner = (void*)(b & (~1));
25802         b_conv.is_owned = false;
25803         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
25804         return ret_val;
25805 }
25806
25807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25808         LDKPrivateRoute orig_conv;
25809         orig_conv.inner = (void*)(orig & (~1));
25810         orig_conv.is_owned = false;
25811         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
25812         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25813         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25814         uint64_t ret_ref = (uint64_t)ret_var.inner;
25815         if (ret_var.is_owned) {
25816                 ret_ref |= 1;
25817         }
25818         return ret_ref;
25819 }
25820
25821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
25822         LDKSignedRawInvoice this_arg_conv;
25823         this_arg_conv.inner = (void*)(this_arg & (~1));
25824         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25825         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
25826         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
25827         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
25828         return (uint64_t)ret_ref;
25829 }
25830
25831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
25832         LDKSignedRawInvoice this_arg_conv;
25833         this_arg_conv.inner = (void*)(this_arg & (~1));
25834         this_arg_conv.is_owned = false;
25835         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
25836         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25837         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25838         uint64_t ret_ref = (uint64_t)ret_var.inner;
25839         if (ret_var.is_owned) {
25840                 ret_ref |= 1;
25841         }
25842         return ret_ref;
25843 }
25844
25845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25846         LDKSignedRawInvoice this_arg_conv;
25847         this_arg_conv.inner = (void*)(this_arg & (~1));
25848         this_arg_conv.is_owned = false;
25849         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
25851         return ret_arr;
25852 }
25853
25854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25855         LDKSignedRawInvoice this_arg_conv;
25856         this_arg_conv.inner = (void*)(this_arg & (~1));
25857         this_arg_conv.is_owned = false;
25858         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
25859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25861         uint64_t ret_ref = (uint64_t)ret_var.inner;
25862         if (ret_var.is_owned) {
25863                 ret_ref |= 1;
25864         }
25865         return ret_ref;
25866 }
25867
25868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25869         LDKSignedRawInvoice this_arg_conv;
25870         this_arg_conv.inner = (void*)(this_arg & (~1));
25871         this_arg_conv.is_owned = false;
25872         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25873         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25874         return (uint64_t)ret_conv;
25875 }
25876
25877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25878         LDKSignedRawInvoice this_arg_conv;
25879         this_arg_conv.inner = (void*)(this_arg & (~1));
25880         this_arg_conv.is_owned = false;
25881         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
25882         return ret_val;
25883 }
25884
25885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25886         LDKRawInvoice this_arg_conv;
25887         this_arg_conv.inner = (void*)(this_arg & (~1));
25888         this_arg_conv.is_owned = false;
25889         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
25891         return ret_arr;
25892 }
25893
25894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25895         LDKRawInvoice this_arg_conv;
25896         this_arg_conv.inner = (void*)(this_arg & (~1));
25897         this_arg_conv.is_owned = false;
25898         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
25899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25901         uint64_t ret_ref = (uint64_t)ret_var.inner;
25902         if (ret_var.is_owned) {
25903                 ret_ref |= 1;
25904         }
25905         return ret_ref;
25906 }
25907
25908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
25909         LDKRawInvoice this_arg_conv;
25910         this_arg_conv.inner = (void*)(this_arg & (~1));
25911         this_arg_conv.is_owned = false;
25912         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
25913         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25914         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25915         uint64_t ret_ref = (uint64_t)ret_var.inner;
25916         if (ret_var.is_owned) {
25917                 ret_ref |= 1;
25918         }
25919         return ret_ref;
25920 }
25921
25922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25923         LDKRawInvoice this_arg_conv;
25924         this_arg_conv.inner = (void*)(this_arg & (~1));
25925         this_arg_conv.is_owned = false;
25926         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
25927         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25928         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25929         uint64_t ret_ref = (uint64_t)ret_var.inner;
25930         if (ret_var.is_owned) {
25931                 ret_ref |= 1;
25932         }
25933         return ret_ref;
25934 }
25935
25936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25937         LDKRawInvoice this_arg_conv;
25938         this_arg_conv.inner = (void*)(this_arg & (~1));
25939         this_arg_conv.is_owned = false;
25940         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
25941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25943         uint64_t ret_ref = (uint64_t)ret_var.inner;
25944         if (ret_var.is_owned) {
25945                 ret_ref |= 1;
25946         }
25947         return ret_ref;
25948 }
25949
25950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25951         LDKRawInvoice this_arg_conv;
25952         this_arg_conv.inner = (void*)(this_arg & (~1));
25953         this_arg_conv.is_owned = false;
25954         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
25955         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25956         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25957         uint64_t ret_ref = (uint64_t)ret_var.inner;
25958         if (ret_var.is_owned) {
25959                 ret_ref |= 1;
25960         }
25961         return ret_ref;
25962 }
25963
25964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25965         LDKRawInvoice this_arg_conv;
25966         this_arg_conv.inner = (void*)(this_arg & (~1));
25967         this_arg_conv.is_owned = false;
25968         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
25969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25971         uint64_t ret_ref = (uint64_t)ret_var.inner;
25972         if (ret_var.is_owned) {
25973                 ret_ref |= 1;
25974         }
25975         return ret_ref;
25976 }
25977
25978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25979         LDKRawInvoice this_arg_conv;
25980         this_arg_conv.inner = (void*)(this_arg & (~1));
25981         this_arg_conv.is_owned = false;
25982         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25983         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
25984         return ret_arr;
25985 }
25986
25987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25988         LDKRawInvoice this_arg_conv;
25989         this_arg_conv.inner = (void*)(this_arg & (~1));
25990         this_arg_conv.is_owned = false;
25991         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
25992         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25993         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25994         uint64_t ret_ref = (uint64_t)ret_var.inner;
25995         if (ret_var.is_owned) {
25996                 ret_ref |= 1;
25997         }
25998         return ret_ref;
25999 }
26000
26001 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
26002         LDKRawInvoice this_arg_conv;
26003         this_arg_conv.inner = (void*)(this_arg & (~1));
26004         this_arg_conv.is_owned = false;
26005         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
26006         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26007         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26008         for (size_t o = 0; o < ret_var.datalen; o++) {
26009                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26010                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26011                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26012                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26013                 if (ret_conv_14_var.is_owned) {
26014                         ret_conv_14_ref |= 1;
26015                 }
26016                 ret_arr_ptr[o] = ret_conv_14_ref;
26017         }
26018         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26019         FREE(ret_var.data);
26020         return ret_arr;
26021 }
26022
26023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
26024         LDKRawInvoice this_arg_conv;
26025         this_arg_conv.inner = (void*)(this_arg & (~1));
26026         this_arg_conv.is_owned = false;
26027         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26028         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
26029         uint64_t ret_ref = (uint64_t)ret_copy;
26030         return ret_ref;
26031 }
26032
26033 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
26034         LDKRawInvoice this_arg_conv;
26035         this_arg_conv.inner = (void*)(this_arg & (~1));
26036         this_arg_conv.is_owned = false;
26037         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
26038         return ret_conv;
26039 }
26040
26041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
26042         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26043         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
26044         return (uint64_t)ret_conv;
26045 }
26046
26047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
26048         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26049         *ret_conv = PositiveTimestamp_from_system_time(time);
26050         return (uint64_t)ret_conv;
26051 }
26052
26053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
26054         LDKPositiveTimestamp this_arg_conv;
26055         this_arg_conv.inner = (void*)(this_arg & (~1));
26056         this_arg_conv.is_owned = false;
26057         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
26058         return ret_val;
26059 }
26060
26061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26062         LDKPositiveTimestamp this_arg_conv;
26063         this_arg_conv.inner = (void*)(this_arg & (~1));
26064         this_arg_conv.is_owned = false;
26065         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
26066         return ret_val;
26067 }
26068
26069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
26070         LDKInvoice this_arg_conv;
26071         this_arg_conv.inner = (void*)(this_arg & (~1));
26072         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26073         this_arg_conv = Invoice_clone(&this_arg_conv);
26074         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
26075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26077         uint64_t ret_ref = (uint64_t)ret_var.inner;
26078         if (ret_var.is_owned) {
26079                 ret_ref |= 1;
26080         }
26081         return ret_ref;
26082 }
26083
26084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
26085         LDKInvoice this_arg_conv;
26086         this_arg_conv.inner = (void*)(this_arg & (~1));
26087         this_arg_conv.is_owned = false;
26088         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
26089         *ret_conv = Invoice_check_signature(&this_arg_conv);
26090         return (uint64_t)ret_conv;
26091 }
26092
26093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
26094         LDKSignedRawInvoice signed_invoice_conv;
26095         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
26096         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
26097         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
26098         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
26099         *ret_conv = Invoice_from_signed(signed_invoice_conv);
26100         return (uint64_t)ret_conv;
26101 }
26102
26103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
26104         LDKInvoice this_arg_conv;
26105         this_arg_conv.inner = (void*)(this_arg & (~1));
26106         this_arg_conv.is_owned = false;
26107         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
26108         return ret_val;
26109 }
26110
26111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26112         LDKInvoice this_arg_conv;
26113         this_arg_conv.inner = (void*)(this_arg & (~1));
26114         this_arg_conv.is_owned = false;
26115         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
26117         return ret_arr;
26118 }
26119
26120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26121         LDKInvoice this_arg_conv;
26122         this_arg_conv.inner = (void*)(this_arg & (~1));
26123         this_arg_conv.is_owned = false;
26124         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
26126         return ret_arr;
26127 }
26128
26129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26130         LDKInvoice this_arg_conv;
26131         this_arg_conv.inner = (void*)(this_arg & (~1));
26132         this_arg_conv.is_owned = false;
26133         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26134         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
26135         return ret_arr;
26136 }
26137
26138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
26139         LDKInvoice this_arg_conv;
26140         this_arg_conv.inner = (void*)(this_arg & (~1));
26141         this_arg_conv.is_owned = false;
26142         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
26143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26145         uint64_t ret_ref = (uint64_t)ret_var.inner;
26146         if (ret_var.is_owned) {
26147                 ret_ref |= 1;
26148         }
26149         return ret_ref;
26150 }
26151
26152 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26153         LDKInvoice this_arg_conv;
26154         this_arg_conv.inner = (void*)(this_arg & (~1));
26155         this_arg_conv.is_owned = false;
26156         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26157         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
26158         return ret_arr;
26159 }
26160
26161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26162         LDKInvoice this_arg_conv;
26163         this_arg_conv.inner = (void*)(this_arg & (~1));
26164         this_arg_conv.is_owned = false;
26165         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
26166         return ret_val;
26167 }
26168
26169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
26170         LDKInvoice this_arg_conv;
26171         this_arg_conv.inner = (void*)(this_arg & (~1));
26172         this_arg_conv.is_owned = false;
26173         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
26174         return ret_val;
26175 }
26176
26177 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
26178         LDKInvoice this_arg_conv;
26179         this_arg_conv.inner = (void*)(this_arg & (~1));
26180         this_arg_conv.is_owned = false;
26181         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
26182         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26183         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26184         for (size_t o = 0; o < ret_var.datalen; o++) {
26185                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26186                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26187                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26188                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26189                 if (ret_conv_14_var.is_owned) {
26190                         ret_conv_14_ref |= 1;
26191                 }
26192                 ret_arr_ptr[o] = ret_conv_14_ref;
26193         }
26194         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26195         FREE(ret_var.data);
26196         return ret_arr;
26197 }
26198
26199 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
26200         LDKInvoice this_arg_conv;
26201         this_arg_conv.inner = (void*)(this_arg & (~1));
26202         this_arg_conv.is_owned = false;
26203         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
26204         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26205         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26206         for (size_t l = 0; l < ret_var.datalen; l++) {
26207                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
26208                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26209                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26210                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
26211                 if (ret_conv_11_var.is_owned) {
26212                         ret_conv_11_ref |= 1;
26213                 }
26214                 ret_arr_ptr[l] = ret_conv_11_ref;
26215         }
26216         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26217         FREE(ret_var.data);
26218         return ret_arr;
26219 }
26220
26221 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
26222         LDKInvoice this_arg_conv;
26223         this_arg_conv.inner = (void*)(this_arg & (~1));
26224         this_arg_conv.is_owned = false;
26225         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
26226         return ret_conv;
26227 }
26228
26229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
26230         LDKInvoice this_arg_conv;
26231         this_arg_conv.inner = (void*)(this_arg & (~1));
26232         this_arg_conv.is_owned = false;
26233         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26234         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
26235         uint64_t ret_ref = (uint64_t)ret_copy;
26236         return ret_ref;
26237 }
26238
26239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
26240         LDKStr description_conv = java_to_owned_str(env, description);
26241         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
26242         *ret_conv = Description_new(description_conv);
26243         return (uint64_t)ret_conv;
26244 }
26245
26246 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26247         LDKDescription this_arg_conv;
26248         this_arg_conv.inner = (void*)(this_arg & (~1));
26249         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26250         this_arg_conv = Description_clone(&this_arg_conv);
26251         LDKStr ret_str = Description_into_inner(this_arg_conv);
26252         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26253         Str_free(ret_str);
26254         return ret_conv;
26255 }
26256
26257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
26258         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26259         *ret_conv = ExpiryTime_from_seconds(seconds);
26260         return (uint64_t)ret_conv;
26261 }
26262
26263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
26264         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26265         *ret_conv = ExpiryTime_from_duration(duration);
26266         return (uint64_t)ret_conv;
26267 }
26268
26269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
26270         LDKExpiryTime this_arg_conv;
26271         this_arg_conv.inner = (void*)(this_arg & (~1));
26272         this_arg_conv.is_owned = false;
26273         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
26274         return ret_val;
26275 }
26276
26277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
26278         LDKExpiryTime this_arg_conv;
26279         this_arg_conv.inner = (void*)(this_arg & (~1));
26280         this_arg_conv.is_owned = false;
26281         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
26282         return ret_val;
26283 }
26284
26285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
26286         LDKRouteHint hops_conv;
26287         hops_conv.inner = (void*)(hops & (~1));
26288         hops_conv.is_owned = (hops & 1) || (hops == 0);
26289         hops_conv = RouteHint_clone(&hops_conv);
26290         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
26291         *ret_conv = PrivateRoute_new(hops_conv);
26292         return (uint64_t)ret_conv;
26293 }
26294
26295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26296         LDKPrivateRoute this_arg_conv;
26297         this_arg_conv.inner = (void*)(this_arg & (~1));
26298         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26299         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
26300         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
26301         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26302         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26303         uint64_t ret_ref = (uint64_t)ret_var.inner;
26304         if (ret_var.is_owned) {
26305                 ret_ref |= 1;
26306         }
26307         return ret_ref;
26308 }
26309
26310 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26311         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
26312         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
26313         return ret_conv;
26314 }
26315
26316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26317         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
26318         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
26319         jboolean ret_val = CreationError_eq(a_conv, b_conv);
26320         return ret_val;
26321 }
26322
26323 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26324         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
26325         LDKStr ret_str = CreationError_to_str(o_conv);
26326         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26327         Str_free(ret_str);
26328         return ret_conv;
26329 }
26330
26331 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26332         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
26333         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
26334         return ret_conv;
26335 }
26336
26337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26338         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
26339         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
26340         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
26341         return ret_val;
26342 }
26343
26344 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26345         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
26346         LDKStr ret_str = SemanticError_to_str(o_conv);
26347         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26348         Str_free(ret_str);
26349         return ret_conv;
26350 }
26351
26352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26353         if ((this_ptr & 1) != 0) return;
26354         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
26355         FREE((void*)this_ptr);
26356         SignOrCreationError_free(this_ptr_conv);
26357 }
26358
26359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26360         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
26361         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26362         *ret_copy = SignOrCreationError_clone(orig_conv);
26363         uint64_t ret_ref = (uint64_t)ret_copy;
26364         return ret_ref;
26365 }
26366
26367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26368         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
26369         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
26370         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
26371         return ret_val;
26372 }
26373
26374 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26375         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
26376         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
26377         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26378         Str_free(ret_str);
26379         return ret_conv;
26380 }
26381
26382 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) {
26383         LDKChannelManager channelmanager_conv;
26384         channelmanager_conv.inner = (void*)(channelmanager & (~1));
26385         channelmanager_conv.is_owned = false;
26386         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26387         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26388                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26389                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26390         }
26391         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
26392         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
26393         LDKStr description_conv = java_to_owned_str(env, description);
26394         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26395         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
26396         return (uint64_t)ret_conv;
26397 }
26398
26399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26400         LDKStr s_conv = java_to_owned_str(env, s);
26401         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
26402         *ret_conv = SiPrefix_from_str(s_conv);
26403         return (uint64_t)ret_conv;
26404 }
26405
26406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26407         LDKStr s_conv = java_to_owned_str(env, s);
26408         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
26409         *ret_conv = Invoice_from_str(s_conv);
26410         return (uint64_t)ret_conv;
26411 }
26412
26413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26414         LDKStr s_conv = java_to_owned_str(env, s);
26415         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
26416         *ret_conv = SignedRawInvoice_from_str(s_conv);
26417         return (uint64_t)ret_conv;
26418 }
26419
26420 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26421         LDKInvoice o_conv;
26422         o_conv.inner = (void*)(o & (~1));
26423         o_conv.is_owned = false;
26424         LDKStr ret_str = Invoice_to_str(&o_conv);
26425         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26426         Str_free(ret_str);
26427         return ret_conv;
26428 }
26429
26430 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26431         LDKSignedRawInvoice o_conv;
26432         o_conv.inner = (void*)(o & (~1));
26433         o_conv.is_owned = false;
26434         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
26435         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26436         Str_free(ret_str);
26437         return ret_conv;
26438 }
26439
26440 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26441         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
26442         LDKStr ret_str = Currency_to_str(o_conv);
26443         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26444         Str_free(ret_str);
26445         return ret_conv;
26446 }
26447
26448 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26449         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
26450         LDKStr ret_str = SiPrefix_to_str(o_conv);
26451         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26452         Str_free(ret_str);
26453         return ret_conv;
26454 }
26455