ecf9820beb9195bc508f021ff073a1925e23df89
[ldk-java] / src / main / jni / bindings.c
1 #include "org_ldk_impl_bindings.h"
2 #include <rust_types.h>
3 #include <lightning.h>
4 #include <string.h>
5 #include <stdatomic.h>
6 #include <stdlib.h>
7
8 #include <assert.h>
9 // Always run a, then assert it is true:
10 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
11 // Assert a is true or do nothing
12 #define CHECK(a) DO_ASSERT(a)
13
14 // Running a leak check across all the allocations and frees of the JDK is a mess,
15 // so instead we implement our own naive leak checker here, relying on the -wrap
16 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
17 // and free'd in Rust or C across the generated bindings shared library.
18 #include <threads.h>
19 #include <execinfo.h>
20 #include <unistd.h>
21 static mtx_t allocation_mtx;
22
23 void __attribute__((constructor)) init_mtx() {
24         DO_ASSERT(mtx_init(&allocation_mtx, mtx_plain) == thrd_success);
25 }
26
27 #define BT_MAX 128
28 typedef struct allocation {
29         struct allocation* next;
30         void* ptr;
31         const char* struct_name;
32         void* bt[BT_MAX];
33         int bt_len;
34         size_t alloc_len;
35 } allocation;
36 static allocation* allocation_ll = NULL;
37
38 void* __real_malloc(size_t len);
39 void* __real_calloc(size_t nmemb, size_t len);
40 static void new_allocation(void* res, const char* struct_name, size_t len) {
41         allocation* new_alloc = __real_malloc(sizeof(allocation));
42         new_alloc->ptr = res;
43         new_alloc->struct_name = struct_name;
44         new_alloc->bt_len = backtrace(new_alloc->bt, BT_MAX);
45         new_alloc->alloc_len = len;
46         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
47         new_alloc->next = allocation_ll;
48         allocation_ll = new_alloc;
49         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
50 }
51 static void* MALLOC(size_t len, const char* struct_name) {
52         void* res = __real_malloc(len);
53         new_allocation(res, struct_name, len);
54         return res;
55 }
56 void __real_free(void* ptr);
57 static void alloc_freed(void* ptr) {
58         allocation* p = NULL;
59         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
60         allocation* it = allocation_ll;
61         while (it->ptr != ptr) {
62                 p = it; it = it->next;
63                 if (it == NULL) {
64                         fprintf(stderr, "Tried to free unknown pointer %p at:\n", ptr);
65                         void* bt[BT_MAX];
66                         int bt_len = backtrace(bt, BT_MAX);
67                         backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
68                         fprintf(stderr, "\n\n");
69                         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
70                         return; // addrsan should catch malloc-unknown and print more info than we have
71                 }
72         }
73         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
74         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
75         DO_ASSERT(it->ptr == ptr);
76         __real_free(it);
77 }
78 static void FREE(void* ptr) {
79         if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
80         alloc_freed(ptr);
81         __real_free(ptr);
82 }
83
84 void* __wrap_malloc(size_t len) {
85         void* res = __real_malloc(len);
86         new_allocation(res, "malloc call", len);
87         return res;
88 }
89 void* __wrap_calloc(size_t nmemb, size_t len) {
90         void* res = __real_calloc(nmemb, len);
91         new_allocation(res, "calloc call", len);
92         return res;
93 }
94 void __wrap_free(void* ptr) {
95         if (ptr == NULL) return;
96         alloc_freed(ptr);
97         __real_free(ptr);
98 }
99
100 void* __real_realloc(void* ptr, size_t newlen);
101 void* __wrap_realloc(void* ptr, size_t len) {
102         if (ptr != NULL) alloc_freed(ptr);
103         void* res = __real_realloc(ptr, len);
104         new_allocation(res, "realloc call", len);
105         return res;
106 }
107 void __wrap_reallocarray(void* ptr, size_t new_sz) {
108         // Rust doesn't seem to use reallocarray currently
109         DO_ASSERT(false);
110 }
111
112 void __attribute__((destructor)) check_leaks() {
113         size_t alloc_count = 0;
114         size_t alloc_size = 0;
115         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
116                 fprintf(stderr, "%s %p (%lu bytes) remains:\n", a->struct_name, a->ptr, a->alloc_len);
117                 backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
118                 fprintf(stderr, "\n\n");
119                 alloc_count++;
120                 alloc_size += a->alloc_len;
121         }
122         fprintf(stderr, "%lu allocations remained for %lu bytes.\n", alloc_count, alloc_size);
123         DO_ASSERT(allocation_ll == NULL);
124 }
125
126 static jmethodID ordinal_meth = NULL;
127 static jmethodID slicedef_meth = NULL;
128 static jclass slicedef_cls = NULL;
129 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
130         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
131         CHECK(ordinal_meth != NULL);
132         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
133         CHECK(slicedef_meth != NULL);
134         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
135         CHECK(slicedef_cls != NULL);
136 }
137
138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
139         return *((bool*)ptr);
140 }
141 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
142         return *((long*)ptr);
143 }
144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
145         FREE((void*)ptr);
146 }
147 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
148         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
149         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
150         return ret_arr;
151 }
152 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
153         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
154         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
155         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
156         return ret_arr;
157 }
158 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
159         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
160         vec->datalen = (*env)->GetArrayLength(env, bytes);
161         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
162         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
163         return (long)vec;
164 }
165 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
166         LDKTransaction *txdata = (LDKTransaction*)ptr;
167         LDKu8slice slice;
168         slice.data = txdata->data;
169         slice.datalen = txdata->datalen;
170         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (long)&slice);
171 }
172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
173         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
174         txdata->datalen = (*env)->GetArrayLength(env, bytes);
175         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
176         txdata->data_is_owned = false;
177         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
178         return (long)txdata;
179 }
180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
181         LDKTransaction *tx = (LDKTransaction*)ptr;
182         tx->data_is_owned = true;
183         Transaction_free(*tx);
184         FREE((void*)ptr);
185 }
186 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
187         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
188         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
189         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
190         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
191         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
192         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
193         return (long)vec->datalen;
194 }
195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
196         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
197         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
198         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
199         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
200         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
201         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
202         vec->data = NULL;
203         vec->datalen = 0;
204         return (long)vec;
205 }
206
207 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
208 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
209 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
210 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
211
212 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
213 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
214 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
215
216 typedef jlongArray int64_tArray;
217 typedef jbyteArray int8_tArray;
218
219 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
220         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
221         char* err_buf = MALLOC(len + 1, "str conv buf");
222         memcpy(err_buf, chars, len);
223         err_buf[len] = 0;
224         jstring err_conv = (*env)->NewStringUTF(env, chars);
225         FREE(err_buf);
226         return err_conv;
227 }
228 static jclass arr_of_J_clz = NULL;
229 static jclass arr_of_B_clz = NULL;
230 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
231         arr_of_J_clz = (*env)->FindClass(env, "[J");
232         CHECK(arr_of_J_clz != NULL);
233         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
234         arr_of_B_clz = (*env)->FindClass(env, "[B");
235         CHECK(arr_of_B_clz != NULL);
236         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
237 }
238 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
239 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
240         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
241                 case 0: return LDKAccessError_UnknownChain;
242                 case 1: return LDKAccessError_UnknownTx;
243         }
244         abort();
245 }
246 static jclass LDKAccessError_class = NULL;
247 static jfieldID LDKAccessError_LDKAccessError_UnknownChain = NULL;
248 static jfieldID LDKAccessError_LDKAccessError_UnknownTx = NULL;
249 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKAccessError_init (JNIEnv *env, jclass clz) {
250         LDKAccessError_class = (*env)->NewGlobalRef(env, clz);
251         CHECK(LDKAccessError_class != NULL);
252         LDKAccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/LDKAccessError;");
253         CHECK(LDKAccessError_LDKAccessError_UnknownChain != NULL);
254         LDKAccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/LDKAccessError;");
255         CHECK(LDKAccessError_LDKAccessError_UnknownTx != NULL);
256 }
257 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
258         switch (val) {
259                 case LDKAccessError_UnknownChain:
260                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownChain);
261                 case LDKAccessError_UnknownTx:
262                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownTx);
263                 default: abort();
264         }
265 }
266
267 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
268         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
269                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
270                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
271         }
272         abort();
273 }
274 static jclass LDKChannelMonitorUpdateErr_class = NULL;
275 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
276 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
277 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
278         LDKChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
279         CHECK(LDKChannelMonitorUpdateErr_class != NULL);
280         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
281         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
282         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
283         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
284 }
285 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
286         switch (val) {
287                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
288                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
289                 case LDKChannelMonitorUpdateErr_PermanentFailure:
290                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
291                 default: abort();
292         }
293 }
294
295 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
296         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
297                 case 0: return LDKConfirmationTarget_Background;
298                 case 1: return LDKConfirmationTarget_Normal;
299                 case 2: return LDKConfirmationTarget_HighPriority;
300         }
301         abort();
302 }
303 static jclass LDKConfirmationTarget_class = NULL;
304 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Background = NULL;
305 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
306 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
307 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKConfirmationTarget_init (JNIEnv *env, jclass clz) {
308         LDKConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
309         CHECK(LDKConfirmationTarget_class != NULL);
310         LDKConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/LDKConfirmationTarget;");
311         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Background != NULL);
312         LDKConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/LDKConfirmationTarget;");
313         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
314         LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/LDKConfirmationTarget;");
315         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
316 }
317 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
318         switch (val) {
319                 case LDKConfirmationTarget_Background:
320                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Background);
321                 case LDKConfirmationTarget_Normal:
322                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Normal);
323                 case LDKConfirmationTarget_HighPriority:
324                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_HighPriority);
325                 default: abort();
326         }
327 }
328
329 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
330         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
331                 case 0: return LDKLevel_Off;
332                 case 1: return LDKLevel_Error;
333                 case 2: return LDKLevel_Warn;
334                 case 3: return LDKLevel_Info;
335                 case 4: return LDKLevel_Debug;
336                 case 5: return LDKLevel_Trace;
337         }
338         abort();
339 }
340 static jclass LDKLevel_class = NULL;
341 static jfieldID LDKLevel_LDKLevel_Off = NULL;
342 static jfieldID LDKLevel_LDKLevel_Error = NULL;
343 static jfieldID LDKLevel_LDKLevel_Warn = NULL;
344 static jfieldID LDKLevel_LDKLevel_Info = NULL;
345 static jfieldID LDKLevel_LDKLevel_Debug = NULL;
346 static jfieldID LDKLevel_LDKLevel_Trace = NULL;
347 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKLevel_init (JNIEnv *env, jclass clz) {
348         LDKLevel_class = (*env)->NewGlobalRef(env, clz);
349         CHECK(LDKLevel_class != NULL);
350         LDKLevel_LDKLevel_Off = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
351         CHECK(LDKLevel_LDKLevel_Off != NULL);
352         LDKLevel_LDKLevel_Error = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
353         CHECK(LDKLevel_LDKLevel_Error != NULL);
354         LDKLevel_LDKLevel_Warn = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
355         CHECK(LDKLevel_LDKLevel_Warn != NULL);
356         LDKLevel_LDKLevel_Info = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
357         CHECK(LDKLevel_LDKLevel_Info != NULL);
358         LDKLevel_LDKLevel_Debug = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
359         CHECK(LDKLevel_LDKLevel_Debug != NULL);
360         LDKLevel_LDKLevel_Trace = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
361         CHECK(LDKLevel_LDKLevel_Trace != NULL);
362 }
363 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
364         switch (val) {
365                 case LDKLevel_Off:
366                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Off);
367                 case LDKLevel_Error:
368                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Error);
369                 case LDKLevel_Warn:
370                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Warn);
371                 case LDKLevel_Info:
372                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Info);
373                 case LDKLevel_Debug:
374                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Debug);
375                 case LDKLevel_Trace:
376                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Trace);
377                 default: abort();
378         }
379 }
380
381 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
382         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
383                 case 0: return LDKNetwork_Bitcoin;
384                 case 1: return LDKNetwork_Testnet;
385                 case 2: return LDKNetwork_Regtest;
386         }
387         abort();
388 }
389 static jclass LDKNetwork_class = NULL;
390 static jfieldID LDKNetwork_LDKNetwork_Bitcoin = NULL;
391 static jfieldID LDKNetwork_LDKNetwork_Testnet = NULL;
392 static jfieldID LDKNetwork_LDKNetwork_Regtest = NULL;
393 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKNetwork_init (JNIEnv *env, jclass clz) {
394         LDKNetwork_class = (*env)->NewGlobalRef(env, clz);
395         CHECK(LDKNetwork_class != NULL);
396         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
397         CHECK(LDKNetwork_LDKNetwork_Bitcoin != NULL);
398         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
399         CHECK(LDKNetwork_LDKNetwork_Testnet != NULL);
400         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
401         CHECK(LDKNetwork_LDKNetwork_Regtest != NULL);
402 }
403 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
404         switch (val) {
405                 case LDKNetwork_Bitcoin:
406                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Bitcoin);
407                 case LDKNetwork_Testnet:
408                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Testnet);
409                 case LDKNetwork_Regtest:
410                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Regtest);
411                 default: abort();
412         }
413 }
414
415 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
416         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
417                 case 0: return LDKSecp256k1Error_IncorrectSignature;
418                 case 1: return LDKSecp256k1Error_InvalidMessage;
419                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
420                 case 3: return LDKSecp256k1Error_InvalidSignature;
421                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
422                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
423                 case 6: return LDKSecp256k1Error_InvalidTweak;
424                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
425                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
426         }
427         abort();
428 }
429 static jclass LDKSecp256k1Error_class = NULL;
430 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
431 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
432 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
433 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
434 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
435 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
436 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
437 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
438 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
439 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKSecp256k1Error_init (JNIEnv *env, jclass clz) {
440         LDKSecp256k1Error_class = (*env)->NewGlobalRef(env, clz);
441         CHECK(LDKSecp256k1Error_class != NULL);
442         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
443         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
444         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
445         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
446         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
447         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
448         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
449         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
450         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
451         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
452         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
453         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
454         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
455         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
456         LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/LDKSecp256k1Error;");
457         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
458         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
459         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
460 }
461 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
462         switch (val) {
463                 case LDKSecp256k1Error_IncorrectSignature:
464                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature);
465                 case LDKSecp256k1Error_InvalidMessage:
466                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage);
467                 case LDKSecp256k1Error_InvalidPublicKey:
468                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
469                 case LDKSecp256k1Error_InvalidSignature:
470                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature);
471                 case LDKSecp256k1Error_InvalidSecretKey:
472                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
473                 case LDKSecp256k1Error_InvalidRecoveryId:
474                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
475                 case LDKSecp256k1Error_InvalidTweak:
476                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak);
477                 case LDKSecp256k1Error_TweakCheckFailed:
478                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
479                 case LDKSecp256k1Error_NotEnoughMemory:
480                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
481                 default: abort();
482         }
483 }
484
485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
486         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
487         ret->datalen = (*env)->GetArrayLength(env, elems);
488         if (ret->datalen == 0) {
489                 ret->data = NULL;
490         } else {
491                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
492                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
493                 for (size_t i = 0; i < ret->datalen; i++) {
494                         ret->data[i] = java_elems[i];
495                 }
496                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
497         }
498         return (long)ret;
499 }
500 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
501         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
502         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
503         return ret;
504 }
505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
506         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
507 }
508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
509         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
510         CHECK(val->result_ok);
511         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
512         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
513         return res_arr;
514 }
515 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
516         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
517         CHECK(!val->result_ok);
518         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
519         return err_conv;
520 }
521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
522         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
523 }
524 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
525         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
526         CHECK(val->result_ok);
527         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
528         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
529         return res_arr;
530 }
531 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
532         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
533         CHECK(!val->result_ok);
534         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
535         return err_conv;
536 }
537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
538         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
539 }
540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
541         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
542         CHECK(val->result_ok);
543         LDKTxCreationKeys res_var = (*val->contents.result);
544         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
545         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
546         long res_ref = (long)res_var.inner & ~1;
547         return res_ref;
548 }
549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
550         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
551         CHECK(!val->result_ok);
552         LDKDecodeError err_var = (*val->contents.err);
553         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
554         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
555         long err_ref = (long)err_var.inner & ~1;
556         return err_ref;
557 }
558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
559         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
560 }
561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
562         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
563         CHECK(val->result_ok);
564         LDKChannelPublicKeys res_var = (*val->contents.result);
565         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
566         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
567         long res_ref = (long)res_var.inner & ~1;
568         return res_ref;
569 }
570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
571         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
572         CHECK(!val->result_ok);
573         LDKDecodeError err_var = (*val->contents.err);
574         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
575         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
576         long err_ref = (long)err_var.inner & ~1;
577         return err_ref;
578 }
579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
580         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
581 }
582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
583         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
584         CHECK(val->result_ok);
585         LDKTxCreationKeys res_var = (*val->contents.result);
586         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
587         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
588         long res_ref = (long)res_var.inner & ~1;
589         return res_ref;
590 }
591 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
592         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
593         CHECK(!val->result_ok);
594         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
595         return err_conv;
596 }
597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
598         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
599 }
600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
601         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
602         CHECK(val->result_ok);
603         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
604         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
605         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
606         long res_ref = (long)res_var.inner & ~1;
607         return res_ref;
608 }
609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
610         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
611         CHECK(!val->result_ok);
612         LDKDecodeError err_var = (*val->contents.err);
613         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
614         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
615         long err_ref = (long)err_var.inner & ~1;
616         return err_ref;
617 }
618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
619         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
620 }
621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
622         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
623         CHECK(val->result_ok);
624         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
625         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
626         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
627         long res_ref = (long)res_var.inner & ~1;
628         return res_ref;
629 }
630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
631         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
632         CHECK(!val->result_ok);
633         LDKDecodeError err_var = (*val->contents.err);
634         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
635         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
636         long err_ref = (long)err_var.inner & ~1;
637         return err_ref;
638 }
639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
640         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
641 }
642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
643         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
644         CHECK(val->result_ok);
645         LDKChannelTransactionParameters res_var = (*val->contents.result);
646         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
647         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
648         long res_ref = (long)res_var.inner & ~1;
649         return res_ref;
650 }
651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
652         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
653         CHECK(!val->result_ok);
654         LDKDecodeError err_var = (*val->contents.err);
655         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
656         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
657         long err_ref = (long)err_var.inner & ~1;
658         return err_ref;
659 }
660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
661         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
662 }
663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
664         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
665         CHECK(val->result_ok);
666         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
667         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
668         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
669         long res_ref = (long)res_var.inner & ~1;
670         return res_ref;
671 }
672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
673         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
674         CHECK(!val->result_ok);
675         LDKDecodeError err_var = (*val->contents.err);
676         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
677         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
678         long err_ref = (long)err_var.inner & ~1;
679         return err_ref;
680 }
681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
682         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
683 }
684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
685         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
686         CHECK(val->result_ok);
687         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
688         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
689         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
690         long res_ref = (long)res_var.inner & ~1;
691         return res_ref;
692 }
693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
694         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
695         CHECK(!val->result_ok);
696         LDKDecodeError err_var = (*val->contents.err);
697         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
698         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
699         long err_ref = (long)err_var.inner & ~1;
700         return err_ref;
701 }
702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
703         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
704 }
705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
706         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
707         CHECK(val->result_ok);
708         LDKCommitmentTransaction res_var = (*val->contents.result);
709         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
710         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
711         long res_ref = (long)res_var.inner & ~1;
712         return res_ref;
713 }
714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
715         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
716         CHECK(!val->result_ok);
717         LDKDecodeError err_var = (*val->contents.err);
718         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
719         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
720         long err_ref = (long)err_var.inner & ~1;
721         return err_ref;
722 }
723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
724         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
725 }
726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
727         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
728         CHECK(val->result_ok);
729         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
730         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
731         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
732         long res_ref = (long)res_var.inner & ~1;
733         return res_ref;
734 }
735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
736         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
737         CHECK(!val->result_ok);
738         return *val->contents.err;
739 }
740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
741         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
742 }
743 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
744         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
745         CHECK(val->result_ok);
746         LDKCVec_SignatureZ res_var = (*val->contents.result);
747         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
748         ;
749         for (size_t i = 0; i < res_var.datalen; i++) {
750                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
751                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
752                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
753         }
754         return res_arr;
755 }
756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
757         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
758         CHECK(!val->result_ok);
759         return *val->contents.err;
760 }
761 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
762         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
763 }
764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
765         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
766         CHECK(val->result_ok);
767         LDKCVec_u8Z res_var = (*val->contents.result);
768         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
769         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
770         return res_arr;
771 }
772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
773         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
774         CHECK(!val->result_ok);
775         LDKPeerHandleError err_var = (*val->contents.err);
776         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
777         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
778         long err_ref = (long)err_var.inner & ~1;
779         return err_ref;
780 }
781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
782         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
783 }
784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
785         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
786         CHECK(val->result_ok);
787         return *val->contents.result;
788 }
789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
790         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
791         CHECK(!val->result_ok);
792         LDKPeerHandleError err_var = (*val->contents.err);
793         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
794         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
795         long err_ref = (long)err_var.inner & ~1;
796         return err_ref;
797 }
798 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
799         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
800 }
801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
802         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
803         CHECK(val->result_ok);
804         return *val->contents.result;
805 }
806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
807         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
808         CHECK(!val->result_ok);
809         LDKPeerHandleError err_var = (*val->contents.err);
810         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
811         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
812         long err_ref = (long)err_var.inner & ~1;
813         return err_ref;
814 }
815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
816         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
817 }
818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
819         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
820         CHECK(val->result_ok);
821         LDKInitFeatures res_var = (*val->contents.result);
822         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
823         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
824         long res_ref = (long)res_var.inner & ~1;
825         return res_ref;
826 }
827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
828         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
829         CHECK(!val->result_ok);
830         LDKDecodeError err_var = (*val->contents.err);
831         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
832         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
833         long err_ref = (long)err_var.inner & ~1;
834         return err_ref;
835 }
836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
837         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
838 }
839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
840         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
841         CHECK(val->result_ok);
842         LDKNodeFeatures res_var = (*val->contents.result);
843         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
844         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
845         long res_ref = (long)res_var.inner & ~1;
846         return res_ref;
847 }
848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
849         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
850         CHECK(!val->result_ok);
851         LDKDecodeError err_var = (*val->contents.err);
852         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
853         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
854         long err_ref = (long)err_var.inner & ~1;
855         return err_ref;
856 }
857 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
858         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
859 }
860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
861         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
862         CHECK(val->result_ok);
863         LDKChannelFeatures res_var = (*val->contents.result);
864         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
865         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
866         long res_ref = (long)res_var.inner & ~1;
867         return res_ref;
868 }
869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
870         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
871         CHECK(!val->result_ok);
872         LDKDecodeError err_var = (*val->contents.err);
873         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
874         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
875         long err_ref = (long)err_var.inner & ~1;
876         return err_ref;
877 }
878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
879         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
880 }
881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
882         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
883         CHECK(val->result_ok);
884         LDKChannelConfig res_var = (*val->contents.result);
885         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
886         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
887         long res_ref = (long)res_var.inner & ~1;
888         return res_ref;
889 }
890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
891         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
892         CHECK(!val->result_ok);
893         LDKDecodeError err_var = (*val->contents.err);
894         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
895         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
896         long err_ref = (long)err_var.inner & ~1;
897         return err_ref;
898 }
899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
900         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
901 }
902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
903         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
904         CHECK(val->result_ok);
905         return *val->contents.result;
906 }
907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
908         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
909         CHECK(!val->result_ok);
910         LDKLightningError err_var = (*val->contents.err);
911         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
912         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
913         long err_ref = (long)err_var.inner & ~1;
914         return err_ref;
915 }
916 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) {
917         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
918         LDKChannelAnnouncement a_conv;
919         a_conv.inner = (void*)(a & (~1));
920         a_conv.is_owned = (a & 1) || (a == 0);
921         a_conv = ChannelAnnouncement_clone(&a_conv);
922         ret->a = a_conv;
923         LDKChannelUpdate b_conv;
924         b_conv.inner = (void*)(b & (~1));
925         b_conv.is_owned = (b & 1) || (b == 0);
926         b_conv = ChannelUpdate_clone(&b_conv);
927         ret->b = b_conv;
928         LDKChannelUpdate c_conv;
929         c_conv.inner = (void*)(c & (~1));
930         c_conv.is_owned = (c & 1) || (c == 0);
931         c_conv = ChannelUpdate_clone(&c_conv);
932         ret->c = c_conv;
933         return (long)ret;
934 }
935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
936         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
937         LDKChannelAnnouncement a_var = tuple->a;
938         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
939         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
940         long a_ref = (long)a_var.inner & ~1;
941         return a_ref;
942 }
943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
944         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
945         LDKChannelUpdate b_var = tuple->b;
946         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
947         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
948         long b_ref = (long)b_var.inner & ~1;
949         return b_ref;
950 }
951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
952         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
953         LDKChannelUpdate c_var = tuple->c;
954         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
955         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
956         long c_ref = (long)c_var.inner & ~1;
957         return c_ref;
958 }
959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
960         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
961         ret->datalen = (*env)->GetArrayLength(env, elems);
962         if (ret->datalen == 0) {
963                 ret->data = NULL;
964         } else {
965                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
966                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
967                 for (size_t i = 0; i < ret->datalen; i++) {
968                         int64_t arr_elem = java_elems[i];
969                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
970                         FREE((void*)arr_elem);
971                         ret->data[i] = arr_elem_conv;
972                 }
973                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
974         }
975         return (long)ret;
976 }
977 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
978         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
979         for (size_t i = 0; i < ret.datalen; i++) {
980                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
981         }
982         return ret;
983 }
984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
985         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
986         ret->datalen = (*env)->GetArrayLength(env, elems);
987         if (ret->datalen == 0) {
988                 ret->data = NULL;
989         } else {
990                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
991                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
992                 for (size_t i = 0; i < ret->datalen; i++) {
993                         int64_t arr_elem = java_elems[i];
994                         LDKNodeAnnouncement arr_elem_conv;
995                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
996                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
997                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
998                         ret->data[i] = arr_elem_conv;
999                 }
1000                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1001         }
1002         return (long)ret;
1003 }
1004 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
1005         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
1006         for (size_t i = 0; i < ret.datalen; i++) {
1007                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
1008         }
1009         return ret;
1010 }
1011 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1012         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
1013 }
1014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1015         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
1016         CHECK(val->result_ok);
1017         return *val->contents.result;
1018 }
1019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1020         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
1021         CHECK(!val->result_ok);
1022         LDKLightningError err_var = (*val->contents.err);
1023         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1024         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1025         long err_ref = (long)err_var.inner & ~1;
1026         return err_ref;
1027 }
1028 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1029 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1030 static jclass LDKErrorAction_IgnoreError_class = NULL;
1031 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1032 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1033 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1035         LDKErrorAction_DisconnectPeer_class =
1036                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1037         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1038         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1039         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1040         LDKErrorAction_IgnoreError_class =
1041                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1042         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1043         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1044         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1045         LDKErrorAction_SendErrorMessage_class =
1046                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1047         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1048         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1049         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1050 }
1051 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1052         LDKErrorAction *obj = (LDKErrorAction*)ptr;
1053         switch(obj->tag) {
1054                 case LDKErrorAction_DisconnectPeer: {
1055                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1056                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1057                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1058                         long msg_ref = (long)msg_var.inner & ~1;
1059                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1060                 }
1061                 case LDKErrorAction_IgnoreError: {
1062                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1063                 }
1064                 case LDKErrorAction_SendErrorMessage: {
1065                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1066                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1067                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1068                         long msg_ref = (long)msg_var.inner & ~1;
1069                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1070                 }
1071                 default: abort();
1072         }
1073 }
1074 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1075 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1076 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1077 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1078 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1079 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1081         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1082                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1083         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1084         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1085         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1086         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1087                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1088         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1089         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1090         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1091         LDKHTLCFailChannelUpdate_NodeFailure_class =
1092                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1093         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1094         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1095         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1096 }
1097 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1098         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
1099         switch(obj->tag) {
1100                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1101                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1102                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1103                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1104                         long msg_ref = (long)msg_var.inner & ~1;
1105                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1106                 }
1107                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1108                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1109                 }
1110                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1111                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1112                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1113                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1114                 }
1115                 default: abort();
1116         }
1117 }
1118 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1119 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1120 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1121 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1122 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1123 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1124 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1125 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1126 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1127 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1128 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1129 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1130 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1131 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1132 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1133 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1134 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1135 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1136 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1137 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1138 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1139 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1140 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1141 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1142 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1143 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1144 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1145 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1146 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1147 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1148 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1149 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1150 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1151 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1152 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1153 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1155         LDKMessageSendEvent_SendAcceptChannel_class =
1156                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1157         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1158         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1159         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1160         LDKMessageSendEvent_SendOpenChannel_class =
1161                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1162         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1163         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1164         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1165         LDKMessageSendEvent_SendFundingCreated_class =
1166                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1167         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1168         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1169         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1170         LDKMessageSendEvent_SendFundingSigned_class =
1171                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1172         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1173         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1174         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1175         LDKMessageSendEvent_SendFundingLocked_class =
1176                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1177         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1178         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1179         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1180         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1181                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1182         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1183         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1184         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1185         LDKMessageSendEvent_UpdateHTLCs_class =
1186                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1187         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1188         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1189         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1190         LDKMessageSendEvent_SendRevokeAndACK_class =
1191                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1192         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1193         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1194         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1195         LDKMessageSendEvent_SendClosingSigned_class =
1196                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1197         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1198         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1199         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1200         LDKMessageSendEvent_SendShutdown_class =
1201                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1202         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1203         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1204         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1205         LDKMessageSendEvent_SendChannelReestablish_class =
1206                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1207         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1208         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1209         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1210         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1211                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1212         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1213         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1214         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1215         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1216                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1217         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1218         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1219         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1220         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1221                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1222         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1223         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1224         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1225         LDKMessageSendEvent_HandleError_class =
1226                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1227         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1228         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1229         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1230         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1231                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1232         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1233         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1234         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1235         LDKMessageSendEvent_SendChannelRangeQuery_class =
1236                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1237         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1238         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1239         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1240         LDKMessageSendEvent_SendShortIdsQuery_class =
1241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1242         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1243         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1244         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1245 }
1246 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1247         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1248         switch(obj->tag) {
1249                 case LDKMessageSendEvent_SendAcceptChannel: {
1250                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1251                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1252                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1253                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1254                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1255                         long msg_ref = (long)msg_var.inner & ~1;
1256                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1257                 }
1258                 case LDKMessageSendEvent_SendOpenChannel: {
1259                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1260                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1261                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1262                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1263                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1264                         long msg_ref = (long)msg_var.inner & ~1;
1265                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1266                 }
1267                 case LDKMessageSendEvent_SendFundingCreated: {
1268                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1269                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1270                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1271                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1272                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1273                         long msg_ref = (long)msg_var.inner & ~1;
1274                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1275                 }
1276                 case LDKMessageSendEvent_SendFundingSigned: {
1277                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1278                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1279                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1280                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1281                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1282                         long msg_ref = (long)msg_var.inner & ~1;
1283                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1284                 }
1285                 case LDKMessageSendEvent_SendFundingLocked: {
1286                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1287                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1288                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1289                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1290                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1291                         long msg_ref = (long)msg_var.inner & ~1;
1292                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1293                 }
1294                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1295                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1296                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1297                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1298                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1299                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1300                         long msg_ref = (long)msg_var.inner & ~1;
1301                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1302                 }
1303                 case LDKMessageSendEvent_UpdateHTLCs: {
1304                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1305                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1306                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1307                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1308                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1309                         long updates_ref = (long)updates_var.inner & ~1;
1310                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1311                 }
1312                 case LDKMessageSendEvent_SendRevokeAndACK: {
1313                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1314                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1315                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1316                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1317                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1318                         long msg_ref = (long)msg_var.inner & ~1;
1319                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1320                 }
1321                 case LDKMessageSendEvent_SendClosingSigned: {
1322                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1323                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1324                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1325                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1326                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1327                         long msg_ref = (long)msg_var.inner & ~1;
1328                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1329                 }
1330                 case LDKMessageSendEvent_SendShutdown: {
1331                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1332                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1333                         LDKShutdown msg_var = obj->send_shutdown.msg;
1334                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1335                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1336                         long msg_ref = (long)msg_var.inner & ~1;
1337                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1338                 }
1339                 case LDKMessageSendEvent_SendChannelReestablish: {
1340                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1341                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1342                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1343                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1344                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1345                         long msg_ref = (long)msg_var.inner & ~1;
1346                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1347                 }
1348                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1349                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1350                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1351                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1352                         long msg_ref = (long)msg_var.inner & ~1;
1353                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1354                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1355                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1356                         long update_msg_ref = (long)update_msg_var.inner & ~1;
1357                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1358                 }
1359                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1360                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1361                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1362                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1363                         long msg_ref = (long)msg_var.inner & ~1;
1364                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1365                 }
1366                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1367                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1368                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1369                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1370                         long msg_ref = (long)msg_var.inner & ~1;
1371                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1372                 }
1373                 case LDKMessageSendEvent_HandleError: {
1374                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1375                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1376                         long action_ref = ((long)&obj->handle_error.action) | 1;
1377                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1378                 }
1379                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1380                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
1381                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1382                 }
1383                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1384                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1385                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1386                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1387                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1388                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1389                         long msg_ref = (long)msg_var.inner & ~1;
1390                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1391                 }
1392                 case LDKMessageSendEvent_SendShortIdsQuery: {
1393                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1394                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1395                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1396                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1397                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1398                         long msg_ref = (long)msg_var.inner & ~1;
1399                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1400                 }
1401                 default: abort();
1402         }
1403 }
1404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1405         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1406         ret->datalen = (*env)->GetArrayLength(env, elems);
1407         if (ret->datalen == 0) {
1408                 ret->data = NULL;
1409         } else {
1410                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1411                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1412                 for (size_t i = 0; i < ret->datalen; i++) {
1413                         int64_t arr_elem = java_elems[i];
1414                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1415                         FREE((void*)arr_elem);
1416                         ret->data[i] = arr_elem_conv;
1417                 }
1418                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1419         }
1420         return (long)ret;
1421 }
1422 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1423         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1424         for (size_t i = 0; i < ret.datalen; i++) {
1425                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1426         }
1427         return ret;
1428 }
1429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1430         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
1431 }
1432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1433         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1434         CHECK(val->result_ok);
1435         LDKDirectionalChannelInfo res_var = (*val->contents.result);
1436         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1437         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1438         long res_ref = (long)res_var.inner & ~1;
1439         return res_ref;
1440 }
1441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1442         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1443         CHECK(!val->result_ok);
1444         LDKDecodeError err_var = (*val->contents.err);
1445         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1446         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1447         long err_ref = (long)err_var.inner & ~1;
1448         return err_ref;
1449 }
1450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1451         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
1452 }
1453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1454         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1455         CHECK(val->result_ok);
1456         LDKChannelInfo res_var = (*val->contents.result);
1457         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1458         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1459         long res_ref = (long)res_var.inner & ~1;
1460         return res_ref;
1461 }
1462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1463         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1464         CHECK(!val->result_ok);
1465         LDKDecodeError err_var = (*val->contents.err);
1466         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1467         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1468         long err_ref = (long)err_var.inner & ~1;
1469         return err_ref;
1470 }
1471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1472         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
1473 }
1474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1475         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1476         CHECK(val->result_ok);
1477         LDKRoutingFees res_var = (*val->contents.result);
1478         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1479         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1480         long res_ref = (long)res_var.inner & ~1;
1481         return res_ref;
1482 }
1483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1484         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1485         CHECK(!val->result_ok);
1486         LDKDecodeError err_var = (*val->contents.err);
1487         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1488         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1489         long err_ref = (long)err_var.inner & ~1;
1490         return err_ref;
1491 }
1492 static jclass LDKNetAddress_IPv4_class = NULL;
1493 static jmethodID LDKNetAddress_IPv4_meth = NULL;
1494 static jclass LDKNetAddress_IPv6_class = NULL;
1495 static jmethodID LDKNetAddress_IPv6_meth = NULL;
1496 static jclass LDKNetAddress_OnionV2_class = NULL;
1497 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
1498 static jclass LDKNetAddress_OnionV3_class = NULL;
1499 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
1500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
1501         LDKNetAddress_IPv4_class =
1502                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
1503         CHECK(LDKNetAddress_IPv4_class != NULL);
1504         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
1505         CHECK(LDKNetAddress_IPv4_meth != NULL);
1506         LDKNetAddress_IPv6_class =
1507                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
1508         CHECK(LDKNetAddress_IPv6_class != NULL);
1509         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
1510         CHECK(LDKNetAddress_IPv6_meth != NULL);
1511         LDKNetAddress_OnionV2_class =
1512                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
1513         CHECK(LDKNetAddress_OnionV2_class != NULL);
1514         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
1515         CHECK(LDKNetAddress_OnionV2_meth != NULL);
1516         LDKNetAddress_OnionV3_class =
1517                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
1518         CHECK(LDKNetAddress_OnionV3_class != NULL);
1519         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
1520         CHECK(LDKNetAddress_OnionV3_meth != NULL);
1521 }
1522 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1523         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1524         switch(obj->tag) {
1525                 case LDKNetAddress_IPv4: {
1526                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
1527                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
1528                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
1529                 }
1530                 case LDKNetAddress_IPv6: {
1531                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
1532                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
1533                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
1534                 }
1535                 case LDKNetAddress_OnionV2: {
1536                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
1537                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
1538                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
1539                 }
1540                 case LDKNetAddress_OnionV3: {
1541                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
1542                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
1543                         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);
1544                 }
1545                 default: abort();
1546         }
1547 }
1548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1549         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1550         ret->datalen = (*env)->GetArrayLength(env, elems);
1551         if (ret->datalen == 0) {
1552                 ret->data = NULL;
1553         } else {
1554                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1555                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1556                 for (size_t i = 0; i < ret->datalen; i++) {
1557                         int64_t arr_elem = java_elems[i];
1558                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
1559                         FREE((void*)arr_elem);
1560                         ret->data[i] = arr_elem_conv;
1561                 }
1562                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1563         }
1564         return (long)ret;
1565 }
1566 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1567         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1568         for (size_t i = 0; i < ret.datalen; i++) {
1569                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1570         }
1571         return ret;
1572 }
1573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1574         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
1575 }
1576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1577         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1578         CHECK(val->result_ok);
1579         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
1580         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1581         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1582         long res_ref = (long)res_var.inner & ~1;
1583         return res_ref;
1584 }
1585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1586         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1587         CHECK(!val->result_ok);
1588         LDKDecodeError err_var = (*val->contents.err);
1589         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1590         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1591         long err_ref = (long)err_var.inner & ~1;
1592         return err_ref;
1593 }
1594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1595         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1596         ret->datalen = (*env)->GetArrayLength(env, elems);
1597         if (ret->datalen == 0) {
1598                 ret->data = NULL;
1599         } else {
1600                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1601                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1602                 for (size_t i = 0; i < ret->datalen; i++) {
1603                         ret->data[i] = java_elems[i];
1604                 }
1605                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1606         }
1607         return (long)ret;
1608 }
1609 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1610         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1611         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1612         return ret;
1613 }
1614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1615         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
1616 }
1617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1618         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1619         CHECK(val->result_ok);
1620         LDKNodeInfo res_var = (*val->contents.result);
1621         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1622         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1623         long res_ref = (long)res_var.inner & ~1;
1624         return res_ref;
1625 }
1626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1627         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1628         CHECK(!val->result_ok);
1629         LDKDecodeError err_var = (*val->contents.err);
1630         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1631         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1632         long err_ref = (long)err_var.inner & ~1;
1633         return err_ref;
1634 }
1635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1636         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
1637 }
1638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1639         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1640         CHECK(val->result_ok);
1641         LDKNetworkGraph res_var = (*val->contents.result);
1642         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1643         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1644         long res_ref = (long)res_var.inner & ~1;
1645         return res_ref;
1646 }
1647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1648         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1649         CHECK(!val->result_ok);
1650         LDKDecodeError err_var = (*val->contents.err);
1651         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1652         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1653         long err_ref = (long)err_var.inner & ~1;
1654         return err_ref;
1655 }
1656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1657         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1658         ret->a = a;
1659         LDKTransaction b_ref;
1660         b_ref.datalen = (*env)->GetArrayLength(env, b);
1661         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1662         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1663         b_ref.data_is_owned = false;
1664         ret->b = b_ref;
1665         return (long)ret;
1666 }
1667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1668         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1669         return tuple->a;
1670 }
1671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1672         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1673         LDKTransaction b_var = tuple->b;
1674         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1675         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1676         return b_arr;
1677 }
1678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1679         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1680         ret->datalen = (*env)->GetArrayLength(env, elems);
1681         if (ret->datalen == 0) {
1682                 ret->data = NULL;
1683         } else {
1684                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1685                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1686                 for (size_t i = 0; i < ret->datalen; i++) {
1687                         int64_t arr_elem = java_elems[i];
1688                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1689                         FREE((void*)arr_elem);
1690                         ret->data[i] = arr_elem_conv;
1691                 }
1692                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1693         }
1694         return (long)ret;
1695 }
1696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1697         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1698 }
1699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1700         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1701         CHECK(val->result_ok);
1702         return *val->contents.result;
1703 }
1704 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1705         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1706         CHECK(!val->result_ok);
1707         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1708         return err_conv;
1709 }
1710 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1711 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1712 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1713 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1715         LDKMonitorEvent_HTLCEvent_class =
1716                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1717         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1718         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "()V");
1719         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1720         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1722         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1723         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "()V");
1724         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1725 }
1726 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1727         LDKMonitorEvent *obj = (LDKMonitorEvent*)ptr;
1728         switch(obj->tag) {
1729                 case LDKMonitorEvent_HTLCEvent: {
1730                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth);
1731                 }
1732                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1733                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth);
1734                 }
1735                 default: abort();
1736         }
1737 }
1738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1739         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1740         ret->datalen = (*env)->GetArrayLength(env, elems);
1741         if (ret->datalen == 0) {
1742                 ret->data = NULL;
1743         } else {
1744                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1745                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1746                 for (size_t i = 0; i < ret->datalen; i++) {
1747                         int64_t arr_elem = java_elems[i];
1748                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1749                         FREE((void*)arr_elem);
1750                         ret->data[i] = arr_elem_conv;
1751                 }
1752                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1753         }
1754         return (long)ret;
1755 }
1756 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1757         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1758         for (size_t i = 0; i < ret.datalen; i++) {
1759                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1760         }
1761         return ret;
1762 }
1763 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1764 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1765 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1766 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1767 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1768 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1770         LDKSpendableOutputDescriptor_StaticOutput_class =
1771                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1772         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1773         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1774         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1775         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1776                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1777         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1778         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "()V");
1779         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1780         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1781                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1782         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1783         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "()V");
1784         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1785 }
1786 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1787         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
1788         switch(obj->tag) {
1789                 case LDKSpendableOutputDescriptor_StaticOutput: {
1790                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1791                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1792                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1793                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1794                         long output_ref = ((long)&obj->static_output.output) | 1;
1795                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (long)output_ref);
1796                 }
1797                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1798                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth);
1799                 }
1800                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1801                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth);
1802                 }
1803                 default: abort();
1804         }
1805 }
1806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1807         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1808         ret->datalen = (*env)->GetArrayLength(env, elems);
1809         if (ret->datalen == 0) {
1810                 ret->data = NULL;
1811         } else {
1812                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1813                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1814                 for (size_t i = 0; i < ret->datalen; i++) {
1815                         int64_t arr_elem = java_elems[i];
1816                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1817                         FREE((void*)arr_elem);
1818                         ret->data[i] = arr_elem_conv;
1819                 }
1820                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1821         }
1822         return (long)ret;
1823 }
1824 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1825         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1826         for (size_t i = 0; i < ret.datalen; i++) {
1827                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1828         }
1829         return ret;
1830 }
1831 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1832 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1833 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
1834 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
1835 static jclass LDKEvent_PaymentReceived_class = NULL;
1836 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1837 static jclass LDKEvent_PaymentSent_class = NULL;
1838 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1839 static jclass LDKEvent_PaymentFailed_class = NULL;
1840 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
1841 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1842 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1843 static jclass LDKEvent_SpendableOutputs_class = NULL;
1844 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1846         LDKEvent_FundingGenerationReady_class =
1847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
1848         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1849         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1850         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1851         LDKEvent_FundingBroadcastSafe_class =
1852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
1853         CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
1854         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
1855         CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
1856         LDKEvent_PaymentReceived_class =
1857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
1858         CHECK(LDKEvent_PaymentReceived_class != NULL);
1859         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
1860         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1861         LDKEvent_PaymentSent_class =
1862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
1863         CHECK(LDKEvent_PaymentSent_class != NULL);
1864         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
1865         CHECK(LDKEvent_PaymentSent_meth != NULL);
1866         LDKEvent_PaymentFailed_class =
1867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
1868         CHECK(LDKEvent_PaymentFailed_class != NULL);
1869         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
1870         CHECK(LDKEvent_PaymentFailed_meth != NULL);
1871         LDKEvent_PendingHTLCsForwardable_class =
1872                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
1873         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1874         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1875         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1876         LDKEvent_SpendableOutputs_class =
1877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
1878         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1879         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1880         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1881 }
1882 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1883         LDKEvent *obj = (LDKEvent*)ptr;
1884         switch(obj->tag) {
1885                 case LDKEvent_FundingGenerationReady: {
1886                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1887                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1888                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1889                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1890                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
1891                         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);
1892                 }
1893                 case LDKEvent_FundingBroadcastSafe: {
1894                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
1895                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1896                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1897                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
1898                         return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
1899                 }
1900                 case LDKEvent_PaymentReceived: {
1901                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1902                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
1903                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1904                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
1905                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
1906                 }
1907                 case LDKEvent_PaymentSent: {
1908                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1909                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
1910                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
1911                 }
1912                 case LDKEvent_PaymentFailed: {
1913                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1914                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
1915                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
1916                 }
1917                 case LDKEvent_PendingHTLCsForwardable: {
1918                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
1919                 }
1920                 case LDKEvent_SpendableOutputs: {
1921                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1922                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
1923                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
1924                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1925                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1926                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1927                         }
1928                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
1929                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
1930                 }
1931                 default: abort();
1932         }
1933 }
1934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1935         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1936         ret->datalen = (*env)->GetArrayLength(env, elems);
1937         if (ret->datalen == 0) {
1938                 ret->data = NULL;
1939         } else {
1940                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1941                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1942                 for (size_t i = 0; i < ret->datalen; i++) {
1943                         int64_t arr_elem = java_elems[i];
1944                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1945                         FREE((void*)arr_elem);
1946                         ret->data[i] = arr_elem_conv;
1947                 }
1948                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1949         }
1950         return (long)ret;
1951 }
1952 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1953         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1954         for (size_t i = 0; i < ret.datalen; i++) {
1955                 ret.data[i] = Event_clone(&orig->data[i]);
1956         }
1957         return ret;
1958 }
1959 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1960         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
1961 }
1962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1963         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1964         CHECK(val->result_ok);
1965         LDKOutPoint res_var = (*val->contents.result);
1966         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1967         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1968         long res_ref = (long)res_var.inner & ~1;
1969         return res_ref;
1970 }
1971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1972         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1973         CHECK(!val->result_ok);
1974         LDKDecodeError err_var = (*val->contents.err);
1975         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1976         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1977         long err_ref = (long)err_var.inner & ~1;
1978         return err_ref;
1979 }
1980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1981         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
1982 }
1983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1984         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1985         CHECK(val->result_ok);
1986         LDKChannelMonitorUpdate res_var = (*val->contents.result);
1987         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1988         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1989         long res_ref = (long)res_var.inner & ~1;
1990         return res_ref;
1991 }
1992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1993         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1994         CHECK(!val->result_ok);
1995         LDKDecodeError err_var = (*val->contents.err);
1996         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1997         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1998         long err_ref = (long)err_var.inner & ~1;
1999         return err_ref;
2000 }
2001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2002         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
2003 }
2004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2005         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
2006         CHECK(val->result_ok);
2007         LDKHTLCUpdate res_var = (*val->contents.result);
2008         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2009         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2010         long res_ref = (long)res_var.inner & ~1;
2011         return res_ref;
2012 }
2013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2014         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
2015         CHECK(!val->result_ok);
2016         LDKDecodeError err_var = (*val->contents.err);
2017         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2018         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2019         long err_ref = (long)err_var.inner & ~1;
2020         return err_ref;
2021 }
2022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2023         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
2024 }
2025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2026         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
2027         CHECK(val->result_ok);
2028         return *val->contents.result;
2029 }
2030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2031         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
2032         CHECK(!val->result_ok);
2033         LDKMonitorUpdateError err_var = (*val->contents.err);
2034         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2035         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2036         long err_ref = (long)err_var.inner & ~1;
2037         return err_ref;
2038 }
2039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
2040         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
2041         LDKOutPoint a_conv;
2042         a_conv.inner = (void*)(a & (~1));
2043         a_conv.is_owned = (a & 1) || (a == 0);
2044         a_conv = OutPoint_clone(&a_conv);
2045         ret->a = a_conv;
2046         LDKCVec_u8Z b_ref;
2047         b_ref.datalen = (*env)->GetArrayLength(env, b);
2048         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
2049         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
2050         ret->b = b_ref;
2051         return (long)ret;
2052 }
2053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2054         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
2055         LDKOutPoint a_var = tuple->a;
2056         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2057         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2058         long a_ref = (long)a_var.inner & ~1;
2059         return a_ref;
2060 }
2061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2062         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
2063         LDKCVec_u8Z b_var = tuple->b;
2064         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
2065         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
2066         return b_arr;
2067 }
2068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
2069         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
2070         ret->a = a;
2071         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
2072         FREE((void*)b);
2073         ret->b = b_conv;
2074         return (long)ret;
2075 }
2076 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2077         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
2078         return tuple->a;
2079 }
2080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2081         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
2082         long b_ref = ((long)&tuple->b) | 1;
2083         return (long)b_ref;
2084 }
2085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2086         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
2087         ret->datalen = (*env)->GetArrayLength(env, elems);
2088         if (ret->datalen == 0) {
2089                 ret->data = NULL;
2090         } else {
2091                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
2092                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2093                 for (size_t i = 0; i < ret->datalen; i++) {
2094                         int64_t arr_elem = java_elems[i];
2095                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
2096                         FREE((void*)arr_elem);
2097                         ret->data[i] = arr_elem_conv;
2098                 }
2099                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2100         }
2101         return (long)ret;
2102 }
2103 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
2104         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
2105         for (size_t i = 0; i < ret.datalen; i++) {
2106                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
2107         }
2108         return ret;
2109 }
2110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
2111         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
2112         LDKThirtyTwoBytes a_ref;
2113         CHECK((*env)->GetArrayLength(env, a) == 32);
2114         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2115         ret->a = a_ref;
2116         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
2117         b_constr.datalen = (*env)->GetArrayLength(env, b);
2118         if (b_constr.datalen > 0)
2119                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
2120         else
2121                 b_constr.data = NULL;
2122         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
2123         for (size_t a = 0; a < b_constr.datalen; a++) {
2124                 int64_t b_conv_26 = b_vals[a];
2125                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
2126                 FREE((void*)b_conv_26);
2127                 b_constr.data[a] = b_conv_26_conv;
2128         }
2129         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
2130         ret->b = b_constr;
2131         return (long)ret;
2132 }
2133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2134         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
2135         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2136         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2137         return a_arr;
2138 }
2139 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2140         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
2141         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
2142         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
2143         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
2144         for (size_t a = 0; a < b_var.datalen; a++) {
2145                 long b_conv_26_ref = (long)(&b_var.data[a]) | 1;
2146                 b_arr_ptr[a] = b_conv_26_ref;
2147         }
2148         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
2149         return b_arr;
2150 }
2151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2152         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
2153         ret->datalen = (*env)->GetArrayLength(env, elems);
2154         if (ret->datalen == 0) {
2155                 ret->data = NULL;
2156         } else {
2157                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
2158                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2159                 for (size_t i = 0; i < ret->datalen; i++) {
2160                         int64_t arr_elem = java_elems[i];
2161                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
2162                         FREE((void*)arr_elem);
2163                         ret->data[i] = arr_elem_conv;
2164                 }
2165                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2166         }
2167         return (long)ret;
2168 }
2169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2170         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2171         LDKSignature a_ref;
2172         CHECK((*env)->GetArrayLength(env, a) == 64);
2173         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2174         ret->a = a_ref;
2175         LDKCVec_SignatureZ b_constr;
2176         b_constr.datalen = (*env)->GetArrayLength(env, b);
2177         if (b_constr.datalen > 0)
2178                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2179         else
2180                 b_constr.data = NULL;
2181         for (size_t i = 0; i < b_constr.datalen; i++) {
2182                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2183                 LDKSignature b_conv_8_ref;
2184                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2185                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2186                 b_constr.data[i] = b_conv_8_ref;
2187         }
2188         ret->b = b_constr;
2189         return (long)ret;
2190 }
2191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2192         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2193         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2194         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2195         return a_arr;
2196 }
2197 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2198         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2199         LDKCVec_SignatureZ b_var = tuple->b;
2200         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2201         ;
2202         for (size_t i = 0; i < b_var.datalen; i++) {
2203                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2204                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2205                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2206         }
2207         return b_arr;
2208 }
2209 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2210         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2211 }
2212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2213         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2214         CHECK(val->result_ok);
2215         long res_ref = (long)(&(*val->contents.result)) | 1;
2216         return res_ref;
2217 }
2218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(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         return *val->contents.err;
2222 }
2223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2224         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2225 }
2226 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2227         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2228         CHECK(val->result_ok);
2229         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2230         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2231         return res_arr;
2232 }
2233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2234         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2235         CHECK(!val->result_ok);
2236         return *val->contents.err;
2237 }
2238 typedef struct LDKSign_JCalls {
2239         atomic_size_t refcnt;
2240         JavaVM *vm;
2241         jweak o;
2242         jmethodID get_per_commitment_point_meth;
2243         jmethodID release_commitment_secret_meth;
2244         jmethodID channel_keys_id_meth;
2245         jmethodID sign_counterparty_commitment_meth;
2246         jmethodID sign_holder_commitment_and_htlcs_meth;
2247         jmethodID sign_justice_transaction_meth;
2248         jmethodID sign_counterparty_htlc_transaction_meth;
2249         jmethodID sign_closing_transaction_meth;
2250         jmethodID sign_channel_announcement_meth;
2251         jmethodID ready_channel_meth;
2252         jmethodID write_meth;
2253 } LDKSign_JCalls;
2254 static void LDKSign_JCalls_free(void* this_arg) {
2255         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2256         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2257                 JNIEnv *env;
2258                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2259                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2260                 FREE(j_calls);
2261         }
2262 }
2263 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
2264         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2265         JNIEnv *env;
2266         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2267         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2268         CHECK(obj != NULL);
2269         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2270         LDKPublicKey ret_ref;
2271         CHECK((*env)->GetArrayLength(env, ret) == 33);
2272         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2273         return ret_ref;
2274 }
2275 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
2276         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2277         JNIEnv *env;
2278         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2279         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2280         CHECK(obj != NULL);
2281         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2282         LDKThirtyTwoBytes ret_ref;
2283         CHECK((*env)->GetArrayLength(env, ret) == 32);
2284         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2285         return ret_ref;
2286 }
2287 LDKThirtyTwoBytes channel_keys_id_jcall(const void* this_arg) {
2288         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2289         JNIEnv *env;
2290         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2291         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2292         CHECK(obj != NULL);
2293         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2294         LDKThirtyTwoBytes ret_ref;
2295         CHECK((*env)->GetArrayLength(env, ret) == 32);
2296         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2297         return ret_ref;
2298 }
2299 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2300         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2301         JNIEnv *env;
2302         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2303         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2304         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2305         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2306         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2307         long commitment_tx_ref = (long)commitment_tx_var.inner;
2308         if (commitment_tx_var.is_owned) {
2309                 commitment_tx_ref |= 1;
2310         }
2311         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2312         CHECK(obj != NULL);
2313         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2314         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2315         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
2316         return ret_conv;
2317 }
2318 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2319         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2320         JNIEnv *env;
2321         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2322         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2323         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2324         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2325         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2326         long commitment_tx_ref = (long)commitment_tx_var.inner;
2327         if (commitment_tx_var.is_owned) {
2328                 commitment_tx_ref |= 1;
2329         }
2330         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2331         CHECK(obj != NULL);
2332         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2333         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2334         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
2335         return ret_conv;
2336 }
2337 LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
2338         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2339         JNIEnv *env;
2340         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2341         LDKTransaction justice_tx_var = justice_tx;
2342         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2343         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2344         Transaction_free(justice_tx_var);
2345         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2346         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2347         LDKHTLCOutputInCommitment htlc_var = *htlc;
2348         htlc_var = HTLCOutputInCommitment_clone(htlc);
2349         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2350         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2351         long htlc_ref = (long)htlc_var.inner;
2352         if (htlc_var.is_owned) {
2353                 htlc_ref |= 1;
2354         }
2355         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2356         CHECK(obj != NULL);
2357         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2358         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2359         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2360         return ret_conv;
2361 }
2362 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
2363         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2364         JNIEnv *env;
2365         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2366         LDKTransaction htlc_tx_var = htlc_tx;
2367         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2368         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2369         Transaction_free(htlc_tx_var);
2370         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2371         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2372         LDKHTLCOutputInCommitment htlc_var = *htlc;
2373         htlc_var = HTLCOutputInCommitment_clone(htlc);
2374         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2375         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2376         long htlc_ref = (long)htlc_var.inner;
2377         if (htlc_var.is_owned) {
2378                 htlc_ref |= 1;
2379         }
2380         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2381         CHECK(obj != NULL);
2382         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);
2383         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2384         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2385         return ret_conv;
2386 }
2387 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
2388         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2389         JNIEnv *env;
2390         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2391         LDKTransaction closing_tx_var = closing_tx;
2392         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2393         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2394         Transaction_free(closing_tx_var);
2395         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2396         CHECK(obj != NULL);
2397         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2398         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2399         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2400         return ret_conv;
2401 }
2402 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2403         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2404         JNIEnv *env;
2405         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2406         LDKUnsignedChannelAnnouncement msg_var = *msg;
2407         msg_var = UnsignedChannelAnnouncement_clone(msg);
2408         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2409         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2410         long msg_ref = (long)msg_var.inner;
2411         if (msg_var.is_owned) {
2412                 msg_ref |= 1;
2413         }
2414         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2415         CHECK(obj != NULL);
2416         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2417         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2418         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
2419         return ret_conv;
2420 }
2421 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2422         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2423         JNIEnv *env;
2424         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2425         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2426         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2427         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2428         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2429         long channel_parameters_ref = (long)channel_parameters_var.inner;
2430         if (channel_parameters_var.is_owned) {
2431                 channel_parameters_ref |= 1;
2432         }
2433         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2434         CHECK(obj != NULL);
2435         return (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2436 }
2437 LDKCVec_u8Z write_jcall(const void* this_arg) {
2438         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2439         JNIEnv *env;
2440         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2441         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2442         CHECK(obj != NULL);
2443         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2444         LDKCVec_u8Z ret_ref;
2445         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2446         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2447         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2448         return ret_ref;
2449 }
2450 static void* LDKSign_JCalls_clone(const void* this_arg) {
2451         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2452         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2453         return (void*) this_arg;
2454 }
2455 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2456         jclass c = (*env)->GetObjectClass(env, o);
2457         CHECK(c != NULL);
2458         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2459         atomic_init(&calls->refcnt, 1);
2460         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2461         calls->o = (*env)->NewWeakGlobalRef(env, o);
2462         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2463         CHECK(calls->get_per_commitment_point_meth != NULL);
2464         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2465         CHECK(calls->release_commitment_secret_meth != NULL);
2466         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2467         CHECK(calls->channel_keys_id_meth != NULL);
2468         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2469         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2470         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2471         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2472         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J");
2473         CHECK(calls->sign_justice_transaction_meth != NULL);
2474         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2475         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2476         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2477         CHECK(calls->sign_closing_transaction_meth != NULL);
2478         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2479         CHECK(calls->sign_channel_announcement_meth != NULL);
2480         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2481         CHECK(calls->ready_channel_meth != NULL);
2482         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2483         CHECK(calls->write_meth != NULL);
2484
2485         LDKChannelPublicKeys pubkeys_conv;
2486         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2487         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2488         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2489
2490         LDKSign ret = {
2491                 .this_arg = (void*) calls,
2492                 .get_per_commitment_point = get_per_commitment_point_jcall,
2493                 .release_commitment_secret = release_commitment_secret_jcall,
2494                 .channel_keys_id = channel_keys_id_jcall,
2495                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
2496                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_jcall,
2497                 .sign_justice_transaction = sign_justice_transaction_jcall,
2498                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
2499                 .sign_closing_transaction = sign_closing_transaction_jcall,
2500                 .sign_channel_announcement = sign_channel_announcement_jcall,
2501                 .ready_channel = ready_channel_jcall,
2502                 .clone = LDKSign_JCalls_clone,
2503                 .write = write_jcall,
2504                 .free = LDKSign_JCalls_free,
2505                 .pubkeys = pubkeys_conv,
2506                 .set_pubkeys = NULL,
2507         };
2508         return ret;
2509 }
2510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2511         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2512         *res_ptr = LDKSign_init(env, clz, o, pubkeys);
2513         return (long)res_ptr;
2514 }
2515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2516         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2517         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2519         return ret_arr;
2520 }
2521
2522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2523         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2524         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2525         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2526         return ret_arr;
2527 }
2528
2529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2530         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2531         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2532         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2533         return ret_arr;
2534 }
2535
2536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2537         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2538         LDKCommitmentTransaction commitment_tx_conv;
2539         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2540         commitment_tx_conv.is_owned = false;
2541         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2542         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2543         return (long)ret_conv;
2544 }
2545
2546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2547         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2548         LDKHolderCommitmentTransaction commitment_tx_conv;
2549         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2550         commitment_tx_conv.is_owned = false;
2551         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2552         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2553         return (long)ret_conv;
2554 }
2555
2556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1justice_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
2557         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2558         LDKTransaction justice_tx_ref;
2559         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2560         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2561         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2562         justice_tx_ref.data_is_owned = true;
2563         unsigned char per_commitment_key_arr[32];
2564         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2565         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2566         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2567         LDKHTLCOutputInCommitment htlc_conv;
2568         htlc_conv.inner = (void*)(htlc & (~1));
2569         htlc_conv.is_owned = false;
2570         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2571         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
2572         return (long)ret_conv;
2573 }
2574
2575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_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) {
2576         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2577         LDKTransaction htlc_tx_ref;
2578         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2579         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2580         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2581         htlc_tx_ref.data_is_owned = true;
2582         LDKPublicKey per_commitment_point_ref;
2583         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2584         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2585         LDKHTLCOutputInCommitment htlc_conv;
2586         htlc_conv.inner = (void*)(htlc & (~1));
2587         htlc_conv.is_owned = false;
2588         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2589         *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);
2590         return (long)ret_conv;
2591 }
2592
2593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
2594         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2595         LDKTransaction closing_tx_ref;
2596         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2597         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2598         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2599         closing_tx_ref.data_is_owned = true;
2600         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2601         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2602         return (long)ret_conv;
2603 }
2604
2605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2606         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2607         LDKUnsignedChannelAnnouncement msg_conv;
2608         msg_conv.inner = (void*)(msg & (~1));
2609         msg_conv.is_owned = false;
2610         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2611         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2612         return (long)ret_conv;
2613 }
2614
2615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2616         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2617         LDKChannelTransactionParameters channel_parameters_conv;
2618         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2619         channel_parameters_conv.is_owned = false;
2620         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2621 }
2622
2623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2624         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2625         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2626         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2627         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2628         CVec_u8Z_free(ret_var);
2629         return ret_arr;
2630 }
2631
2632 LDKChannelPublicKeys LDKSign_set_get_pubkeys(LDKSign* this_arg) {
2633         if (this_arg->set_pubkeys != NULL)
2634                 this_arg->set_pubkeys(this_arg);
2635         return this_arg->pubkeys;
2636 }
2637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2638         LDKSign* this_arg_conv = (LDKSign*)this_arg;
2639         LDKChannelPublicKeys ret_var = LDKSign_set_get_pubkeys(this_arg_conv);
2640         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2641         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2642         long ret_ref = (long)ret_var.inner;
2643         if (ret_var.is_owned) {
2644                 ret_ref |= 1;
2645         }
2646         return ret_ref;
2647 }
2648
2649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2650         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2651         LDKThirtyTwoBytes a_ref;
2652         CHECK((*env)->GetArrayLength(env, a) == 32);
2653         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2654         ret->a = a_ref;
2655         LDKChannelMonitor b_conv;
2656         b_conv.inner = (void*)(b & (~1));
2657         b_conv.is_owned = (b & 1) || (b == 0);
2658         b_conv = ChannelMonitor_clone(&b_conv);
2659         ret->b = b_conv;
2660         return (long)ret;
2661 }
2662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2663         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2664         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2665         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2666         return a_arr;
2667 }
2668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2669         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2670         LDKChannelMonitor b_var = tuple->b;
2671         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2672         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2673         long b_ref = (long)b_var.inner & ~1;
2674         return b_ref;
2675 }
2676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2677         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2678 }
2679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2680         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2681         CHECK(val->result_ok);
2682         long res_ref = (long)(&(*val->contents.result)) | 1;
2683         return res_ref;
2684 }
2685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2686         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2687         CHECK(!val->result_ok);
2688         LDKDecodeError err_var = (*val->contents.err);
2689         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2690         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2691         long err_ref = (long)err_var.inner & ~1;
2692         return err_ref;
2693 }
2694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2695         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2696 }
2697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2698         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2699         CHECK(val->result_ok);
2700         long res_ref = ((long)&(*val->contents.result)) | 1;
2701         return (long)res_ref;
2702 }
2703 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2704         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2705         CHECK(!val->result_ok);
2706         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
2707         return err_conv;
2708 }
2709 static jclass LDKAPIError_APIMisuseError_class = NULL;
2710 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2711 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2712 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2713 static jclass LDKAPIError_RouteError_class = NULL;
2714 static jmethodID LDKAPIError_RouteError_meth = NULL;
2715 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
2716 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
2717 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
2718 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
2719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
2720         LDKAPIError_APIMisuseError_class =
2721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
2722         CHECK(LDKAPIError_APIMisuseError_class != NULL);
2723         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
2724         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
2725         LDKAPIError_FeeRateTooHigh_class =
2726                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
2727         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
2728         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
2729         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
2730         LDKAPIError_RouteError_class =
2731                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
2732         CHECK(LDKAPIError_RouteError_class != NULL);
2733         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
2734         CHECK(LDKAPIError_RouteError_meth != NULL);
2735         LDKAPIError_ChannelUnavailable_class =
2736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
2737         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
2738         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
2739         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
2740         LDKAPIError_MonitorUpdateFailed_class =
2741                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
2742         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
2743         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
2744         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
2745 }
2746 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2747         LDKAPIError *obj = (LDKAPIError*)ptr;
2748         switch(obj->tag) {
2749                 case LDKAPIError_APIMisuseError: {
2750                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
2751                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2752                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2753                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
2754                 }
2755                 case LDKAPIError_FeeRateTooHigh: {
2756                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
2757                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2758                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2759                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
2760                 }
2761                 case LDKAPIError_RouteError: {
2762                         LDKStr err_str = obj->route_error.err;
2763                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2764                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
2765                 }
2766                 case LDKAPIError_ChannelUnavailable: {
2767                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
2768                         int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
2769                         (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
2770                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
2771                 }
2772                 case LDKAPIError_MonitorUpdateFailed: {
2773                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
2774                 }
2775                 default: abort();
2776         }
2777 }
2778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2779         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2780 }
2781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2782         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2783         CHECK(val->result_ok);
2784         return *val->contents.result;
2785 }
2786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2787         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2788         CHECK(!val->result_ok);
2789         long err_ref = ((long)&(*val->contents.err)) | 1;
2790         return err_ref;
2791 }
2792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2793         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2794         ret->datalen = (*env)->GetArrayLength(env, elems);
2795         if (ret->datalen == 0) {
2796                 ret->data = NULL;
2797         } else {
2798                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2799                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2800                 for (size_t i = 0; i < ret->datalen; i++) {
2801                         int64_t arr_elem = java_elems[i];
2802                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2803                         FREE((void*)arr_elem);
2804                         ret->data[i] = arr_elem_conv;
2805                 }
2806                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2807         }
2808         return (long)ret;
2809 }
2810 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2811         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2812         for (size_t i = 0; i < ret.datalen; i++) {
2813                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2814         }
2815         return ret;
2816 }
2817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2818         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2819         ret->datalen = (*env)->GetArrayLength(env, elems);
2820         if (ret->datalen == 0) {
2821                 ret->data = NULL;
2822         } else {
2823                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2824                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2825                 for (size_t i = 0; i < ret->datalen; i++) {
2826                         int64_t arr_elem = java_elems[i];
2827                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2828                         FREE((void*)arr_elem);
2829                         ret->data[i] = arr_elem_conv;
2830                 }
2831                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2832         }
2833         return (long)ret;
2834 }
2835 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2836         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2837         for (size_t i = 0; i < ret.datalen; i++) {
2838                 ret.data[i] = APIError_clone(&orig->data[i]);
2839         }
2840         return ret;
2841 }
2842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2843         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2844         ret->datalen = (*env)->GetArrayLength(env, elems);
2845         if (ret->datalen == 0) {
2846                 ret->data = NULL;
2847         } else {
2848                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2849                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2850                 for (size_t i = 0; i < ret->datalen; i++) {
2851                         int64_t arr_elem = java_elems[i];
2852                         LDKChannelDetails arr_elem_conv;
2853                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2854                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2855                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2856                         ret->data[i] = arr_elem_conv;
2857                 }
2858                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2859         }
2860         return (long)ret;
2861 }
2862 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2863         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2864         for (size_t i = 0; i < ret.datalen; i++) {
2865                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2866         }
2867         return ret;
2868 }
2869 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
2870 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
2871 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
2872 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
2873 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
2874 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
2875 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
2876 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
2877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
2878         LDKPaymentSendFailure_ParameterError_class =
2879                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
2880         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
2881         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "()V");
2882         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
2883         LDKPaymentSendFailure_PathParameterError_class =
2884                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
2885         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
2886         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "()V");
2887         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
2888         LDKPaymentSendFailure_AllFailedRetrySafe_class =
2889                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
2890         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
2891         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "()V");
2892         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
2893         LDKPaymentSendFailure_PartialFailure_class =
2894                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
2895         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
2896         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "()V");
2897         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
2898 }
2899 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2900         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)ptr;
2901         switch(obj->tag) {
2902                 case LDKPaymentSendFailure_ParameterError: {
2903                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth);
2904                 }
2905                 case LDKPaymentSendFailure_PathParameterError: {
2906                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth);
2907                 }
2908                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2909                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth);
2910                 }
2911                 case LDKPaymentSendFailure_PartialFailure: {
2912                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth);
2913                 }
2914                 default: abort();
2915         }
2916 }
2917 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2918         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2919 }
2920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2921         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2922         CHECK(val->result_ok);
2923         return *val->contents.result;
2924 }
2925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2926         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2927         CHECK(!val->result_ok);
2928         long err_ref = ((long)&(*val->contents.err)) | 1;
2929         return err_ref;
2930 }
2931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2932         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2933         ret->datalen = (*env)->GetArrayLength(env, elems);
2934         if (ret->datalen == 0) {
2935                 ret->data = NULL;
2936         } else {
2937                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2938                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2939                 for (size_t i = 0; i < ret->datalen; i++) {
2940                         int64_t arr_elem = java_elems[i];
2941                         LDKChannelMonitor arr_elem_conv;
2942                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2943                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2944                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2945                         ret->data[i] = arr_elem_conv;
2946                 }
2947                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2948         }
2949         return (long)ret;
2950 }
2951 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2952         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2953         for (size_t i = 0; i < ret.datalen; i++) {
2954                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2955         }
2956         return ret;
2957 }
2958 typedef struct LDKWatch_JCalls {
2959         atomic_size_t refcnt;
2960         JavaVM *vm;
2961         jweak o;
2962         jmethodID watch_channel_meth;
2963         jmethodID update_channel_meth;
2964         jmethodID release_pending_monitor_events_meth;
2965 } LDKWatch_JCalls;
2966 static void LDKWatch_JCalls_free(void* this_arg) {
2967         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2968         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2969                 JNIEnv *env;
2970                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2971                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2972                 FREE(j_calls);
2973         }
2974 }
2975 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2976         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2977         JNIEnv *env;
2978         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
2979         LDKOutPoint funding_txo_var = funding_txo;
2980         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2981         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2982         long funding_txo_ref = (long)funding_txo_var.inner;
2983         if (funding_txo_var.is_owned) {
2984                 funding_txo_ref |= 1;
2985         }
2986         LDKChannelMonitor monitor_var = monitor;
2987         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2988         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2989         long monitor_ref = (long)monitor_var.inner;
2990         if (monitor_var.is_owned) {
2991                 monitor_ref |= 1;
2992         }
2993         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2994         CHECK(obj != NULL);
2995         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2996         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2997         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
2998         return ret_conv;
2999 }
3000 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3001         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3002         JNIEnv *env;
3003         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3004         LDKOutPoint funding_txo_var = funding_txo;
3005         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3006         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3007         long funding_txo_ref = (long)funding_txo_var.inner;
3008         if (funding_txo_var.is_owned) {
3009                 funding_txo_ref |= 1;
3010         }
3011         LDKChannelMonitorUpdate update_var = update;
3012         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3013         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3014         long update_ref = (long)update_var.inner;
3015         if (update_var.is_owned) {
3016                 update_ref |= 1;
3017         }
3018         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3019         CHECK(obj != NULL);
3020         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3021         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3022         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
3023         return ret_conv;
3024 }
3025 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
3026         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3027         JNIEnv *env;
3028         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3029         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3030         CHECK(obj != NULL);
3031         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3032         LDKCVec_MonitorEventZ ret_constr;
3033         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3034         if (ret_constr.datalen > 0)
3035                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3036         else
3037                 ret_constr.data = NULL;
3038         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3039         for (size_t o = 0; o < ret_constr.datalen; o++) {
3040                 int64_t ret_conv_14 = ret_vals[o];
3041                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3042                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)ret_conv_14);
3043                 ret_constr.data[o] = ret_conv_14_conv;
3044         }
3045         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3046         return ret_constr;
3047 }
3048 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3049         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3050         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3051         return (void*) this_arg;
3052 }
3053 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3054         jclass c = (*env)->GetObjectClass(env, o);
3055         CHECK(c != NULL);
3056         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3057         atomic_init(&calls->refcnt, 1);
3058         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3059         calls->o = (*env)->NewWeakGlobalRef(env, o);
3060         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3061         CHECK(calls->watch_channel_meth != NULL);
3062         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3063         CHECK(calls->update_channel_meth != NULL);
3064         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3065         CHECK(calls->release_pending_monitor_events_meth != NULL);
3066
3067         LDKWatch ret = {
3068                 .this_arg = (void*) calls,
3069                 .watch_channel = watch_channel_jcall,
3070                 .update_channel = update_channel_jcall,
3071                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
3072                 .free = LDKWatch_JCalls_free,
3073         };
3074         return ret;
3075 }
3076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3077         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3078         *res_ptr = LDKWatch_init(env, clz, o);
3079         return (long)res_ptr;
3080 }
3081 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) {
3082         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
3083         LDKOutPoint funding_txo_conv;
3084         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3085         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3086         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3087         LDKChannelMonitor monitor_conv;
3088         monitor_conv.inner = (void*)(monitor & (~1));
3089         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3090         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3091         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3092         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3093         return (long)ret_conv;
3094 }
3095
3096 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) {
3097         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
3098         LDKOutPoint funding_txo_conv;
3099         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3100         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3101         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3102         LDKChannelMonitorUpdate update_conv;
3103         update_conv.inner = (void*)(update & (~1));
3104         update_conv.is_owned = (update & 1) || (update == 0);
3105         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3106         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3107         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3108         return (long)ret_conv;
3109 }
3110
3111 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3112         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
3113         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3114         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3115         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3116         for (size_t o = 0; o < ret_var.datalen; o++) {
3117                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3118                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3119                 long ret_conv_14_ref = (long)ret_conv_14_copy;
3120                 ret_arr_ptr[o] = ret_conv_14_ref;
3121         }
3122         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3123         FREE(ret_var.data);
3124         return ret_arr;
3125 }
3126
3127 typedef struct LDKBroadcasterInterface_JCalls {
3128         atomic_size_t refcnt;
3129         JavaVM *vm;
3130         jweak o;
3131         jmethodID broadcast_transaction_meth;
3132 } LDKBroadcasterInterface_JCalls;
3133 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3134         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3135         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3136                 JNIEnv *env;
3137                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3138                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3139                 FREE(j_calls);
3140         }
3141 }
3142 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
3143         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3144         JNIEnv *env;
3145         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3146         LDKTransaction tx_var = tx;
3147         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3148         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3149         Transaction_free(tx_var);
3150         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3151         CHECK(obj != NULL);
3152         return (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3153 }
3154 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3155         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3156         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3157         return (void*) this_arg;
3158 }
3159 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3160         jclass c = (*env)->GetObjectClass(env, o);
3161         CHECK(c != NULL);
3162         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3163         atomic_init(&calls->refcnt, 1);
3164         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3165         calls->o = (*env)->NewWeakGlobalRef(env, o);
3166         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3167         CHECK(calls->broadcast_transaction_meth != NULL);
3168
3169         LDKBroadcasterInterface ret = {
3170                 .this_arg = (void*) calls,
3171                 .broadcast_transaction = broadcast_transaction_jcall,
3172                 .free = LDKBroadcasterInterface_JCalls_free,
3173         };
3174         return ret;
3175 }
3176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3177         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3178         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3179         return (long)res_ptr;
3180 }
3181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3182         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
3183         LDKTransaction tx_ref;
3184         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3185         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3186         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3187         tx_ref.data_is_owned = true;
3188         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3189 }
3190
3191 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3192         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3193 }
3194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3195         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3196         CHECK(val->result_ok);
3197         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3198         *ret = Sign_clone(&(*val->contents.result));
3199         return (long)ret;
3200 }
3201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3202         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3203         CHECK(!val->result_ok);
3204         LDKDecodeError err_var = (*val->contents.err);
3205         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3206         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3207         long err_ref = (long)err_var.inner & ~1;
3208         return err_ref;
3209 }
3210 typedef struct LDKKeysInterface_JCalls {
3211         atomic_size_t refcnt;
3212         JavaVM *vm;
3213         jweak o;
3214         jmethodID get_node_secret_meth;
3215         jmethodID get_destination_script_meth;
3216         jmethodID get_shutdown_pubkey_meth;
3217         jmethodID get_channel_signer_meth;
3218         jmethodID get_secure_random_bytes_meth;
3219         jmethodID read_chan_signer_meth;
3220 } LDKKeysInterface_JCalls;
3221 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3222         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3223         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3224                 JNIEnv *env;
3225                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3226                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3227                 FREE(j_calls);
3228         }
3229 }
3230 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
3231         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3232         JNIEnv *env;
3233         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3234         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3235         CHECK(obj != NULL);
3236         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3237         LDKSecretKey ret_ref;
3238         CHECK((*env)->GetArrayLength(env, ret) == 32);
3239         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3240         return ret_ref;
3241 }
3242 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
3243         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3244         JNIEnv *env;
3245         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3246         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3247         CHECK(obj != NULL);
3248         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3249         LDKCVec_u8Z ret_ref;
3250         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3251         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3252         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3253         return ret_ref;
3254 }
3255 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
3256         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3257         JNIEnv *env;
3258         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3259         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3260         CHECK(obj != NULL);
3261         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3262         LDKPublicKey ret_ref;
3263         CHECK((*env)->GetArrayLength(env, ret) == 33);
3264         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3265         return ret_ref;
3266 }
3267 LDKSign get_channel_signer_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3268         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3269         JNIEnv *env;
3270         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3271         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3272         CHECK(obj != NULL);
3273         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3274         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3275         ret_conv = Sign_clone(ret);
3276         return ret_conv;
3277 }
3278 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
3279         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3280         JNIEnv *env;
3281         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3283         CHECK(obj != NULL);
3284         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3285         LDKThirtyTwoBytes ret_ref;
3286         CHECK((*env)->GetArrayLength(env, ret) == 32);
3287         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3288         return ret_ref;
3289 }
3290 LDKCResult_SignDecodeErrorZ read_chan_signer_jcall(const void* this_arg, LDKu8slice reader) {
3291         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3292         JNIEnv *env;
3293         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3294         LDKu8slice reader_var = reader;
3295         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3296         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3297         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3298         CHECK(obj != NULL);
3299         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3300         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3301         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)ret);
3302         return ret_conv;
3303 }
3304 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3305         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3306         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3307         return (void*) this_arg;
3308 }
3309 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3310         jclass c = (*env)->GetObjectClass(env, o);
3311         CHECK(c != NULL);
3312         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3313         atomic_init(&calls->refcnt, 1);
3314         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3315         calls->o = (*env)->NewWeakGlobalRef(env, o);
3316         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3317         CHECK(calls->get_node_secret_meth != NULL);
3318         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3319         CHECK(calls->get_destination_script_meth != NULL);
3320         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3321         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3322         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3323         CHECK(calls->get_channel_signer_meth != NULL);
3324         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3325         CHECK(calls->get_secure_random_bytes_meth != NULL);
3326         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3327         CHECK(calls->read_chan_signer_meth != NULL);
3328
3329         LDKKeysInterface ret = {
3330                 .this_arg = (void*) calls,
3331                 .get_node_secret = get_node_secret_jcall,
3332                 .get_destination_script = get_destination_script_jcall,
3333                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
3334                 .get_channel_signer = get_channel_signer_jcall,
3335                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
3336                 .read_chan_signer = read_chan_signer_jcall,
3337                 .free = LDKKeysInterface_JCalls_free,
3338         };
3339         return ret;
3340 }
3341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3342         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3343         *res_ptr = LDKKeysInterface_init(env, clz, o);
3344         return (long)res_ptr;
3345 }
3346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3347         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3348         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3349         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3350         return ret_arr;
3351 }
3352
3353 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3354         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3355         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3356         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3357         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3358         CVec_u8Z_free(ret_var);
3359         return ret_arr;
3360 }
3361
3362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3363         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3364         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3365         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3366         return ret_arr;
3367 }
3368
3369 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) {
3370         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3371         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3372         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3373         return (long)ret;
3374 }
3375
3376 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3377         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3378         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3379         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3380         return ret_arr;
3381 }
3382
3383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3384         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
3385         LDKu8slice reader_ref;
3386         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3387         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3388         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3389         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3390         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3391         return (long)ret_conv;
3392 }
3393
3394 typedef struct LDKFeeEstimator_JCalls {
3395         atomic_size_t refcnt;
3396         JavaVM *vm;
3397         jweak o;
3398         jmethodID get_est_sat_per_1000_weight_meth;
3399 } LDKFeeEstimator_JCalls;
3400 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3401         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3402         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3403                 JNIEnv *env;
3404                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3405                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3406                 FREE(j_calls);
3407         }
3408 }
3409 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3410         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3411         JNIEnv *env;
3412         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3413         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3414         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3415         CHECK(obj != NULL);
3416         return (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3417 }
3418 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
3419         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3420         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3421         return (void*) this_arg;
3422 }
3423 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
3424         jclass c = (*env)->GetObjectClass(env, o);
3425         CHECK(c != NULL);
3426         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3427         atomic_init(&calls->refcnt, 1);
3428         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3429         calls->o = (*env)->NewWeakGlobalRef(env, o);
3430         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
3431         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
3432
3433         LDKFeeEstimator ret = {
3434                 .this_arg = (void*) calls,
3435                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
3436                 .free = LDKFeeEstimator_JCalls_free,
3437         };
3438         return ret;
3439 }
3440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
3441         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3442         *res_ptr = LDKFeeEstimator_init(env, clz, o);
3443         return (long)res_ptr;
3444 }
3445 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) {
3446         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
3447         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
3448         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3449         return ret_val;
3450 }
3451
3452 typedef struct LDKLogger_JCalls {
3453         atomic_size_t refcnt;
3454         JavaVM *vm;
3455         jweak o;
3456         jmethodID log_meth;
3457 } LDKLogger_JCalls;
3458 static void LDKLogger_JCalls_free(void* this_arg) {
3459         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3460         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3461                 JNIEnv *env;
3462                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3463                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3464                 FREE(j_calls);
3465         }
3466 }
3467 void log_jcall(const void* this_arg, const char* record) {
3468         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3469         JNIEnv *env;
3470         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
3471         const char* record_str = record;
3472         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
3473         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3474         CHECK(obj != NULL);
3475         return (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
3476 }
3477 static void* LDKLogger_JCalls_clone(const void* this_arg) {
3478         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3479         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3480         return (void*) this_arg;
3481 }
3482 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3483         jclass c = (*env)->GetObjectClass(env, o);
3484         CHECK(c != NULL);
3485         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3486         atomic_init(&calls->refcnt, 1);
3487         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3488         calls->o = (*env)->NewWeakGlobalRef(env, o);
3489         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
3490         CHECK(calls->log_meth != NULL);
3491
3492         LDKLogger ret = {
3493                 .this_arg = (void*) calls,
3494                 .log = log_jcall,
3495                 .free = LDKLogger_JCalls_free,
3496         };
3497         return ret;
3498 }
3499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3500         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3501         *res_ptr = LDKLogger_init(env, clz, o);
3502         return (long)res_ptr;
3503 }
3504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3505         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3506         LDKThirtyTwoBytes a_ref;
3507         CHECK((*env)->GetArrayLength(env, a) == 32);
3508         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3509         ret->a = a_ref;
3510         LDKChannelManager b_conv;
3511         b_conv.inner = (void*)(b & (~1));
3512         b_conv.is_owned = (b & 1) || (b == 0);
3513         // Warning: we need a move here but no clone is available for LDKChannelManager
3514         ret->b = b_conv;
3515         return (long)ret;
3516 }
3517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3518         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3519         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3520         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3521         return a_arr;
3522 }
3523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3524         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3525         LDKChannelManager b_var = tuple->b;
3526         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3527         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3528         long b_ref = (long)b_var.inner & ~1;
3529         return b_ref;
3530 }
3531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3532         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3533 }
3534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3535         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3536         CHECK(val->result_ok);
3537         long res_ref = (long)(&(*val->contents.result)) | 1;
3538         return res_ref;
3539 }
3540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3541         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3542         CHECK(!val->result_ok);
3543         LDKDecodeError err_var = (*val->contents.err);
3544         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3545         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3546         long err_ref = (long)err_var.inner & ~1;
3547         return err_ref;
3548 }
3549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3550         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
3551 }
3552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3553         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3554         CHECK(val->result_ok);
3555         long res_ref = ((long)&(*val->contents.result)) | 1;
3556         return res_ref;
3557 }
3558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3559         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3560         CHECK(!val->result_ok);
3561         LDKDecodeError err_var = (*val->contents.err);
3562         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3563         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3564         long err_ref = (long)err_var.inner & ~1;
3565         return err_ref;
3566 }
3567 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3568         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3569         for (size_t i = 0; i < ret.datalen; i++) {
3570                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3571         }
3572         return ret;
3573 }
3574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3575         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3576 }
3577 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3578         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3579         CHECK(val->result_ok);
3580         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3581         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3582         ;
3583         for (size_t i = 0; i < res_var.datalen; i++) {
3584                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3585                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3586                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3587                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3588         }
3589         return res_arr;
3590 }
3591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3592         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3593         CHECK(!val->result_ok);
3594         return *val->contents.err;
3595 }
3596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3597         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3598 }
3599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3600         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3601         CHECK(val->result_ok);
3602         LDKInMemorySigner res_var = (*val->contents.result);
3603         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3604         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3605         long res_ref = (long)res_var.inner & ~1;
3606         return res_ref;
3607 }
3608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3609         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3610         CHECK(!val->result_ok);
3611         LDKDecodeError err_var = (*val->contents.err);
3612         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3613         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3614         long err_ref = (long)err_var.inner & ~1;
3615         return err_ref;
3616 }
3617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3618         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
3619         ret->datalen = (*env)->GetArrayLength(env, elems);
3620         if (ret->datalen == 0) {
3621                 ret->data = NULL;
3622         } else {
3623                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
3624                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3625                 for (size_t i = 0; i < ret->datalen; i++) {
3626                         int64_t arr_elem = java_elems[i];
3627                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
3628                         FREE((void*)arr_elem);
3629                         ret->data[i] = arr_elem_conv;
3630                 }
3631                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3632         }
3633         return (long)ret;
3634 }
3635 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3636         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3637         for (size_t i = 0; i < ret.datalen; i++) {
3638                 ret.data[i] = TxOut_clone(&orig->data[i]);
3639         }
3640         return ret;
3641 }
3642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3643         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3644 }
3645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3646         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3647         CHECK(val->result_ok);
3648         LDKTransaction res_var = (*val->contents.result);
3649         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3650         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3651         return res_arr;
3652 }
3653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3654         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3655         CHECK(!val->result_ok);
3656         return *val->contents.err;
3657 }
3658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3659         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
3660         ret->datalen = (*env)->GetArrayLength(env, elems);
3661         if (ret->datalen == 0) {
3662                 ret->data = NULL;
3663         } else {
3664                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
3665                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3666                 for (size_t i = 0; i < ret->datalen; i++) {
3667                         int64_t arr_elem = java_elems[i];
3668                         LDKRouteHop arr_elem_conv;
3669                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3670                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3671                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
3672                         ret->data[i] = arr_elem_conv;
3673                 }
3674                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3675         }
3676         return (long)ret;
3677 }
3678 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
3679         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
3680         for (size_t i = 0; i < ret.datalen; i++) {
3681                 ret.data[i] = RouteHop_clone(&orig->data[i]);
3682         }
3683         return ret;
3684 }
3685 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
3686         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
3687         for (size_t i = 0; i < ret.datalen; i++) {
3688                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
3689         }
3690         return ret;
3691 }
3692 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3693         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
3694 }
3695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3696         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3697         CHECK(val->result_ok);
3698         LDKRoute res_var = (*val->contents.result);
3699         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3700         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3701         long res_ref = (long)res_var.inner & ~1;
3702         return res_ref;
3703 }
3704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3705         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3706         CHECK(!val->result_ok);
3707         LDKDecodeError err_var = (*val->contents.err);
3708         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3709         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3710         long err_ref = (long)err_var.inner & ~1;
3711         return err_ref;
3712 }
3713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3714         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
3715         ret->datalen = (*env)->GetArrayLength(env, elems);
3716         if (ret->datalen == 0) {
3717                 ret->data = NULL;
3718         } else {
3719                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
3720                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3721                 for (size_t i = 0; i < ret->datalen; i++) {
3722                         int64_t arr_elem = java_elems[i];
3723                         LDKRouteHint arr_elem_conv;
3724                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3725                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3726                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
3727                         ret->data[i] = arr_elem_conv;
3728                 }
3729                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3730         }
3731         return (long)ret;
3732 }
3733 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
3734         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
3735         for (size_t i = 0; i < ret.datalen; i++) {
3736                 ret.data[i] = RouteHint_clone(&orig->data[i]);
3737         }
3738         return ret;
3739 }
3740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3741         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3742 }
3743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3744         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3745         CHECK(val->result_ok);
3746         LDKRoute res_var = (*val->contents.result);
3747         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3748         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3749         long res_ref = (long)res_var.inner & ~1;
3750         return res_ref;
3751 }
3752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3753         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3754         CHECK(!val->result_ok);
3755         LDKLightningError err_var = (*val->contents.err);
3756         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3757         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3758         long err_ref = (long)err_var.inner & ~1;
3759         return err_ref;
3760 }
3761 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3762         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3763 }
3764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3765         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3766         CHECK(val->result_ok);
3767         long res_ref = ((long)&(*val->contents.result)) | 1;
3768         return res_ref;
3769 }
3770 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3771         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3772         CHECK(!val->result_ok);
3773         return *val->contents.err;
3774 }
3775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3776         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3777 }
3778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3779         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3780         CHECK(val->result_ok);
3781         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3782         *res_conv = (*val->contents.result);
3783         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3784         return (long)res_conv;
3785 }
3786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3787         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3788         CHECK(!val->result_ok);
3789         LDKDecodeError err_var = (*val->contents.err);
3790         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3791         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3792         long err_ref = (long)err_var.inner & ~1;
3793         return err_ref;
3794 }
3795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3796         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3797         ret->datalen = (*env)->GetArrayLength(env, elems);
3798         if (ret->datalen == 0) {
3799                 ret->data = NULL;
3800         } else {
3801                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3802                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3803                 for (size_t i = 0; i < ret->datalen; i++) {
3804                         int64_t arr_elem = java_elems[i];
3805                         LDKUpdateAddHTLC arr_elem_conv;
3806                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3807                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3808                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3809                         ret->data[i] = arr_elem_conv;
3810                 }
3811                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3812         }
3813         return (long)ret;
3814 }
3815 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3816         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3817         for (size_t i = 0; i < ret.datalen; i++) {
3818                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3819         }
3820         return ret;
3821 }
3822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3823         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3824         ret->datalen = (*env)->GetArrayLength(env, elems);
3825         if (ret->datalen == 0) {
3826                 ret->data = NULL;
3827         } else {
3828                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3829                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3830                 for (size_t i = 0; i < ret->datalen; i++) {
3831                         int64_t arr_elem = java_elems[i];
3832                         LDKUpdateFulfillHTLC arr_elem_conv;
3833                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3834                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3835                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3836                         ret->data[i] = arr_elem_conv;
3837                 }
3838                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3839         }
3840         return (long)ret;
3841 }
3842 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3843         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3844         for (size_t i = 0; i < ret.datalen; i++) {
3845                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3846         }
3847         return ret;
3848 }
3849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3850         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3851         ret->datalen = (*env)->GetArrayLength(env, elems);
3852         if (ret->datalen == 0) {
3853                 ret->data = NULL;
3854         } else {
3855                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3856                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3857                 for (size_t i = 0; i < ret->datalen; i++) {
3858                         int64_t arr_elem = java_elems[i];
3859                         LDKUpdateFailHTLC arr_elem_conv;
3860                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3861                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3862                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3863                         ret->data[i] = arr_elem_conv;
3864                 }
3865                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3866         }
3867         return (long)ret;
3868 }
3869 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3870         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3871         for (size_t i = 0; i < ret.datalen; i++) {
3872                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3873         }
3874         return ret;
3875 }
3876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3877         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3878         ret->datalen = (*env)->GetArrayLength(env, elems);
3879         if (ret->datalen == 0) {
3880                 ret->data = NULL;
3881         } else {
3882                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3883                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3884                 for (size_t i = 0; i < ret->datalen; i++) {
3885                         int64_t arr_elem = java_elems[i];
3886                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3887                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3888                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3889                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3890                         ret->data[i] = arr_elem_conv;
3891                 }
3892                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3893         }
3894         return (long)ret;
3895 }
3896 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3897         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3898         for (size_t i = 0; i < ret.datalen; i++) {
3899                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3900         }
3901         return ret;
3902 }
3903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3904         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3905 }
3906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3907         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3908         CHECK(val->result_ok);
3909         LDKAcceptChannel res_var = (*val->contents.result);
3910         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3911         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3912         long res_ref = (long)res_var.inner & ~1;
3913         return res_ref;
3914 }
3915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3916         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3917         CHECK(!val->result_ok);
3918         LDKDecodeError err_var = (*val->contents.err);
3919         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3920         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3921         long err_ref = (long)err_var.inner & ~1;
3922         return err_ref;
3923 }
3924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3925         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3926 }
3927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3928         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3929         CHECK(val->result_ok);
3930         LDKAnnouncementSignatures res_var = (*val->contents.result);
3931         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3932         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3933         long res_ref = (long)res_var.inner & ~1;
3934         return res_ref;
3935 }
3936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3937         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3938         CHECK(!val->result_ok);
3939         LDKDecodeError err_var = (*val->contents.err);
3940         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3941         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3942         long err_ref = (long)err_var.inner & ~1;
3943         return err_ref;
3944 }
3945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3946         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3947 }
3948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3949         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3950         CHECK(val->result_ok);
3951         LDKChannelReestablish res_var = (*val->contents.result);
3952         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3953         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3954         long res_ref = (long)res_var.inner & ~1;
3955         return res_ref;
3956 }
3957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3958         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3959         CHECK(!val->result_ok);
3960         LDKDecodeError err_var = (*val->contents.err);
3961         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3962         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3963         long err_ref = (long)err_var.inner & ~1;
3964         return err_ref;
3965 }
3966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3967         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
3968 }
3969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3970         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3971         CHECK(val->result_ok);
3972         LDKClosingSigned res_var = (*val->contents.result);
3973         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3974         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3975         long res_ref = (long)res_var.inner & ~1;
3976         return res_ref;
3977 }
3978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3979         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3980         CHECK(!val->result_ok);
3981         LDKDecodeError err_var = (*val->contents.err);
3982         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3983         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3984         long err_ref = (long)err_var.inner & ~1;
3985         return err_ref;
3986 }
3987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3988         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
3989 }
3990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3991         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3992         CHECK(val->result_ok);
3993         LDKCommitmentSigned res_var = (*val->contents.result);
3994         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3995         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3996         long res_ref = (long)res_var.inner & ~1;
3997         return res_ref;
3998 }
3999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4000         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4001         CHECK(!val->result_ok);
4002         LDKDecodeError err_var = (*val->contents.err);
4003         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4004         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4005         long err_ref = (long)err_var.inner & ~1;
4006         return err_ref;
4007 }
4008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4009         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4010 }
4011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4012         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4013         CHECK(val->result_ok);
4014         LDKFundingCreated res_var = (*val->contents.result);
4015         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4016         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4017         long res_ref = (long)res_var.inner & ~1;
4018         return res_ref;
4019 }
4020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4021         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4022         CHECK(!val->result_ok);
4023         LDKDecodeError err_var = (*val->contents.err);
4024         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4025         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4026         long err_ref = (long)err_var.inner & ~1;
4027         return err_ref;
4028 }
4029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4030         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4031 }
4032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4033         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4034         CHECK(val->result_ok);
4035         LDKFundingSigned res_var = (*val->contents.result);
4036         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4037         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4038         long res_ref = (long)res_var.inner & ~1;
4039         return res_ref;
4040 }
4041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4042         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4043         CHECK(!val->result_ok);
4044         LDKDecodeError err_var = (*val->contents.err);
4045         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4046         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4047         long err_ref = (long)err_var.inner & ~1;
4048         return err_ref;
4049 }
4050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4051         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4052 }
4053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4054         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4055         CHECK(val->result_ok);
4056         LDKFundingLocked res_var = (*val->contents.result);
4057         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4058         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4059         long res_ref = (long)res_var.inner & ~1;
4060         return res_ref;
4061 }
4062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4063         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4064         CHECK(!val->result_ok);
4065         LDKDecodeError err_var = (*val->contents.err);
4066         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4067         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4068         long err_ref = (long)err_var.inner & ~1;
4069         return err_ref;
4070 }
4071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4072         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4073 }
4074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4075         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4076         CHECK(val->result_ok);
4077         LDKInit res_var = (*val->contents.result);
4078         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4079         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4080         long res_ref = (long)res_var.inner & ~1;
4081         return res_ref;
4082 }
4083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4084         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4085         CHECK(!val->result_ok);
4086         LDKDecodeError err_var = (*val->contents.err);
4087         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4088         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4089         long err_ref = (long)err_var.inner & ~1;
4090         return err_ref;
4091 }
4092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4093         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4094 }
4095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4096         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4097         CHECK(val->result_ok);
4098         LDKOpenChannel res_var = (*val->contents.result);
4099         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4100         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4101         long res_ref = (long)res_var.inner & ~1;
4102         return res_ref;
4103 }
4104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4105         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4106         CHECK(!val->result_ok);
4107         LDKDecodeError err_var = (*val->contents.err);
4108         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4109         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4110         long err_ref = (long)err_var.inner & ~1;
4111         return err_ref;
4112 }
4113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4114         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4115 }
4116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4117         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4118         CHECK(val->result_ok);
4119         LDKRevokeAndACK res_var = (*val->contents.result);
4120         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4121         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4122         long res_ref = (long)res_var.inner & ~1;
4123         return res_ref;
4124 }
4125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4126         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4127         CHECK(!val->result_ok);
4128         LDKDecodeError err_var = (*val->contents.err);
4129         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4130         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4131         long err_ref = (long)err_var.inner & ~1;
4132         return err_ref;
4133 }
4134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4135         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4136 }
4137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4138         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4139         CHECK(val->result_ok);
4140         LDKShutdown res_var = (*val->contents.result);
4141         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4142         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4143         long res_ref = (long)res_var.inner & ~1;
4144         return res_ref;
4145 }
4146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4147         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4148         CHECK(!val->result_ok);
4149         LDKDecodeError err_var = (*val->contents.err);
4150         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4151         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4152         long err_ref = (long)err_var.inner & ~1;
4153         return err_ref;
4154 }
4155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4156         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4157 }
4158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4159         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4160         CHECK(val->result_ok);
4161         LDKUpdateFailHTLC res_var = (*val->contents.result);
4162         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4163         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4164         long res_ref = (long)res_var.inner & ~1;
4165         return res_ref;
4166 }
4167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4168         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4169         CHECK(!val->result_ok);
4170         LDKDecodeError err_var = (*val->contents.err);
4171         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4172         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4173         long err_ref = (long)err_var.inner & ~1;
4174         return err_ref;
4175 }
4176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4177         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4178 }
4179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4180         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4181         CHECK(val->result_ok);
4182         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4183         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4184         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4185         long res_ref = (long)res_var.inner & ~1;
4186         return res_ref;
4187 }
4188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4189         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4190         CHECK(!val->result_ok);
4191         LDKDecodeError err_var = (*val->contents.err);
4192         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4193         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4194         long err_ref = (long)err_var.inner & ~1;
4195         return err_ref;
4196 }
4197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4198         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4199 }
4200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4201         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4202         CHECK(val->result_ok);
4203         LDKUpdateFee res_var = (*val->contents.result);
4204         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4205         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4206         long res_ref = (long)res_var.inner & ~1;
4207         return res_ref;
4208 }
4209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4210         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4211         CHECK(!val->result_ok);
4212         LDKDecodeError err_var = (*val->contents.err);
4213         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4214         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4215         long err_ref = (long)err_var.inner & ~1;
4216         return err_ref;
4217 }
4218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4219         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4220 }
4221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4222         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4223         CHECK(val->result_ok);
4224         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4225         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4226         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4227         long res_ref = (long)res_var.inner & ~1;
4228         return res_ref;
4229 }
4230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4231         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4232         CHECK(!val->result_ok);
4233         LDKDecodeError err_var = (*val->contents.err);
4234         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4235         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4236         long err_ref = (long)err_var.inner & ~1;
4237         return err_ref;
4238 }
4239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4240         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4241 }
4242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4243         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4244         CHECK(val->result_ok);
4245         LDKUpdateAddHTLC res_var = (*val->contents.result);
4246         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4247         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4248         long res_ref = (long)res_var.inner & ~1;
4249         return res_ref;
4250 }
4251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4252         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4253         CHECK(!val->result_ok);
4254         LDKDecodeError err_var = (*val->contents.err);
4255         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4256         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4257         long err_ref = (long)err_var.inner & ~1;
4258         return err_ref;
4259 }
4260 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4261         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4262 }
4263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4264         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4265         CHECK(val->result_ok);
4266         LDKPing res_var = (*val->contents.result);
4267         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4268         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4269         long res_ref = (long)res_var.inner & ~1;
4270         return res_ref;
4271 }
4272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4273         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4274         CHECK(!val->result_ok);
4275         LDKDecodeError err_var = (*val->contents.err);
4276         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4277         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4278         long err_ref = (long)err_var.inner & ~1;
4279         return err_ref;
4280 }
4281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4282         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4283 }
4284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4285         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4286         CHECK(val->result_ok);
4287         LDKPong res_var = (*val->contents.result);
4288         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4289         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4290         long res_ref = (long)res_var.inner & ~1;
4291         return res_ref;
4292 }
4293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4294         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4295         CHECK(!val->result_ok);
4296         LDKDecodeError err_var = (*val->contents.err);
4297         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4298         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4299         long err_ref = (long)err_var.inner & ~1;
4300         return err_ref;
4301 }
4302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4303         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4304 }
4305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4306         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4307         CHECK(val->result_ok);
4308         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4309         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4310         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4311         long res_ref = (long)res_var.inner & ~1;
4312         return res_ref;
4313 }
4314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4315         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4316         CHECK(!val->result_ok);
4317         LDKDecodeError err_var = (*val->contents.err);
4318         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4319         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4320         long err_ref = (long)err_var.inner & ~1;
4321         return err_ref;
4322 }
4323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4324         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4325 }
4326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4327         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4328         CHECK(val->result_ok);
4329         LDKChannelAnnouncement res_var = (*val->contents.result);
4330         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4331         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4332         long res_ref = (long)res_var.inner & ~1;
4333         return res_ref;
4334 }
4335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4336         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4337         CHECK(!val->result_ok);
4338         LDKDecodeError err_var = (*val->contents.err);
4339         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4340         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4341         long err_ref = (long)err_var.inner & ~1;
4342         return err_ref;
4343 }
4344 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4345         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4346 }
4347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4348         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4349         CHECK(val->result_ok);
4350         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4351         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4352         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4353         long res_ref = (long)res_var.inner & ~1;
4354         return res_ref;
4355 }
4356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4357         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4358         CHECK(!val->result_ok);
4359         LDKDecodeError err_var = (*val->contents.err);
4360         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4361         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4362         long err_ref = (long)err_var.inner & ~1;
4363         return err_ref;
4364 }
4365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4366         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4367 }
4368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4369         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4370         CHECK(val->result_ok);
4371         LDKChannelUpdate res_var = (*val->contents.result);
4372         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4373         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4374         long res_ref = (long)res_var.inner & ~1;
4375         return res_ref;
4376 }
4377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4378         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4379         CHECK(!val->result_ok);
4380         LDKDecodeError err_var = (*val->contents.err);
4381         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4382         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4383         long err_ref = (long)err_var.inner & ~1;
4384         return err_ref;
4385 }
4386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4387         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4388 }
4389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4390         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4391         CHECK(val->result_ok);
4392         LDKErrorMessage res_var = (*val->contents.result);
4393         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4394         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4395         long res_ref = (long)res_var.inner & ~1;
4396         return res_ref;
4397 }
4398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4399         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4400         CHECK(!val->result_ok);
4401         LDKDecodeError err_var = (*val->contents.err);
4402         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4403         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4404         long err_ref = (long)err_var.inner & ~1;
4405         return err_ref;
4406 }
4407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4408         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4409 }
4410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4411         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4412         CHECK(val->result_ok);
4413         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4414         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4415         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4416         long res_ref = (long)res_var.inner & ~1;
4417         return res_ref;
4418 }
4419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4420         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4421         CHECK(!val->result_ok);
4422         LDKDecodeError err_var = (*val->contents.err);
4423         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4424         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4425         long err_ref = (long)err_var.inner & ~1;
4426         return err_ref;
4427 }
4428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4429         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4430 }
4431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4432         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4433         CHECK(val->result_ok);
4434         LDKNodeAnnouncement res_var = (*val->contents.result);
4435         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4436         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4437         long res_ref = (long)res_var.inner & ~1;
4438         return res_ref;
4439 }
4440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4441         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4442         CHECK(!val->result_ok);
4443         LDKDecodeError err_var = (*val->contents.err);
4444         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4445         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4446         long err_ref = (long)err_var.inner & ~1;
4447         return err_ref;
4448 }
4449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4450         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4451 }
4452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4453         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4454         CHECK(val->result_ok);
4455         LDKQueryShortChannelIds res_var = (*val->contents.result);
4456         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4457         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4458         long res_ref = (long)res_var.inner & ~1;
4459         return res_ref;
4460 }
4461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4462         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4463         CHECK(!val->result_ok);
4464         LDKDecodeError err_var = (*val->contents.err);
4465         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4466         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4467         long err_ref = (long)err_var.inner & ~1;
4468         return err_ref;
4469 }
4470 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4471         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4472 }
4473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4474         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4475         CHECK(val->result_ok);
4476         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4477         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4478         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4479         long res_ref = (long)res_var.inner & ~1;
4480         return res_ref;
4481 }
4482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4483         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4484         CHECK(!val->result_ok);
4485         LDKDecodeError err_var = (*val->contents.err);
4486         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4487         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4488         long err_ref = (long)err_var.inner & ~1;
4489         return err_ref;
4490 }
4491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4492         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4493 }
4494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4495         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4496         CHECK(val->result_ok);
4497         LDKQueryChannelRange res_var = (*val->contents.result);
4498         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4499         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4500         long res_ref = (long)res_var.inner & ~1;
4501         return res_ref;
4502 }
4503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4504         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4505         CHECK(!val->result_ok);
4506         LDKDecodeError err_var = (*val->contents.err);
4507         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4508         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4509         long err_ref = (long)err_var.inner & ~1;
4510         return err_ref;
4511 }
4512 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4513         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4514 }
4515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4516         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4517         CHECK(val->result_ok);
4518         LDKReplyChannelRange res_var = (*val->contents.result);
4519         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4520         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4521         long res_ref = (long)res_var.inner & ~1;
4522         return res_ref;
4523 }
4524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4525         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4526         CHECK(!val->result_ok);
4527         LDKDecodeError err_var = (*val->contents.err);
4528         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4529         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4530         long err_ref = (long)err_var.inner & ~1;
4531         return err_ref;
4532 }
4533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4534         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4535 }
4536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4537         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4538         CHECK(val->result_ok);
4539         LDKGossipTimestampFilter res_var = (*val->contents.result);
4540         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4541         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4542         long res_ref = (long)res_var.inner & ~1;
4543         return res_ref;
4544 }
4545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4546         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4547         CHECK(!val->result_ok);
4548         LDKDecodeError err_var = (*val->contents.err);
4549         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4550         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4551         long err_ref = (long)err_var.inner & ~1;
4552         return err_ref;
4553 }
4554 typedef struct LDKMessageSendEventsProvider_JCalls {
4555         atomic_size_t refcnt;
4556         JavaVM *vm;
4557         jweak o;
4558         jmethodID get_and_clear_pending_msg_events_meth;
4559 } LDKMessageSendEventsProvider_JCalls;
4560 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4561         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4562         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4563                 JNIEnv *env;
4564                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4565                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4566                 FREE(j_calls);
4567         }
4568 }
4569 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
4570         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4571         JNIEnv *env;
4572         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4573         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4574         CHECK(obj != NULL);
4575         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
4576         LDKCVec_MessageSendEventZ ret_constr;
4577         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4578         if (ret_constr.datalen > 0)
4579                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4580         else
4581                 ret_constr.data = NULL;
4582         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4583         for (size_t s = 0; s < ret_constr.datalen; s++) {
4584                 int64_t ret_conv_18 = ret_vals[s];
4585                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4586                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)ret_conv_18);
4587                 ret_constr.data[s] = ret_conv_18_conv;
4588         }
4589         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4590         return ret_constr;
4591 }
4592 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4593         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4594         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4595         return (void*) this_arg;
4596 }
4597 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4598         jclass c = (*env)->GetObjectClass(env, o);
4599         CHECK(c != NULL);
4600         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4601         atomic_init(&calls->refcnt, 1);
4602         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4603         calls->o = (*env)->NewWeakGlobalRef(env, o);
4604         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
4605         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
4606
4607         LDKMessageSendEventsProvider ret = {
4608                 .this_arg = (void*) calls,
4609                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
4610                 .free = LDKMessageSendEventsProvider_JCalls_free,
4611         };
4612         return ret;
4613 }
4614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4615         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4616         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
4617         return (long)res_ptr;
4618 }
4619 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4620         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
4621         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4622         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4623         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4624         for (size_t s = 0; s < ret_var.datalen; s++) {
4625                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4626                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4627                 long ret_conv_18_ref = (long)ret_conv_18_copy;
4628                 ret_arr_ptr[s] = ret_conv_18_ref;
4629         }
4630         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4631         FREE(ret_var.data);
4632         return ret_arr;
4633 }
4634
4635 typedef struct LDKEventsProvider_JCalls {
4636         atomic_size_t refcnt;
4637         JavaVM *vm;
4638         jweak o;
4639         jmethodID get_and_clear_pending_events_meth;
4640 } LDKEventsProvider_JCalls;
4641 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4642         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4643         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4644                 JNIEnv *env;
4645                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4646                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4647                 FREE(j_calls);
4648         }
4649 }
4650 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
4651         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4652         JNIEnv *env;
4653         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4654         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4655         CHECK(obj != NULL);
4656         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
4657         LDKCVec_EventZ ret_constr;
4658         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4659         if (ret_constr.datalen > 0)
4660                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4661         else
4662                 ret_constr.data = NULL;
4663         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4664         for (size_t h = 0; h < ret_constr.datalen; h++) {
4665                 int64_t ret_conv_7 = ret_vals[h];
4666                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
4667                 ret_conv_7_conv = Event_clone((LDKEvent*)ret_conv_7);
4668                 ret_constr.data[h] = ret_conv_7_conv;
4669         }
4670         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4671         return ret_constr;
4672 }
4673 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4674         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4675         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4676         return (void*) this_arg;
4677 }
4678 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
4679         jclass c = (*env)->GetObjectClass(env, o);
4680         CHECK(c != NULL);
4681         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4682         atomic_init(&calls->refcnt, 1);
4683         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4684         calls->o = (*env)->NewWeakGlobalRef(env, o);
4685         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
4686         CHECK(calls->get_and_clear_pending_events_meth != NULL);
4687
4688         LDKEventsProvider ret = {
4689                 .this_arg = (void*) calls,
4690                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
4691                 .free = LDKEventsProvider_JCalls_free,
4692         };
4693         return ret;
4694 }
4695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
4696         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4697         *res_ptr = LDKEventsProvider_init(env, clz, o);
4698         return (long)res_ptr;
4699 }
4700 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4701         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
4702         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
4703         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4704         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4705         for (size_t h = 0; h < ret_var.datalen; h++) {
4706                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4707                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
4708                 long ret_conv_7_ref = (long)ret_conv_7_copy;
4709                 ret_arr_ptr[h] = ret_conv_7_ref;
4710         }
4711         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4712         FREE(ret_var.data);
4713         return ret_arr;
4714 }
4715
4716 typedef struct LDKAccess_JCalls {
4717         atomic_size_t refcnt;
4718         JavaVM *vm;
4719         jweak o;
4720         jmethodID get_utxo_meth;
4721 } LDKAccess_JCalls;
4722 static void LDKAccess_JCalls_free(void* this_arg) {
4723         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4724         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4725                 JNIEnv *env;
4726                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4727                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4728                 FREE(j_calls);
4729         }
4730 }
4731 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4732         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4733         JNIEnv *env;
4734         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4735         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4736         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4737         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4738         CHECK(obj != NULL);
4739         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4740         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4741         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
4742         return ret_conv;
4743 }
4744 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4745         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4746         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4747         return (void*) this_arg;
4748 }
4749 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4750         jclass c = (*env)->GetObjectClass(env, o);
4751         CHECK(c != NULL);
4752         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4753         atomic_init(&calls->refcnt, 1);
4754         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4755         calls->o = (*env)->NewWeakGlobalRef(env, o);
4756         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4757         CHECK(calls->get_utxo_meth != NULL);
4758
4759         LDKAccess ret = {
4760                 .this_arg = (void*) calls,
4761                 .get_utxo = get_utxo_jcall,
4762                 .free = LDKAccess_JCalls_free,
4763         };
4764         return ret;
4765 }
4766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4767         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4768         *res_ptr = LDKAccess_init(env, clz, o);
4769         return (long)res_ptr;
4770 }
4771 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) {
4772         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
4773         unsigned char genesis_hash_arr[32];
4774         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4775         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4776         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4777         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4778         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4779         return (long)ret_conv;
4780 }
4781
4782 typedef struct LDKListen_JCalls {
4783         atomic_size_t refcnt;
4784         JavaVM *vm;
4785         jweak o;
4786         jmethodID block_connected_meth;
4787         jmethodID block_disconnected_meth;
4788 } LDKListen_JCalls;
4789 static void LDKListen_JCalls_free(void* this_arg) {
4790         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4791         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4792                 JNIEnv *env;
4793                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4794                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4795                 FREE(j_calls);
4796         }
4797 }
4798 void block_connected_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4799         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4800         JNIEnv *env;
4801         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4802         LDKu8slice block_var = block;
4803         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
4804         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
4805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4806         CHECK(obj != NULL);
4807         return (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
4808 }
4809 void block_disconnected_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4810         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4811         JNIEnv *env;
4812         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4813         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
4814         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
4815         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4816         CHECK(obj != NULL);
4817         return (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
4818 }
4819 static void* LDKListen_JCalls_clone(const void* this_arg) {
4820         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4821         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4822         return (void*) this_arg;
4823 }
4824 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
4825         jclass c = (*env)->GetObjectClass(env, o);
4826         CHECK(c != NULL);
4827         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4828         atomic_init(&calls->refcnt, 1);
4829         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4830         calls->o = (*env)->NewWeakGlobalRef(env, o);
4831         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
4832         CHECK(calls->block_connected_meth != NULL);
4833         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
4834         CHECK(calls->block_disconnected_meth != NULL);
4835
4836         LDKListen ret = {
4837                 .this_arg = (void*) calls,
4838                 .block_connected = block_connected_jcall,
4839                 .block_disconnected = block_disconnected_jcall,
4840                 .free = LDKListen_JCalls_free,
4841         };
4842         return ret;
4843 }
4844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
4845         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4846         *res_ptr = LDKListen_init(env, clz, o);
4847         return (long)res_ptr;
4848 }
4849 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) {
4850         LDKListen* this_arg_conv = (LDKListen*)this_arg;
4851         LDKu8slice block_ref;
4852         block_ref.datalen = (*env)->GetArrayLength(env, block);
4853         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
4854         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4855         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
4856 }
4857
4858 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) {
4859         LDKListen* this_arg_conv = (LDKListen*)this_arg;
4860         unsigned char header_arr[80];
4861         CHECK((*env)->GetArrayLength(env, header) == 80);
4862         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
4863         unsigned char (*header_ref)[80] = &header_arr;
4864         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4865 }
4866
4867 typedef struct LDKFilter_JCalls {
4868         atomic_size_t refcnt;
4869         JavaVM *vm;
4870         jweak o;
4871         jmethodID register_tx_meth;
4872         jmethodID register_output_meth;
4873 } LDKFilter_JCalls;
4874 static void LDKFilter_JCalls_free(void* this_arg) {
4875         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4876         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4877                 JNIEnv *env;
4878                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4879                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4880                 FREE(j_calls);
4881         }
4882 }
4883 void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
4884         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4885         JNIEnv *env;
4886         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4887         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
4888         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
4889         LDKu8slice script_pubkey_var = script_pubkey;
4890         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
4891         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
4892         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4893         CHECK(obj != NULL);
4894         return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
4895 }
4896 void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
4897         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4898         JNIEnv *env;
4899         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4900         LDKOutPoint outpoint_var = *outpoint;
4901         outpoint_var = OutPoint_clone(outpoint);
4902         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4903         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4904         long outpoint_ref = (long)outpoint_var.inner;
4905         if (outpoint_var.is_owned) {
4906                 outpoint_ref |= 1;
4907         }
4908         LDKu8slice script_pubkey_var = script_pubkey;
4909         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
4910         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
4911         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4912         CHECK(obj != NULL);
4913         return (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
4914 }
4915 static void* LDKFilter_JCalls_clone(const void* this_arg) {
4916         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4917         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4918         return (void*) this_arg;
4919 }
4920 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
4921         jclass c = (*env)->GetObjectClass(env, o);
4922         CHECK(c != NULL);
4923         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
4924         atomic_init(&calls->refcnt, 1);
4925         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4926         calls->o = (*env)->NewWeakGlobalRef(env, o);
4927         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
4928         CHECK(calls->register_tx_meth != NULL);
4929         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V");
4930         CHECK(calls->register_output_meth != NULL);
4931
4932         LDKFilter ret = {
4933                 .this_arg = (void*) calls,
4934                 .register_tx = register_tx_jcall,
4935                 .register_output = register_output_jcall,
4936                 .free = LDKFilter_JCalls_free,
4937         };
4938         return ret;
4939 }
4940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
4941         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
4942         *res_ptr = LDKFilter_init(env, clz, o);
4943         return (long)res_ptr;
4944 }
4945 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) {
4946         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
4947         unsigned char txid_arr[32];
4948         CHECK((*env)->GetArrayLength(env, txid) == 32);
4949         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
4950         unsigned char (*txid_ref)[32] = &txid_arr;
4951         LDKu8slice script_pubkey_ref;
4952         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
4953         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
4954         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
4955         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
4956 }
4957
4958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t outpoint, int8_tArray script_pubkey) {
4959         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
4960         LDKOutPoint outpoint_conv;
4961         outpoint_conv.inner = (void*)(outpoint & (~1));
4962         outpoint_conv.is_owned = false;
4963         LDKu8slice script_pubkey_ref;
4964         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
4965         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
4966         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
4967         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
4968 }
4969
4970 typedef struct LDKPersist_JCalls {
4971         atomic_size_t refcnt;
4972         JavaVM *vm;
4973         jweak o;
4974         jmethodID persist_new_channel_meth;
4975         jmethodID update_persisted_channel_meth;
4976 } LDKPersist_JCalls;
4977 static void LDKPersist_JCalls_free(void* this_arg) {
4978         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4979         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4980                 JNIEnv *env;
4981                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4982                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4983                 FREE(j_calls);
4984         }
4985 }
4986 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
4987         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4988         JNIEnv *env;
4989         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
4990         LDKOutPoint id_var = id;
4991         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4992         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4993         long id_ref = (long)id_var.inner;
4994         if (id_var.is_owned) {
4995                 id_ref |= 1;
4996         }
4997         LDKChannelMonitor data_var = *data;
4998         data_var = ChannelMonitor_clone(data);
4999         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5000         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5001         long data_ref = (long)data_var.inner;
5002         if (data_var.is_owned) {
5003                 data_ref |= 1;
5004         }
5005         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5006         CHECK(obj != NULL);
5007         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
5008         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5009         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
5010         return ret_conv;
5011 }
5012 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5013         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5014         JNIEnv *env;
5015         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5016         LDKOutPoint id_var = id;
5017         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5018         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5019         long id_ref = (long)id_var.inner;
5020         if (id_var.is_owned) {
5021                 id_ref |= 1;
5022         }
5023         LDKChannelMonitorUpdate update_var = *update;
5024         update_var = ChannelMonitorUpdate_clone(update);
5025         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5026         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5027         long update_ref = (long)update_var.inner;
5028         if (update_var.is_owned) {
5029                 update_ref |= 1;
5030         }
5031         LDKChannelMonitor data_var = *data;
5032         data_var = ChannelMonitor_clone(data);
5033         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5034         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5035         long data_ref = (long)data_var.inner;
5036         if (data_var.is_owned) {
5037                 data_ref |= 1;
5038         }
5039         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5040         CHECK(obj != NULL);
5041         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5042         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5043         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
5044         return ret_conv;
5045 }
5046 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5047         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5048         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5049         return (void*) this_arg;
5050 }
5051 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
5052         jclass c = (*env)->GetObjectClass(env, o);
5053         CHECK(c != NULL);
5054         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5055         atomic_init(&calls->refcnt, 1);
5056         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5057         calls->o = (*env)->NewWeakGlobalRef(env, o);
5058         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
5059         CHECK(calls->persist_new_channel_meth != NULL);
5060         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
5061         CHECK(calls->update_persisted_channel_meth != NULL);
5062
5063         LDKPersist ret = {
5064                 .this_arg = (void*) calls,
5065                 .persist_new_channel = persist_new_channel_jcall,
5066                 .update_persisted_channel = update_persisted_channel_jcall,
5067                 .free = LDKPersist_JCalls_free,
5068         };
5069         return ret;
5070 }
5071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
5072         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5073         *res_ptr = LDKPersist_init(env, clz, o);
5074         return (long)res_ptr;
5075 }
5076 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) {
5077         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
5078         LDKOutPoint id_conv;
5079         id_conv.inner = (void*)(id & (~1));
5080         id_conv.is_owned = (id & 1) || (id == 0);
5081         id_conv = OutPoint_clone(&id_conv);
5082         LDKChannelMonitor data_conv;
5083         data_conv.inner = (void*)(data & (~1));
5084         data_conv.is_owned = false;
5085         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5086         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5087         return (long)ret_conv;
5088 }
5089
5090 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) {
5091         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
5092         LDKOutPoint id_conv;
5093         id_conv.inner = (void*)(id & (~1));
5094         id_conv.is_owned = (id & 1) || (id == 0);
5095         id_conv = OutPoint_clone(&id_conv);
5096         LDKChannelMonitorUpdate update_conv;
5097         update_conv.inner = (void*)(update & (~1));
5098         update_conv.is_owned = false;
5099         LDKChannelMonitor data_conv;
5100         data_conv.inner = (void*)(data & (~1));
5101         data_conv.is_owned = false;
5102         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5103         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5104         return (long)ret_conv;
5105 }
5106
5107 typedef struct LDKChannelMessageHandler_JCalls {
5108         atomic_size_t refcnt;
5109         JavaVM *vm;
5110         jweak o;
5111         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5112         jmethodID handle_open_channel_meth;
5113         jmethodID handle_accept_channel_meth;
5114         jmethodID handle_funding_created_meth;
5115         jmethodID handle_funding_signed_meth;
5116         jmethodID handle_funding_locked_meth;
5117         jmethodID handle_shutdown_meth;
5118         jmethodID handle_closing_signed_meth;
5119         jmethodID handle_update_add_htlc_meth;
5120         jmethodID handle_update_fulfill_htlc_meth;
5121         jmethodID handle_update_fail_htlc_meth;
5122         jmethodID handle_update_fail_malformed_htlc_meth;
5123         jmethodID handle_commitment_signed_meth;
5124         jmethodID handle_revoke_and_ack_meth;
5125         jmethodID handle_update_fee_meth;
5126         jmethodID handle_announcement_signatures_meth;
5127         jmethodID peer_disconnected_meth;
5128         jmethodID peer_connected_meth;
5129         jmethodID handle_channel_reestablish_meth;
5130         jmethodID handle_error_meth;
5131 } LDKChannelMessageHandler_JCalls;
5132 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5133         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5134         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5135                 JNIEnv *env;
5136                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5137                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5138                 FREE(j_calls);
5139         }
5140 }
5141 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5142         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5143         JNIEnv *env;
5144         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5145         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5146         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5147         LDKInitFeatures their_features_var = their_features;
5148         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5149         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5150         long their_features_ref = (long)their_features_var.inner;
5151         if (their_features_var.is_owned) {
5152                 their_features_ref |= 1;
5153         }
5154         LDKOpenChannel msg_var = *msg;
5155         msg_var = OpenChannel_clone(msg);
5156         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5157         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5158         long msg_ref = (long)msg_var.inner;
5159         if (msg_var.is_owned) {
5160                 msg_ref |= 1;
5161         }
5162         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5163         CHECK(obj != NULL);
5164         return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5165 }
5166 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5167         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5168         JNIEnv *env;
5169         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5170         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5171         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5172         LDKInitFeatures their_features_var = their_features;
5173         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5174         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5175         long their_features_ref = (long)their_features_var.inner;
5176         if (their_features_var.is_owned) {
5177                 their_features_ref |= 1;
5178         }
5179         LDKAcceptChannel msg_var = *msg;
5180         msg_var = AcceptChannel_clone(msg);
5181         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5182         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5183         long msg_ref = (long)msg_var.inner;
5184         if (msg_var.is_owned) {
5185                 msg_ref |= 1;
5186         }
5187         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5188         CHECK(obj != NULL);
5189         return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5190 }
5191 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5192         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5193         JNIEnv *env;
5194         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5195         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5196         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5197         LDKFundingCreated msg_var = *msg;
5198         msg_var = FundingCreated_clone(msg);
5199         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5200         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5201         long msg_ref = (long)msg_var.inner;
5202         if (msg_var.is_owned) {
5203                 msg_ref |= 1;
5204         }
5205         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5206         CHECK(obj != NULL);
5207         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5208 }
5209 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5210         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5211         JNIEnv *env;
5212         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5213         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5214         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5215         LDKFundingSigned msg_var = *msg;
5216         msg_var = FundingSigned_clone(msg);
5217         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5218         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5219         long msg_ref = (long)msg_var.inner;
5220         if (msg_var.is_owned) {
5221                 msg_ref |= 1;
5222         }
5223         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5224         CHECK(obj != NULL);
5225         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5226 }
5227 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5228         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5229         JNIEnv *env;
5230         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5231         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5232         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5233         LDKFundingLocked msg_var = *msg;
5234         msg_var = FundingLocked_clone(msg);
5235         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5236         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5237         long msg_ref = (long)msg_var.inner;
5238         if (msg_var.is_owned) {
5239                 msg_ref |= 1;
5240         }
5241         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5242         CHECK(obj != NULL);
5243         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5244 }
5245 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5246         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5247         JNIEnv *env;
5248         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5249         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5250         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5251         LDKInitFeatures their_features_var = *their_features;
5252         their_features_var = InitFeatures_clone(their_features);
5253         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5254         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5255         long their_features_ref = (long)their_features_var.inner;
5256         if (their_features_var.is_owned) {
5257                 their_features_ref |= 1;
5258         }
5259         LDKShutdown msg_var = *msg;
5260         msg_var = Shutdown_clone(msg);
5261         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5262         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5263         long msg_ref = (long)msg_var.inner;
5264         if (msg_var.is_owned) {
5265                 msg_ref |= 1;
5266         }
5267         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5268         CHECK(obj != NULL);
5269         return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5270 }
5271 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5272         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5273         JNIEnv *env;
5274         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5275         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5276         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5277         LDKClosingSigned msg_var = *msg;
5278         msg_var = ClosingSigned_clone(msg);
5279         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5280         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5281         long msg_ref = (long)msg_var.inner;
5282         if (msg_var.is_owned) {
5283                 msg_ref |= 1;
5284         }
5285         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5286         CHECK(obj != NULL);
5287         return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5288 }
5289 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5290         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5291         JNIEnv *env;
5292         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5293         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5294         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5295         LDKUpdateAddHTLC msg_var = *msg;
5296         msg_var = UpdateAddHTLC_clone(msg);
5297         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5298         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5299         long msg_ref = (long)msg_var.inner;
5300         if (msg_var.is_owned) {
5301                 msg_ref |= 1;
5302         }
5303         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5304         CHECK(obj != NULL);
5305         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5306 }
5307 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5308         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5309         JNIEnv *env;
5310         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5311         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5312         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5313         LDKUpdateFulfillHTLC msg_var = *msg;
5314         msg_var = UpdateFulfillHTLC_clone(msg);
5315         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5316         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5317         long msg_ref = (long)msg_var.inner;
5318         if (msg_var.is_owned) {
5319                 msg_ref |= 1;
5320         }
5321         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5322         CHECK(obj != NULL);
5323         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5324 }
5325 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5326         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5327         JNIEnv *env;
5328         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5329         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5330         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5331         LDKUpdateFailHTLC msg_var = *msg;
5332         msg_var = UpdateFailHTLC_clone(msg);
5333         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5334         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5335         long msg_ref = (long)msg_var.inner;
5336         if (msg_var.is_owned) {
5337                 msg_ref |= 1;
5338         }
5339         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5340         CHECK(obj != NULL);
5341         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5342 }
5343 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5344         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5345         JNIEnv *env;
5346         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5347         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5348         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5349         LDKUpdateFailMalformedHTLC msg_var = *msg;
5350         msg_var = UpdateFailMalformedHTLC_clone(msg);
5351         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5352         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5353         long msg_ref = (long)msg_var.inner;
5354         if (msg_var.is_owned) {
5355                 msg_ref |= 1;
5356         }
5357         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5358         CHECK(obj != NULL);
5359         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5360 }
5361 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5362         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5363         JNIEnv *env;
5364         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5365         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5366         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5367         LDKCommitmentSigned msg_var = *msg;
5368         msg_var = CommitmentSigned_clone(msg);
5369         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5370         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5371         long msg_ref = (long)msg_var.inner;
5372         if (msg_var.is_owned) {
5373                 msg_ref |= 1;
5374         }
5375         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5376         CHECK(obj != NULL);
5377         return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5378 }
5379 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5380         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5381         JNIEnv *env;
5382         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5383         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5384         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5385         LDKRevokeAndACK msg_var = *msg;
5386         msg_var = RevokeAndACK_clone(msg);
5387         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5388         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5389         long msg_ref = (long)msg_var.inner;
5390         if (msg_var.is_owned) {
5391                 msg_ref |= 1;
5392         }
5393         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5394         CHECK(obj != NULL);
5395         return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5396 }
5397 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5398         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5399         JNIEnv *env;
5400         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5401         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5402         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5403         LDKUpdateFee msg_var = *msg;
5404         msg_var = UpdateFee_clone(msg);
5405         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5406         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5407         long msg_ref = (long)msg_var.inner;
5408         if (msg_var.is_owned) {
5409                 msg_ref |= 1;
5410         }
5411         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5412         CHECK(obj != NULL);
5413         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5414 }
5415 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5416         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5417         JNIEnv *env;
5418         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5419         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5420         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5421         LDKAnnouncementSignatures msg_var = *msg;
5422         msg_var = AnnouncementSignatures_clone(msg);
5423         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5424         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5425         long msg_ref = (long)msg_var.inner;
5426         if (msg_var.is_owned) {
5427                 msg_ref |= 1;
5428         }
5429         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5430         CHECK(obj != NULL);
5431         return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5432 }
5433 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5434         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5435         JNIEnv *env;
5436         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5437         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5438         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5439         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5440         CHECK(obj != NULL);
5441         return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5442 }
5443 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5444         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5445         JNIEnv *env;
5446         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5447         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5448         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5449         LDKInit msg_var = *msg;
5450         msg_var = Init_clone(msg);
5451         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5452         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5453         long msg_ref = (long)msg_var.inner;
5454         if (msg_var.is_owned) {
5455                 msg_ref |= 1;
5456         }
5457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5458         CHECK(obj != NULL);
5459         return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5460 }
5461 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5462         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5463         JNIEnv *env;
5464         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5465         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5466         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5467         LDKChannelReestablish msg_var = *msg;
5468         msg_var = ChannelReestablish_clone(msg);
5469         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5470         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5471         long msg_ref = (long)msg_var.inner;
5472         if (msg_var.is_owned) {
5473                 msg_ref |= 1;
5474         }
5475         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5476         CHECK(obj != NULL);
5477         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5478 }
5479 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5480         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5481         JNIEnv *env;
5482         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5483         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5484         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5485         LDKErrorMessage msg_var = *msg;
5486         msg_var = ErrorMessage_clone(msg);
5487         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5488         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5489         long msg_ref = (long)msg_var.inner;
5490         if (msg_var.is_owned) {
5491                 msg_ref |= 1;
5492         }
5493         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5494         CHECK(obj != NULL);
5495         return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5496 }
5497 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5498         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5499         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5500         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5501         return (void*) this_arg;
5502 }
5503 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5504         jclass c = (*env)->GetObjectClass(env, o);
5505         CHECK(c != NULL);
5506         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5507         atomic_init(&calls->refcnt, 1);
5508         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5509         calls->o = (*env)->NewWeakGlobalRef(env, o);
5510         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
5511         CHECK(calls->handle_open_channel_meth != NULL);
5512         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
5513         CHECK(calls->handle_accept_channel_meth != NULL);
5514         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
5515         CHECK(calls->handle_funding_created_meth != NULL);
5516         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
5517         CHECK(calls->handle_funding_signed_meth != NULL);
5518         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
5519         CHECK(calls->handle_funding_locked_meth != NULL);
5520         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
5521         CHECK(calls->handle_shutdown_meth != NULL);
5522         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
5523         CHECK(calls->handle_closing_signed_meth != NULL);
5524         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
5525         CHECK(calls->handle_update_add_htlc_meth != NULL);
5526         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
5527         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
5528         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
5529         CHECK(calls->handle_update_fail_htlc_meth != NULL);
5530         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
5531         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
5532         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
5533         CHECK(calls->handle_commitment_signed_meth != NULL);
5534         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
5535         CHECK(calls->handle_revoke_and_ack_meth != NULL);
5536         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
5537         CHECK(calls->handle_update_fee_meth != NULL);
5538         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
5539         CHECK(calls->handle_announcement_signatures_meth != NULL);
5540         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
5541         CHECK(calls->peer_disconnected_meth != NULL);
5542         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
5543         CHECK(calls->peer_connected_meth != NULL);
5544         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
5545         CHECK(calls->handle_channel_reestablish_meth != NULL);
5546         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
5547         CHECK(calls->handle_error_meth != NULL);
5548
5549         LDKChannelMessageHandler ret = {
5550                 .this_arg = (void*) calls,
5551                 .handle_open_channel = handle_open_channel_jcall,
5552                 .handle_accept_channel = handle_accept_channel_jcall,
5553                 .handle_funding_created = handle_funding_created_jcall,
5554                 .handle_funding_signed = handle_funding_signed_jcall,
5555                 .handle_funding_locked = handle_funding_locked_jcall,
5556                 .handle_shutdown = handle_shutdown_jcall,
5557                 .handle_closing_signed = handle_closing_signed_jcall,
5558                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
5559                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
5560                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
5561                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
5562                 .handle_commitment_signed = handle_commitment_signed_jcall,
5563                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
5564                 .handle_update_fee = handle_update_fee_jcall,
5565                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
5566                 .peer_disconnected = peer_disconnected_jcall,
5567                 .peer_connected = peer_connected_jcall,
5568                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
5569                 .handle_error = handle_error_jcall,
5570                 .free = LDKChannelMessageHandler_JCalls_free,
5571                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
5572         };
5573         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5574         return ret;
5575 }
5576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
5577         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5578         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
5579         return (long)res_ptr;
5580 }
5581 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) {
5582         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5583         LDKPublicKey their_node_id_ref;
5584         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5585         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5586         LDKInitFeatures their_features_conv;
5587         their_features_conv.inner = (void*)(their_features & (~1));
5588         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5589         their_features_conv = InitFeatures_clone(&their_features_conv);
5590         LDKOpenChannel msg_conv;
5591         msg_conv.inner = (void*)(msg & (~1));
5592         msg_conv.is_owned = false;
5593         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5594 }
5595
5596 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) {
5597         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5598         LDKPublicKey their_node_id_ref;
5599         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5600         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5601         LDKInitFeatures their_features_conv;
5602         their_features_conv.inner = (void*)(their_features & (~1));
5603         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5604         their_features_conv = InitFeatures_clone(&their_features_conv);
5605         LDKAcceptChannel msg_conv;
5606         msg_conv.inner = (void*)(msg & (~1));
5607         msg_conv.is_owned = false;
5608         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5609 }
5610
5611 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) {
5612         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5613         LDKPublicKey their_node_id_ref;
5614         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5615         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5616         LDKFundingCreated msg_conv;
5617         msg_conv.inner = (void*)(msg & (~1));
5618         msg_conv.is_owned = false;
5619         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5620 }
5621
5622 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) {
5623         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5624         LDKPublicKey their_node_id_ref;
5625         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5626         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5627         LDKFundingSigned msg_conv;
5628         msg_conv.inner = (void*)(msg & (~1));
5629         msg_conv.is_owned = false;
5630         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5631 }
5632
5633 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) {
5634         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5635         LDKPublicKey their_node_id_ref;
5636         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5637         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5638         LDKFundingLocked msg_conv;
5639         msg_conv.inner = (void*)(msg & (~1));
5640         msg_conv.is_owned = false;
5641         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5642 }
5643
5644 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) {
5645         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5646         LDKPublicKey their_node_id_ref;
5647         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5648         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5649         LDKInitFeatures their_features_conv;
5650         their_features_conv.inner = (void*)(their_features & (~1));
5651         their_features_conv.is_owned = false;
5652         LDKShutdown msg_conv;
5653         msg_conv.inner = (void*)(msg & (~1));
5654         msg_conv.is_owned = false;
5655         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
5656 }
5657
5658 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) {
5659         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5660         LDKPublicKey their_node_id_ref;
5661         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5662         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5663         LDKClosingSigned msg_conv;
5664         msg_conv.inner = (void*)(msg & (~1));
5665         msg_conv.is_owned = false;
5666         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5667 }
5668
5669 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) {
5670         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5671         LDKPublicKey their_node_id_ref;
5672         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5673         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5674         LDKUpdateAddHTLC msg_conv;
5675         msg_conv.inner = (void*)(msg & (~1));
5676         msg_conv.is_owned = false;
5677         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5678 }
5679
5680 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) {
5681         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5682         LDKPublicKey their_node_id_ref;
5683         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5684         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5685         LDKUpdateFulfillHTLC msg_conv;
5686         msg_conv.inner = (void*)(msg & (~1));
5687         msg_conv.is_owned = false;
5688         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5689 }
5690
5691 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) {
5692         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5693         LDKPublicKey their_node_id_ref;
5694         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5695         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5696         LDKUpdateFailHTLC msg_conv;
5697         msg_conv.inner = (void*)(msg & (~1));
5698         msg_conv.is_owned = false;
5699         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5700 }
5701
5702 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) {
5703         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5704         LDKPublicKey their_node_id_ref;
5705         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5706         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5707         LDKUpdateFailMalformedHTLC msg_conv;
5708         msg_conv.inner = (void*)(msg & (~1));
5709         msg_conv.is_owned = false;
5710         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5711 }
5712
5713 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) {
5714         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5715         LDKPublicKey their_node_id_ref;
5716         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5717         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5718         LDKCommitmentSigned msg_conv;
5719         msg_conv.inner = (void*)(msg & (~1));
5720         msg_conv.is_owned = false;
5721         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5722 }
5723
5724 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) {
5725         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5726         LDKPublicKey their_node_id_ref;
5727         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5728         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5729         LDKRevokeAndACK msg_conv;
5730         msg_conv.inner = (void*)(msg & (~1));
5731         msg_conv.is_owned = false;
5732         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5733 }
5734
5735 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) {
5736         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5737         LDKPublicKey their_node_id_ref;
5738         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5739         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5740         LDKUpdateFee msg_conv;
5741         msg_conv.inner = (void*)(msg & (~1));
5742         msg_conv.is_owned = false;
5743         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5744 }
5745
5746 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) {
5747         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5748         LDKPublicKey their_node_id_ref;
5749         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5750         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5751         LDKAnnouncementSignatures msg_conv;
5752         msg_conv.inner = (void*)(msg & (~1));
5753         msg_conv.is_owned = false;
5754         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5755 }
5756
5757 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) {
5758         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5759         LDKPublicKey their_node_id_ref;
5760         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5761         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5762         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5763 }
5764
5765 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) {
5766         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5767         LDKPublicKey their_node_id_ref;
5768         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5769         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5770         LDKInit msg_conv;
5771         msg_conv.inner = (void*)(msg & (~1));
5772         msg_conv.is_owned = false;
5773         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5774 }
5775
5776 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) {
5777         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5778         LDKPublicKey their_node_id_ref;
5779         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5780         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5781         LDKChannelReestablish msg_conv;
5782         msg_conv.inner = (void*)(msg & (~1));
5783         msg_conv.is_owned = false;
5784         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5785 }
5786
5787 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) {
5788         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
5789         LDKPublicKey their_node_id_ref;
5790         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
5791         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
5792         LDKErrorMessage msg_conv;
5793         msg_conv.inner = (void*)(msg & (~1));
5794         msg_conv.is_owned = false;
5795         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5796 }
5797
5798 typedef struct LDKRoutingMessageHandler_JCalls {
5799         atomic_size_t refcnt;
5800         JavaVM *vm;
5801         jweak o;
5802         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5803         jmethodID handle_node_announcement_meth;
5804         jmethodID handle_channel_announcement_meth;
5805         jmethodID handle_channel_update_meth;
5806         jmethodID handle_htlc_fail_channel_update_meth;
5807         jmethodID get_next_channel_announcements_meth;
5808         jmethodID get_next_node_announcements_meth;
5809         jmethodID sync_routing_table_meth;
5810         jmethodID handle_reply_channel_range_meth;
5811         jmethodID handle_reply_short_channel_ids_end_meth;
5812         jmethodID handle_query_channel_range_meth;
5813         jmethodID handle_query_short_channel_ids_meth;
5814 } LDKRoutingMessageHandler_JCalls;
5815 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
5816         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5817         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5818                 JNIEnv *env;
5819                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5820                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5821                 FREE(j_calls);
5822         }
5823 }
5824 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5825         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5826         JNIEnv *env;
5827         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5828         LDKNodeAnnouncement msg_var = *msg;
5829         msg_var = NodeAnnouncement_clone(msg);
5830         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5831         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5832         long msg_ref = (long)msg_var.inner;
5833         if (msg_var.is_owned) {
5834                 msg_ref |= 1;
5835         }
5836         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5837         CHECK(obj != NULL);
5838         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
5839         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5840         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5841         return ret_conv;
5842 }
5843 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5844         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5845         JNIEnv *env;
5846         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5847         LDKChannelAnnouncement msg_var = *msg;
5848         msg_var = ChannelAnnouncement_clone(msg);
5849         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5850         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5851         long msg_ref = (long)msg_var.inner;
5852         if (msg_var.is_owned) {
5853                 msg_ref |= 1;
5854         }
5855         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5856         CHECK(obj != NULL);
5857         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
5858         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5859         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5860         return ret_conv;
5861 }
5862 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5863         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5864         JNIEnv *env;
5865         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5866         LDKChannelUpdate msg_var = *msg;
5867         msg_var = ChannelUpdate_clone(msg);
5868         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5869         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5870         long msg_ref = (long)msg_var.inner;
5871         if (msg_var.is_owned) {
5872                 msg_ref |= 1;
5873         }
5874         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5875         CHECK(obj != NULL);
5876         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
5877         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5878         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
5879         return ret_conv;
5880 }
5881 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5882         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5883         JNIEnv *env;
5884         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5885         long ret_update = (long)update;
5886         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5887         CHECK(obj != NULL);
5888         return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5889 }
5890 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5891         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5892         JNIEnv *env;
5893         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5894         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5895         CHECK(obj != NULL);
5896         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5897         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
5898         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5899         if (ret_constr.datalen > 0)
5900                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5901         else
5902                 ret_constr.data = NULL;
5903         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5904         for (size_t l = 0; l < ret_constr.datalen; l++) {
5905                 int64_t ret_conv_63 = ret_vals[l];
5906                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
5907                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ret_conv_63);
5908                 ret_constr.data[l] = ret_conv_63_conv;
5909         }
5910         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5911         return ret_constr;
5912 }
5913 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5914         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5915         JNIEnv *env;
5916         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5917         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
5918         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
5919         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5920         CHECK(obj != NULL);
5921         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5922         LDKCVec_NodeAnnouncementZ ret_constr;
5923         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5924         if (ret_constr.datalen > 0)
5925                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5926         else
5927                 ret_constr.data = NULL;
5928         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5929         for (size_t s = 0; s < ret_constr.datalen; s++) {
5930                 int64_t ret_conv_18 = ret_vals[s];
5931                 LDKNodeAnnouncement ret_conv_18_conv;
5932                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
5933                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
5934                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
5935                 ret_constr.data[s] = ret_conv_18_conv;
5936         }
5937         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5938         return ret_constr;
5939 }
5940 void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
5941         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5942         JNIEnv *env;
5943         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5944         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5945         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5946         LDKInit init_var = *init;
5947         init_var = Init_clone(init);
5948         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5949         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5950         long init_ref = (long)init_var.inner;
5951         if (init_var.is_owned) {
5952                 init_ref |= 1;
5953         }
5954         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5955         CHECK(obj != NULL);
5956         return (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
5957 }
5958 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
5959         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5960         JNIEnv *env;
5961         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5962         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5963         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5964         LDKReplyChannelRange msg_var = msg;
5965         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5966         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5967         long msg_ref = (long)msg_var.inner;
5968         if (msg_var.is_owned) {
5969                 msg_ref |= 1;
5970         }
5971         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5972         CHECK(obj != NULL);
5973         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
5974         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5975         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5976         return ret_conv;
5977 }
5978 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
5979         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5980         JNIEnv *env;
5981         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
5982         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
5983         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
5984         LDKReplyShortChannelIdsEnd msg_var = msg;
5985         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5986         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5987         long msg_ref = (long)msg_var.inner;
5988         if (msg_var.is_owned) {
5989                 msg_ref |= 1;
5990         }
5991         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5992         CHECK(obj != NULL);
5993         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
5994         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5995         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5996         return ret_conv;
5997 }
5998 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
5999         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6000         JNIEnv *env;
6001         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6002         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6003         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6004         LDKQueryChannelRange msg_var = msg;
6005         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6006         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6007         long msg_ref = (long)msg_var.inner;
6008         if (msg_var.is_owned) {
6009                 msg_ref |= 1;
6010         }
6011         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6012         CHECK(obj != NULL);
6013         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6014         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6015         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
6016         return ret_conv;
6017 }
6018 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6019         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6020         JNIEnv *env;
6021         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6022         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6023         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6024         LDKQueryShortChannelIds msg_var = msg;
6025         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6026         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6027         long msg_ref = (long)msg_var.inner;
6028         if (msg_var.is_owned) {
6029                 msg_ref |= 1;
6030         }
6031         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6032         CHECK(obj != NULL);
6033         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6034         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6035         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
6036         return ret_conv;
6037 }
6038 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6039         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6040         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6041         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6042         return (void*) this_arg;
6043 }
6044 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6045         jclass c = (*env)->GetObjectClass(env, o);
6046         CHECK(c != NULL);
6047         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6048         atomic_init(&calls->refcnt, 1);
6049         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6050         calls->o = (*env)->NewWeakGlobalRef(env, o);
6051         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
6052         CHECK(calls->handle_node_announcement_meth != NULL);
6053         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
6054         CHECK(calls->handle_channel_announcement_meth != NULL);
6055         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
6056         CHECK(calls->handle_channel_update_meth != NULL);
6057         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
6058         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
6059         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
6060         CHECK(calls->get_next_channel_announcements_meth != NULL);
6061         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
6062         CHECK(calls->get_next_node_announcements_meth != NULL);
6063         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
6064         CHECK(calls->sync_routing_table_meth != NULL);
6065         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
6066         CHECK(calls->handle_reply_channel_range_meth != NULL);
6067         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
6068         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
6069         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
6070         CHECK(calls->handle_query_channel_range_meth != NULL);
6071         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
6072         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
6073
6074         LDKRoutingMessageHandler ret = {
6075                 .this_arg = (void*) calls,
6076                 .handle_node_announcement = handle_node_announcement_jcall,
6077                 .handle_channel_announcement = handle_channel_announcement_jcall,
6078                 .handle_channel_update = handle_channel_update_jcall,
6079                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
6080                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
6081                 .get_next_node_announcements = get_next_node_announcements_jcall,
6082                 .sync_routing_table = sync_routing_table_jcall,
6083                 .handle_reply_channel_range = handle_reply_channel_range_jcall,
6084                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
6085                 .handle_query_channel_range = handle_query_channel_range_jcall,
6086                 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
6087                 .free = LDKRoutingMessageHandler_JCalls_free,
6088                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
6089         };
6090         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6091         return ret;
6092 }
6093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
6094         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6095         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
6096         return (long)res_ptr;
6097 }
6098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6099         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6100         LDKNodeAnnouncement msg_conv;
6101         msg_conv.inner = (void*)(msg & (~1));
6102         msg_conv.is_owned = false;
6103         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6104         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6105         return (long)ret_conv;
6106 }
6107
6108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6109         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6110         LDKChannelAnnouncement msg_conv;
6111         msg_conv.inner = (void*)(msg & (~1));
6112         msg_conv.is_owned = false;
6113         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6114         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6115         return (long)ret_conv;
6116 }
6117
6118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6119         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6120         LDKChannelUpdate msg_conv;
6121         msg_conv.inner = (void*)(msg & (~1));
6122         msg_conv.is_owned = false;
6123         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6124         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6125         return (long)ret_conv;
6126 }
6127
6128 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) {
6129         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6130         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6131         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6132 }
6133
6134 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) {
6135         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6136         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6137         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6138         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6139         for (size_t l = 0; l < ret_var.datalen; l++) {
6140                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6141                 *ret_conv_63_ref = ret_var.data[l];
6142                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
6143         }
6144         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6145         FREE(ret_var.data);
6146         return ret_arr;
6147 }
6148
6149 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) {
6150         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6151         LDKPublicKey starting_point_ref;
6152         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
6153         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
6154         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6155         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6156         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6157         for (size_t s = 0; s < ret_var.datalen; s++) {
6158                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6159                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6160                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6161                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
6162                 if (ret_conv_18_var.is_owned) {
6163                         ret_conv_18_ref |= 1;
6164                 }
6165                 ret_arr_ptr[s] = ret_conv_18_ref;
6166         }
6167         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6168         FREE(ret_var.data);
6169         return ret_arr;
6170 }
6171
6172 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) {
6173         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6174         LDKPublicKey their_node_id_ref;
6175         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6176         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6177         LDKInit init_conv;
6178         init_conv.inner = (void*)(init & (~1));
6179         init_conv.is_owned = false;
6180         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6181 }
6182
6183 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) {
6184         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6185         LDKPublicKey their_node_id_ref;
6186         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6187         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6188         LDKReplyChannelRange msg_conv;
6189         msg_conv.inner = (void*)(msg & (~1));
6190         msg_conv.is_owned = (msg & 1) || (msg == 0);
6191         msg_conv = ReplyChannelRange_clone(&msg_conv);
6192         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6193         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6194         return (long)ret_conv;
6195 }
6196
6197 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) {
6198         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6199         LDKPublicKey their_node_id_ref;
6200         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6201         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6202         LDKReplyShortChannelIdsEnd msg_conv;
6203         msg_conv.inner = (void*)(msg & (~1));
6204         msg_conv.is_owned = (msg & 1) || (msg == 0);
6205         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6206         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6207         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6208         return (long)ret_conv;
6209 }
6210
6211 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) {
6212         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6213         LDKPublicKey their_node_id_ref;
6214         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6215         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6216         LDKQueryChannelRange msg_conv;
6217         msg_conv.inner = (void*)(msg & (~1));
6218         msg_conv.is_owned = (msg & 1) || (msg == 0);
6219         msg_conv = QueryChannelRange_clone(&msg_conv);
6220         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6221         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6222         return (long)ret_conv;
6223 }
6224
6225 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) {
6226         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
6227         LDKPublicKey their_node_id_ref;
6228         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
6229         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
6230         LDKQueryShortChannelIds msg_conv;
6231         msg_conv.inner = (void*)(msg & (~1));
6232         msg_conv.is_owned = (msg & 1) || (msg == 0);
6233         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6234         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6235         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6236         return (long)ret_conv;
6237 }
6238
6239 typedef struct LDKSocketDescriptor_JCalls {
6240         atomic_size_t refcnt;
6241         JavaVM *vm;
6242         jweak o;
6243         jmethodID send_data_meth;
6244         jmethodID disconnect_socket_meth;
6245         jmethodID eq_meth;
6246         jmethodID hash_meth;
6247 } LDKSocketDescriptor_JCalls;
6248 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6249         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6250         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6251                 JNIEnv *env;
6252                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6253                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6254                 FREE(j_calls);
6255         }
6256 }
6257 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6258         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6259         JNIEnv *env;
6260         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6261         LDKu8slice data_var = data;
6262         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
6263         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
6264         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6265         CHECK(obj != NULL);
6266         return (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
6267 }
6268 void disconnect_socket_jcall(void* this_arg) {
6269         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6270         JNIEnv *env;
6271         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6272         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6273         CHECK(obj != NULL);
6274         return (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
6275 }
6276 bool eq_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6277         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6278         JNIEnv *env;
6279         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6280         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6281         *other_arg_clone = SocketDescriptor_clone(other_arg);
6282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6283         CHECK(obj != NULL);
6284         return (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (long)other_arg_clone);
6285 }
6286 uint64_t hash_jcall(const void* this_arg) {
6287         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6288         JNIEnv *env;
6289         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK);
6290         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6291         CHECK(obj != NULL);
6292         return (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
6293 }
6294 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6295         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6296         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6297         return (void*) this_arg;
6298 }
6299 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
6300         jclass c = (*env)->GetObjectClass(env, o);
6301         CHECK(c != NULL);
6302         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6303         atomic_init(&calls->refcnt, 1);
6304         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6305         calls->o = (*env)->NewWeakGlobalRef(env, o);
6306         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
6307         CHECK(calls->send_data_meth != NULL);
6308         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
6309         CHECK(calls->disconnect_socket_meth != NULL);
6310         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
6311         CHECK(calls->eq_meth != NULL);
6312         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
6313         CHECK(calls->hash_meth != NULL);
6314
6315         LDKSocketDescriptor ret = {
6316                 .this_arg = (void*) calls,
6317                 .send_data = send_data_jcall,
6318                 .disconnect_socket = disconnect_socket_jcall,
6319                 .eq = eq_jcall,
6320                 .hash = hash_jcall,
6321                 .clone = LDKSocketDescriptor_JCalls_clone,
6322                 .free = LDKSocketDescriptor_JCalls_free,
6323         };
6324         return ret;
6325 }
6326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
6327         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6328         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
6329         return (long)res_ptr;
6330 }
6331 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) {
6332         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
6333         LDKu8slice data_ref;
6334         data_ref.datalen = (*env)->GetArrayLength(env, data);
6335         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
6336         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6337         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
6338         return ret_val;
6339 }
6340
6341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
6342         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
6343         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6344 }
6345
6346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
6347         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
6348         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6349         return ret_val;
6350 }
6351
6352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
6353         LDKTransaction _res_ref;
6354         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
6355         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6356         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
6357         _res_ref.data_is_owned = true;
6358         Transaction_free(_res_ref);
6359 }
6360
6361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
6362         if ((_res & 1) != 0) return;
6363         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6364         FREE((void*)_res);
6365         TxOut_free(_res_conv);
6366 }
6367
6368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6369         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6370         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6371         *ret_ref = TxOut_clone(orig_conv);
6372         return (long)ret_ref;
6373 }
6374
6375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6376         LDKSecretKey o_ref;
6377         CHECK((*env)->GetArrayLength(env, o) == 32);
6378         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
6379         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6380         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6381         return (long)ret_conv;
6382 }
6383
6384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6385         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6386         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6387         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6388         return (long)ret_conv;
6389 }
6390
6391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6392         if ((_res & 1) != 0) return;
6393         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6394         FREE((void*)_res);
6395         CResult_SecretKeyErrorZ_free(_res_conv);
6396 }
6397
6398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6399         LDKPublicKey o_ref;
6400         CHECK((*env)->GetArrayLength(env, o) == 33);
6401         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
6402         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6403         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6404         return (long)ret_conv;
6405 }
6406
6407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6408         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6409         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6410         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6411         return (long)ret_conv;
6412 }
6413
6414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6415         if ((_res & 1) != 0) return;
6416         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6417         FREE((void*)_res);
6418         CResult_PublicKeyErrorZ_free(_res_conv);
6419 }
6420
6421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6422         LDKTxCreationKeys o_conv;
6423         o_conv.inner = (void*)(o & (~1));
6424         o_conv.is_owned = (o & 1) || (o == 0);
6425         o_conv = TxCreationKeys_clone(&o_conv);
6426         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6427         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6428         return (long)ret_conv;
6429 }
6430
6431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6432         LDKDecodeError e_conv;
6433         e_conv.inner = (void*)(e & (~1));
6434         e_conv.is_owned = (e & 1) || (e == 0);
6435         e_conv = DecodeError_clone(&e_conv);
6436         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6437         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6438         return (long)ret_conv;
6439 }
6440
6441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6442         if ((_res & 1) != 0) return;
6443         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6444         FREE((void*)_res);
6445         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6446 }
6447
6448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6449         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6450         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6451         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6452         return (long)ret_conv;
6453 }
6454
6455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6456         LDKChannelPublicKeys o_conv;
6457         o_conv.inner = (void*)(o & (~1));
6458         o_conv.is_owned = (o & 1) || (o == 0);
6459         o_conv = ChannelPublicKeys_clone(&o_conv);
6460         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6461         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6462         return (long)ret_conv;
6463 }
6464
6465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6466         LDKDecodeError e_conv;
6467         e_conv.inner = (void*)(e & (~1));
6468         e_conv.is_owned = (e & 1) || (e == 0);
6469         e_conv = DecodeError_clone(&e_conv);
6470         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6471         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6472         return (long)ret_conv;
6473 }
6474
6475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6476         if ((_res & 1) != 0) return;
6477         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6478         FREE((void*)_res);
6479         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6480 }
6481
6482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6483         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6484         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6485         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6486         return (long)ret_conv;
6487 }
6488
6489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6490         LDKTxCreationKeys o_conv;
6491         o_conv.inner = (void*)(o & (~1));
6492         o_conv.is_owned = (o & 1) || (o == 0);
6493         o_conv = TxCreationKeys_clone(&o_conv);
6494         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6495         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6496         return (long)ret_conv;
6497 }
6498
6499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
6500         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
6501         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6502         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6503         return (long)ret_conv;
6504 }
6505
6506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6507         if ((_res & 1) != 0) return;
6508         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6509         FREE((void*)_res);
6510         CResult_TxCreationKeysErrorZ_free(_res_conv);
6511 }
6512
6513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6514         LDKHTLCOutputInCommitment o_conv;
6515         o_conv.inner = (void*)(o & (~1));
6516         o_conv.is_owned = (o & 1) || (o == 0);
6517         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6518         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6519         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6520         return (long)ret_conv;
6521 }
6522
6523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6524         LDKDecodeError e_conv;
6525         e_conv.inner = (void*)(e & (~1));
6526         e_conv.is_owned = (e & 1) || (e == 0);
6527         e_conv = DecodeError_clone(&e_conv);
6528         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6529         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6530         return (long)ret_conv;
6531 }
6532
6533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6534         if ((_res & 1) != 0) return;
6535         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6536         FREE((void*)_res);
6537         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6538 }
6539
6540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6541         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6542         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6543         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6544         return (long)ret_conv;
6545 }
6546
6547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6548         LDKCounterpartyChannelTransactionParameters o_conv;
6549         o_conv.inner = (void*)(o & (~1));
6550         o_conv.is_owned = (o & 1) || (o == 0);
6551         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6552         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6553         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6554         return (long)ret_conv;
6555 }
6556
6557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6558         LDKDecodeError e_conv;
6559         e_conv.inner = (void*)(e & (~1));
6560         e_conv.is_owned = (e & 1) || (e == 0);
6561         e_conv = DecodeError_clone(&e_conv);
6562         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6563         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6564         return (long)ret_conv;
6565 }
6566
6567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6568         if ((_res & 1) != 0) return;
6569         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6570         FREE((void*)_res);
6571         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6572 }
6573
6574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6575         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6576         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6577         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6578         return (long)ret_conv;
6579 }
6580
6581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6582         LDKChannelTransactionParameters o_conv;
6583         o_conv.inner = (void*)(o & (~1));
6584         o_conv.is_owned = (o & 1) || (o == 0);
6585         o_conv = ChannelTransactionParameters_clone(&o_conv);
6586         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6587         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6588         return (long)ret_conv;
6589 }
6590
6591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6592         LDKDecodeError e_conv;
6593         e_conv.inner = (void*)(e & (~1));
6594         e_conv.is_owned = (e & 1) || (e == 0);
6595         e_conv = DecodeError_clone(&e_conv);
6596         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6597         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6598         return (long)ret_conv;
6599 }
6600
6601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6602         if ((_res & 1) != 0) return;
6603         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6604         FREE((void*)_res);
6605         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6606 }
6607
6608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6609         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6610         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6611         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6612         return (long)ret_conv;
6613 }
6614
6615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
6616         LDKCVec_SignatureZ _res_constr;
6617         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6618         if (_res_constr.datalen > 0)
6619                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6620         else
6621                 _res_constr.data = NULL;
6622         for (size_t i = 0; i < _res_constr.datalen; i++) {
6623                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
6624                 LDKSignature _res_conv_8_ref;
6625                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
6626                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
6627                 _res_constr.data[i] = _res_conv_8_ref;
6628         }
6629         CVec_SignatureZ_free(_res_constr);
6630 }
6631
6632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6633         LDKHolderCommitmentTransaction o_conv;
6634         o_conv.inner = (void*)(o & (~1));
6635         o_conv.is_owned = (o & 1) || (o == 0);
6636         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6637         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6638         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6639         return (long)ret_conv;
6640 }
6641
6642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6643         LDKDecodeError e_conv;
6644         e_conv.inner = (void*)(e & (~1));
6645         e_conv.is_owned = (e & 1) || (e == 0);
6646         e_conv = DecodeError_clone(&e_conv);
6647         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6648         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6649         return (long)ret_conv;
6650 }
6651
6652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6653         if ((_res & 1) != 0) return;
6654         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6655         FREE((void*)_res);
6656         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6657 }
6658
6659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6660         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6661         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6662         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6663         return (long)ret_conv;
6664 }
6665
6666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6667         LDKBuiltCommitmentTransaction o_conv;
6668         o_conv.inner = (void*)(o & (~1));
6669         o_conv.is_owned = (o & 1) || (o == 0);
6670         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6671         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6672         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6673         return (long)ret_conv;
6674 }
6675
6676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6677         LDKDecodeError e_conv;
6678         e_conv.inner = (void*)(e & (~1));
6679         e_conv.is_owned = (e & 1) || (e == 0);
6680         e_conv = DecodeError_clone(&e_conv);
6681         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6682         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6683         return (long)ret_conv;
6684 }
6685
6686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6687         if ((_res & 1) != 0) return;
6688         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6689         FREE((void*)_res);
6690         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6691 }
6692
6693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6694         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6695         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6696         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6697         return (long)ret_conv;
6698 }
6699
6700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6701         LDKCommitmentTransaction o_conv;
6702         o_conv.inner = (void*)(o & (~1));
6703         o_conv.is_owned = (o & 1) || (o == 0);
6704         o_conv = CommitmentTransaction_clone(&o_conv);
6705         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6706         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6707         return (long)ret_conv;
6708 }
6709
6710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6711         LDKDecodeError e_conv;
6712         e_conv.inner = (void*)(e & (~1));
6713         e_conv.is_owned = (e & 1) || (e == 0);
6714         e_conv = DecodeError_clone(&e_conv);
6715         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6716         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6717         return (long)ret_conv;
6718 }
6719
6720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6721         if ((_res & 1) != 0) return;
6722         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6723         FREE((void*)_res);
6724         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6725 }
6726
6727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6728         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6729         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6730         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6731         return (long)ret_conv;
6732 }
6733
6734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6735         LDKTrustedCommitmentTransaction o_conv;
6736         o_conv.inner = (void*)(o & (~1));
6737         o_conv.is_owned = (o & 1) || (o == 0);
6738         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6739         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6740         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6741         return (long)ret_conv;
6742 }
6743
6744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
6745         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6746         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6747         return (long)ret_conv;
6748 }
6749
6750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6751         if ((_res & 1) != 0) return;
6752         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6753         FREE((void*)_res);
6754         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6755 }
6756
6757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
6758         LDKCVec_SignatureZ o_constr;
6759         o_constr.datalen = (*env)->GetArrayLength(env, o);
6760         if (o_constr.datalen > 0)
6761                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6762         else
6763                 o_constr.data = NULL;
6764         for (size_t i = 0; i < o_constr.datalen; i++) {
6765                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
6766                 LDKSignature o_conv_8_ref;
6767                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
6768                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
6769                 o_constr.data[i] = o_conv_8_ref;
6770         }
6771         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6772         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6773         return (long)ret_conv;
6774 }
6775
6776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
6777         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6778         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
6779         return (long)ret_conv;
6780 }
6781
6782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6783         if ((_res & 1) != 0) return;
6784         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
6785         FREE((void*)_res);
6786         CResult_CVec_SignatureZNoneZ_free(_res_conv);
6787 }
6788
6789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6790         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
6791         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6792         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
6793         return (long)ret_conv;
6794 }
6795
6796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
6797         LDKCVec_PublicKeyZ _res_constr;
6798         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
6799         if (_res_constr.datalen > 0)
6800                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
6801         else
6802                 _res_constr.data = NULL;
6803         for (size_t i = 0; i < _res_constr.datalen; i++) {
6804                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
6805                 LDKPublicKey _res_conv_8_ref;
6806                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
6807                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
6808                 _res_constr.data[i] = _res_conv_8_ref;
6809         }
6810         CVec_PublicKeyZ_free(_res_constr);
6811 }
6812
6813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
6814         LDKCVec_u8Z _res_ref;
6815         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
6816         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
6817         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
6818         CVec_u8Z_free(_res_ref);
6819 }
6820
6821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
6822         LDKCVec_u8Z o_ref;
6823         o_ref.datalen = (*env)->GetArrayLength(env, o);
6824         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
6825         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
6826         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6827         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
6828         return (long)ret_conv;
6829 }
6830
6831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6832         LDKPeerHandleError e_conv;
6833         e_conv.inner = (void*)(e & (~1));
6834         e_conv.is_owned = (e & 1) || (e == 0);
6835         e_conv = PeerHandleError_clone(&e_conv);
6836         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6837         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
6838         return (long)ret_conv;
6839 }
6840
6841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6842         if ((_res & 1) != 0) return;
6843         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6844         FREE((void*)_res);
6845         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
6846 }
6847
6848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6849         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
6850         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6851         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
6852         return (long)ret_conv;
6853 }
6854
6855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
6856         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6857         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
6858         return (long)ret_conv;
6859 }
6860
6861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6862         LDKPeerHandleError e_conv;
6863         e_conv.inner = (void*)(e & (~1));
6864         e_conv.is_owned = (e & 1) || (e == 0);
6865         e_conv = PeerHandleError_clone(&e_conv);
6866         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6867         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
6868         return (long)ret_conv;
6869 }
6870
6871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6872         if ((_res & 1) != 0) return;
6873         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6874         FREE((void*)_res);
6875         CResult_NonePeerHandleErrorZ_free(_res_conv);
6876 }
6877
6878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6879         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
6880         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6881         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
6882         return (long)ret_conv;
6883 }
6884
6885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
6886         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6887         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
6888         return (long)ret_conv;
6889 }
6890
6891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6892         LDKPeerHandleError e_conv;
6893         e_conv.inner = (void*)(e & (~1));
6894         e_conv.is_owned = (e & 1) || (e == 0);
6895         e_conv = PeerHandleError_clone(&e_conv);
6896         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6897         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
6898         return (long)ret_conv;
6899 }
6900
6901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6902         if ((_res & 1) != 0) return;
6903         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6904         FREE((void*)_res);
6905         CResult_boolPeerHandleErrorZ_free(_res_conv);
6906 }
6907
6908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
6909         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
6910         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6911         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
6912         return (long)ret_conv;
6913 }
6914
6915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6916         LDKInitFeatures o_conv;
6917         o_conv.inner = (void*)(o & (~1));
6918         o_conv.is_owned = (o & 1) || (o == 0);
6919         o_conv = InitFeatures_clone(&o_conv);
6920         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6921         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
6922         return (long)ret_conv;
6923 }
6924
6925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6926         LDKDecodeError e_conv;
6927         e_conv.inner = (void*)(e & (~1));
6928         e_conv.is_owned = (e & 1) || (e == 0);
6929         e_conv = DecodeError_clone(&e_conv);
6930         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6931         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
6932         return (long)ret_conv;
6933 }
6934
6935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6936         if ((_res & 1) != 0) return;
6937         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6938         FREE((void*)_res);
6939         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
6940 }
6941
6942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6943         LDKNodeFeatures o_conv;
6944         o_conv.inner = (void*)(o & (~1));
6945         o_conv.is_owned = (o & 1) || (o == 0);
6946         o_conv = NodeFeatures_clone(&o_conv);
6947         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6948         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
6949         return (long)ret_conv;
6950 }
6951
6952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6953         LDKDecodeError e_conv;
6954         e_conv.inner = (void*)(e & (~1));
6955         e_conv.is_owned = (e & 1) || (e == 0);
6956         e_conv = DecodeError_clone(&e_conv);
6957         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6958         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
6959         return (long)ret_conv;
6960 }
6961
6962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6963         if ((_res & 1) != 0) return;
6964         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6965         FREE((void*)_res);
6966         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
6967 }
6968
6969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6970         LDKChannelFeatures o_conv;
6971         o_conv.inner = (void*)(o & (~1));
6972         o_conv.is_owned = (o & 1) || (o == 0);
6973         o_conv = ChannelFeatures_clone(&o_conv);
6974         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6975         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
6976         return (long)ret_conv;
6977 }
6978
6979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
6980         LDKDecodeError e_conv;
6981         e_conv.inner = (void*)(e & (~1));
6982         e_conv.is_owned = (e & 1) || (e == 0);
6983         e_conv = DecodeError_clone(&e_conv);
6984         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6985         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
6986         return (long)ret_conv;
6987 }
6988
6989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
6990         if ((_res & 1) != 0) return;
6991         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6992         FREE((void*)_res);
6993         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
6994 }
6995
6996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
6997         LDKChannelConfig o_conv;
6998         o_conv.inner = (void*)(o & (~1));
6999         o_conv.is_owned = (o & 1) || (o == 0);
7000         o_conv = ChannelConfig_clone(&o_conv);
7001         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7002         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
7003         return (long)ret_conv;
7004 }
7005
7006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7007         LDKDecodeError e_conv;
7008         e_conv.inner = (void*)(e & (~1));
7009         e_conv.is_owned = (e & 1) || (e == 0);
7010         e_conv = DecodeError_clone(&e_conv);
7011         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7012         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
7013         return (long)ret_conv;
7014 }
7015
7016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7017         if ((_res & 1) != 0) return;
7018         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
7019         FREE((void*)_res);
7020         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
7021 }
7022
7023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7024         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
7025         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
7026         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
7027         return (long)ret_conv;
7028 }
7029
7030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
7031         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7032         *ret_conv = CResult_boolLightningErrorZ_ok(o);
7033         return (long)ret_conv;
7034 }
7035
7036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7037         LDKLightningError e_conv;
7038         e_conv.inner = (void*)(e & (~1));
7039         e_conv.is_owned = (e & 1) || (e == 0);
7040         e_conv = LightningError_clone(&e_conv);
7041         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7042         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
7043         return (long)ret_conv;
7044 }
7045
7046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7047         if ((_res & 1) != 0) return;
7048         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
7049         FREE((void*)_res);
7050         CResult_boolLightningErrorZ_free(_res_conv);
7051 }
7052
7053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7054         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
7055         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7056         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
7057         return (long)ret_conv;
7058 }
7059
7060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7061         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
7062         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
7063         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
7064         return (long)ret_ref;
7065 }
7066
7067 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) {
7068         LDKChannelAnnouncement a_conv;
7069         a_conv.inner = (void*)(a & (~1));
7070         a_conv.is_owned = (a & 1) || (a == 0);
7071         a_conv = ChannelAnnouncement_clone(&a_conv);
7072         LDKChannelUpdate b_conv;
7073         b_conv.inner = (void*)(b & (~1));
7074         b_conv.is_owned = (b & 1) || (b == 0);
7075         b_conv = ChannelUpdate_clone(&b_conv);
7076         LDKChannelUpdate c_conv;
7077         c_conv.inner = (void*)(c & (~1));
7078         c_conv.is_owned = (c & 1) || (c == 0);
7079         c_conv = ChannelUpdate_clone(&c_conv);
7080         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
7081         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
7082         return (long)ret_ref;
7083 }
7084
7085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7086         if ((_res & 1) != 0) return;
7087         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
7088         FREE((void*)_res);
7089         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
7090 }
7091
7092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7093         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
7094         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7095         if (_res_constr.datalen > 0)
7096                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
7097         else
7098                 _res_constr.data = NULL;
7099         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7100         for (size_t l = 0; l < _res_constr.datalen; l++) {
7101                 int64_t _res_conv_63 = _res_vals[l];
7102                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
7103                 FREE((void*)_res_conv_63);
7104                 _res_constr.data[l] = _res_conv_63_conv;
7105         }
7106         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7107         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
7108 }
7109
7110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7111         LDKCVec_NodeAnnouncementZ _res_constr;
7112         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7113         if (_res_constr.datalen > 0)
7114                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
7115         else
7116                 _res_constr.data = NULL;
7117         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7118         for (size_t s = 0; s < _res_constr.datalen; s++) {
7119                 int64_t _res_conv_18 = _res_vals[s];
7120                 LDKNodeAnnouncement _res_conv_18_conv;
7121                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
7122                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
7123                 _res_constr.data[s] = _res_conv_18_conv;
7124         }
7125         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7126         CVec_NodeAnnouncementZ_free(_res_constr);
7127 }
7128
7129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
7130         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7131         *ret_conv = CResult_NoneLightningErrorZ_ok();
7132         return (long)ret_conv;
7133 }
7134
7135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7136         LDKLightningError e_conv;
7137         e_conv.inner = (void*)(e & (~1));
7138         e_conv.is_owned = (e & 1) || (e == 0);
7139         e_conv = LightningError_clone(&e_conv);
7140         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7141         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
7142         return (long)ret_conv;
7143 }
7144
7145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7146         if ((_res & 1) != 0) return;
7147         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
7148         FREE((void*)_res);
7149         CResult_NoneLightningErrorZ_free(_res_conv);
7150 }
7151
7152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7153         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
7154         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7155         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
7156         return (long)ret_conv;
7157 }
7158
7159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7160         LDKCVec_MessageSendEventZ _res_constr;
7161         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7162         if (_res_constr.datalen > 0)
7163                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7164         else
7165                 _res_constr.data = NULL;
7166         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7167         for (size_t s = 0; s < _res_constr.datalen; s++) {
7168                 int64_t _res_conv_18 = _res_vals[s];
7169                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7170                 FREE((void*)_res_conv_18);
7171                 _res_constr.data[s] = _res_conv_18_conv;
7172         }
7173         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7174         CVec_MessageSendEventZ_free(_res_constr);
7175 }
7176
7177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7178         LDKDirectionalChannelInfo o_conv;
7179         o_conv.inner = (void*)(o & (~1));
7180         o_conv.is_owned = (o & 1) || (o == 0);
7181         o_conv = DirectionalChannelInfo_clone(&o_conv);
7182         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7183         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
7184         return (long)ret_conv;
7185 }
7186
7187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7188         LDKDecodeError e_conv;
7189         e_conv.inner = (void*)(e & (~1));
7190         e_conv.is_owned = (e & 1) || (e == 0);
7191         e_conv = DecodeError_clone(&e_conv);
7192         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7193         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
7194         return (long)ret_conv;
7195 }
7196
7197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7198         if ((_res & 1) != 0) return;
7199         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7200         FREE((void*)_res);
7201         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
7202 }
7203
7204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7205         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
7206         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7207         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
7208         return (long)ret_conv;
7209 }
7210
7211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7212         LDKChannelInfo o_conv;
7213         o_conv.inner = (void*)(o & (~1));
7214         o_conv.is_owned = (o & 1) || (o == 0);
7215         o_conv = ChannelInfo_clone(&o_conv);
7216         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7217         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
7218         return (long)ret_conv;
7219 }
7220
7221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7222         LDKDecodeError e_conv;
7223         e_conv.inner = (void*)(e & (~1));
7224         e_conv.is_owned = (e & 1) || (e == 0);
7225         e_conv = DecodeError_clone(&e_conv);
7226         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7227         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
7228         return (long)ret_conv;
7229 }
7230
7231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7232         if ((_res & 1) != 0) return;
7233         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7234         FREE((void*)_res);
7235         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
7236 }
7237
7238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7239         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
7240         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7241         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
7242         return (long)ret_conv;
7243 }
7244
7245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7246         LDKRoutingFees o_conv;
7247         o_conv.inner = (void*)(o & (~1));
7248         o_conv.is_owned = (o & 1) || (o == 0);
7249         o_conv = RoutingFees_clone(&o_conv);
7250         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7251         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
7252         return (long)ret_conv;
7253 }
7254
7255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7256         LDKDecodeError e_conv;
7257         e_conv.inner = (void*)(e & (~1));
7258         e_conv.is_owned = (e & 1) || (e == 0);
7259         e_conv = DecodeError_clone(&e_conv);
7260         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7261         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
7262         return (long)ret_conv;
7263 }
7264
7265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7266         if ((_res & 1) != 0) return;
7267         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7268         FREE((void*)_res);
7269         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
7270 }
7271
7272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7273         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
7274         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7275         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
7276         return (long)ret_conv;
7277 }
7278
7279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7280         LDKCVec_NetAddressZ _res_constr;
7281         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7282         if (_res_constr.datalen > 0)
7283                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
7284         else
7285                 _res_constr.data = NULL;
7286         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7287         for (size_t m = 0; m < _res_constr.datalen; m++) {
7288                 int64_t _res_conv_12 = _res_vals[m];
7289                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
7290                 FREE((void*)_res_conv_12);
7291                 _res_constr.data[m] = _res_conv_12_conv;
7292         }
7293         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7294         CVec_NetAddressZ_free(_res_constr);
7295 }
7296
7297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7298         LDKNodeAnnouncementInfo o_conv;
7299         o_conv.inner = (void*)(o & (~1));
7300         o_conv.is_owned = (o & 1) || (o == 0);
7301         o_conv = NodeAnnouncementInfo_clone(&o_conv);
7302         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7303         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
7304         return (long)ret_conv;
7305 }
7306
7307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7308         LDKDecodeError e_conv;
7309         e_conv.inner = (void*)(e & (~1));
7310         e_conv.is_owned = (e & 1) || (e == 0);
7311         e_conv = DecodeError_clone(&e_conv);
7312         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7313         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
7314         return (long)ret_conv;
7315 }
7316
7317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7318         if ((_res & 1) != 0) return;
7319         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7320         FREE((void*)_res);
7321         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
7322 }
7323
7324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7325         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
7326         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7327         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
7328         return (long)ret_conv;
7329 }
7330
7331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7332         LDKCVec_u64Z _res_constr;
7333         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7334         if (_res_constr.datalen > 0)
7335                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
7336         else
7337                 _res_constr.data = NULL;
7338         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7339         for (size_t g = 0; g < _res_constr.datalen; g++) {
7340                 int64_t _res_conv_6 = _res_vals[g];
7341                 _res_constr.data[g] = _res_conv_6;
7342         }
7343         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7344         CVec_u64Z_free(_res_constr);
7345 }
7346
7347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7348         LDKNodeInfo o_conv;
7349         o_conv.inner = (void*)(o & (~1));
7350         o_conv.is_owned = (o & 1) || (o == 0);
7351         o_conv = NodeInfo_clone(&o_conv);
7352         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7353         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
7354         return (long)ret_conv;
7355 }
7356
7357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7358         LDKDecodeError e_conv;
7359         e_conv.inner = (void*)(e & (~1));
7360         e_conv.is_owned = (e & 1) || (e == 0);
7361         e_conv = DecodeError_clone(&e_conv);
7362         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7363         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
7364         return (long)ret_conv;
7365 }
7366
7367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7368         if ((_res & 1) != 0) return;
7369         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7370         FREE((void*)_res);
7371         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
7372 }
7373
7374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7375         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
7376         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7377         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
7378         return (long)ret_conv;
7379 }
7380
7381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7382         LDKNetworkGraph o_conv;
7383         o_conv.inner = (void*)(o & (~1));
7384         o_conv.is_owned = (o & 1) || (o == 0);
7385         o_conv = NetworkGraph_clone(&o_conv);
7386         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7387         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
7388         return (long)ret_conv;
7389 }
7390
7391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7392         LDKDecodeError e_conv;
7393         e_conv.inner = (void*)(e & (~1));
7394         e_conv.is_owned = (e & 1) || (e == 0);
7395         e_conv = DecodeError_clone(&e_conv);
7396         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7397         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
7398         return (long)ret_conv;
7399 }
7400
7401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7402         if ((_res & 1) != 0) return;
7403         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
7404         FREE((void*)_res);
7405         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
7406 }
7407
7408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7409         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
7410         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7411         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
7412         return (long)ret_conv;
7413 }
7414
7415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7416         LDKTransaction b_ref;
7417         b_ref.datalen = (*env)->GetArrayLength(env, b);
7418         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7419         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7420         b_ref.data_is_owned = true;
7421         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7422         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7423         return (long)ret_ref;
7424 }
7425
7426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7427         if ((_res & 1) != 0) return;
7428         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7429         FREE((void*)_res);
7430         C2Tuple_usizeTransactionZ_free(_res_conv);
7431 }
7432
7433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7434         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7435         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7436         if (_res_constr.datalen > 0)
7437                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7438         else
7439                 _res_constr.data = NULL;
7440         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7441         for (size_t y = 0; y < _res_constr.datalen; y++) {
7442                 int64_t _res_conv_24 = _res_vals[y];
7443                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
7444                 FREE((void*)_res_conv_24);
7445                 _res_constr.data[y] = _res_conv_24_conv;
7446         }
7447         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7448         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7449 }
7450
7451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
7452         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7453         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7454         return (long)ret_conv;
7455 }
7456
7457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
7458         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
7459         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7460         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7461         return (long)ret_conv;
7462 }
7463
7464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7465         if ((_res & 1) != 0) return;
7466         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7467         FREE((void*)_res);
7468         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7469 }
7470
7471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7472         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7473         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7474         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7475         return (long)ret_conv;
7476 }
7477
7478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7479         LDKCVec_MonitorEventZ _res_constr;
7480         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7481         if (_res_constr.datalen > 0)
7482                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7483         else
7484                 _res_constr.data = NULL;
7485         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7486         for (size_t o = 0; o < _res_constr.datalen; o++) {
7487                 int64_t _res_conv_14 = _res_vals[o];
7488                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7489                 FREE((void*)_res_conv_14);
7490                 _res_constr.data[o] = _res_conv_14_conv;
7491         }
7492         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7493         CVec_MonitorEventZ_free(_res_constr);
7494 }
7495
7496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7497         LDKCVec_EventZ _res_constr;
7498         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7499         if (_res_constr.datalen > 0)
7500                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
7501         else
7502                 _res_constr.data = NULL;
7503         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7504         for (size_t h = 0; h < _res_constr.datalen; h++) {
7505                 int64_t _res_conv_7 = _res_vals[h];
7506                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
7507                 FREE((void*)_res_conv_7);
7508                 _res_constr.data[h] = _res_conv_7_conv;
7509         }
7510         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7511         CVec_EventZ_free(_res_constr);
7512 }
7513
7514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7515         LDKOutPoint o_conv;
7516         o_conv.inner = (void*)(o & (~1));
7517         o_conv.is_owned = (o & 1) || (o == 0);
7518         o_conv = OutPoint_clone(&o_conv);
7519         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7520         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
7521         return (long)ret_conv;
7522 }
7523
7524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7525         LDKDecodeError e_conv;
7526         e_conv.inner = (void*)(e & (~1));
7527         e_conv.is_owned = (e & 1) || (e == 0);
7528         e_conv = DecodeError_clone(&e_conv);
7529         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7530         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
7531         return (long)ret_conv;
7532 }
7533
7534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7535         if ((_res & 1) != 0) return;
7536         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
7537         FREE((void*)_res);
7538         CResult_OutPointDecodeErrorZ_free(_res_conv);
7539 }
7540
7541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7542         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
7543         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
7544         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
7545         return (long)ret_conv;
7546 }
7547
7548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7549         LDKChannelMonitorUpdate o_conv;
7550         o_conv.inner = (void*)(o & (~1));
7551         o_conv.is_owned = (o & 1) || (o == 0);
7552         o_conv = ChannelMonitorUpdate_clone(&o_conv);
7553         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7554         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
7555         return (long)ret_conv;
7556 }
7557
7558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7559         LDKDecodeError e_conv;
7560         e_conv.inner = (void*)(e & (~1));
7561         e_conv.is_owned = (e & 1) || (e == 0);
7562         e_conv = DecodeError_clone(&e_conv);
7563         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7564         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
7565         return (long)ret_conv;
7566 }
7567
7568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7569         if ((_res & 1) != 0) return;
7570         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7571         FREE((void*)_res);
7572         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
7573 }
7574
7575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7576         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
7577         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7578         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
7579         return (long)ret_conv;
7580 }
7581
7582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7583         LDKHTLCUpdate o_conv;
7584         o_conv.inner = (void*)(o & (~1));
7585         o_conv.is_owned = (o & 1) || (o == 0);
7586         o_conv = HTLCUpdate_clone(&o_conv);
7587         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7588         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
7589         return (long)ret_conv;
7590 }
7591
7592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7593         LDKDecodeError e_conv;
7594         e_conv.inner = (void*)(e & (~1));
7595         e_conv.is_owned = (e & 1) || (e == 0);
7596         e_conv = DecodeError_clone(&e_conv);
7597         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7598         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
7599         return (long)ret_conv;
7600 }
7601
7602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7603         if ((_res & 1) != 0) return;
7604         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
7605         FREE((void*)_res);
7606         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
7607 }
7608
7609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7610         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
7611         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
7612         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
7613         return (long)ret_conv;
7614 }
7615
7616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
7617         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7618         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
7619         return (long)ret_conv;
7620 }
7621
7622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7623         LDKMonitorUpdateError e_conv;
7624         e_conv.inner = (void*)(e & (~1));
7625         e_conv.is_owned = (e & 1) || (e == 0);
7626         e_conv = MonitorUpdateError_clone(&e_conv);
7627         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7628         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
7629         return (long)ret_conv;
7630 }
7631
7632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7633         if ((_res & 1) != 0) return;
7634         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
7635         FREE((void*)_res);
7636         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
7637 }
7638
7639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7640         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
7641         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7642         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
7643         return (long)ret_conv;
7644 }
7645
7646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7647         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
7648         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7649         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
7650         return (long)ret_ref;
7651 }
7652
7653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
7654         LDKOutPoint a_conv;
7655         a_conv.inner = (void*)(a & (~1));
7656         a_conv.is_owned = (a & 1) || (a == 0);
7657         a_conv = OutPoint_clone(&a_conv);
7658         LDKCVec_u8Z b_ref;
7659         b_ref.datalen = (*env)->GetArrayLength(env, b);
7660         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
7661         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
7662         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7663         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
7664         return (long)ret_ref;
7665 }
7666
7667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7668         if ((_res & 1) != 0) return;
7669         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
7670         FREE((void*)_res);
7671         C2Tuple_OutPointScriptZ_free(_res_conv);
7672 }
7673
7674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
7675         LDKCVec_TransactionZ _res_constr;
7676         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7677         if (_res_constr.datalen > 0)
7678                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
7679         else
7680                 _res_constr.data = NULL;
7681         for (size_t i = 0; i < _res_constr.datalen; i++) {
7682                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
7683                 LDKTransaction _res_conv_8_ref;
7684                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
7685                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
7686                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
7687                 _res_conv_8_ref.data_is_owned = true;
7688                 _res_constr.data[i] = _res_conv_8_ref;
7689         }
7690         CVec_TransactionZ_free(_res_constr);
7691 }
7692
7693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7694         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
7695         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7696         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
7697         return (long)ret_ref;
7698 }
7699
7700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
7701         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
7702         FREE((void*)b);
7703         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7704         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
7705         return (long)ret_ref;
7706 }
7707
7708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7709         if ((_res & 1) != 0) return;
7710         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
7711         FREE((void*)_res);
7712         C2Tuple_u32TxOutZ_free(_res_conv);
7713 }
7714
7715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7716         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
7717         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7718         if (_res_constr.datalen > 0)
7719                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7720         else
7721                 _res_constr.data = NULL;
7722         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7723         for (size_t a = 0; a < _res_constr.datalen; a++) {
7724                 int64_t _res_conv_26 = _res_vals[a];
7725                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
7726                 FREE((void*)_res_conv_26);
7727                 _res_constr.data[a] = _res_conv_26_conv;
7728         }
7729         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7730         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
7731 }
7732
7733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
7734         LDKThirtyTwoBytes a_ref;
7735         CHECK((*env)->GetArrayLength(env, a) == 32);
7736         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7737         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
7738         b_constr.datalen = (*env)->GetArrayLength(env, b);
7739         if (b_constr.datalen > 0)
7740                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
7741         else
7742                 b_constr.data = NULL;
7743         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
7744         for (size_t a = 0; a < b_constr.datalen; a++) {
7745                 int64_t b_conv_26 = b_vals[a];
7746                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
7747                 FREE((void*)b_conv_26);
7748                 b_constr.data[a] = b_conv_26_conv;
7749         }
7750         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
7751         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
7752         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
7753         return (long)ret_ref;
7754 }
7755
7756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7757         if ((_res & 1) != 0) return;
7758         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
7759         FREE((void*)_res);
7760         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
7761 }
7762
7763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7764         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
7765         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7766         if (_res_constr.datalen > 0)
7767                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
7768         else
7769                 _res_constr.data = NULL;
7770         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7771         for (size_t u = 0; u < _res_constr.datalen; u++) {
7772                 int64_t _res_conv_46 = _res_vals[u];
7773                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
7774                 FREE((void*)_res_conv_46);
7775                 _res_constr.data[u] = _res_conv_46_conv;
7776         }
7777         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7778         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
7779 }
7780
7781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
7782         LDKThirtyTwoBytes a_ref;
7783         CHECK((*env)->GetArrayLength(env, a) == 32);
7784         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
7785         LDKChannelMonitor b_conv;
7786         b_conv.inner = (void*)(b & (~1));
7787         b_conv.is_owned = (b & 1) || (b == 0);
7788         b_conv = ChannelMonitor_clone(&b_conv);
7789         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7790         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7791         return (long)ret_ref;
7792 }
7793
7794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7795         if ((_res & 1) != 0) return;
7796         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7797         FREE((void*)_res);
7798         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7799 }
7800
7801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7802         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
7803         FREE((void*)o);
7804         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7805         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
7806         return (long)ret_conv;
7807 }
7808
7809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7810         LDKDecodeError e_conv;
7811         e_conv.inner = (void*)(e & (~1));
7812         e_conv.is_owned = (e & 1) || (e == 0);
7813         e_conv = DecodeError_clone(&e_conv);
7814         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7815         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
7816         return (long)ret_conv;
7817 }
7818
7819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7820         if ((_res & 1) != 0) return;
7821         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7822         FREE((void*)_res);
7823         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
7824 }
7825
7826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7827         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7828         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7829         if (_res_constr.datalen > 0)
7830                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7831         else
7832                 _res_constr.data = NULL;
7833         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7834         for (size_t b = 0; b < _res_constr.datalen; b++) {
7835                 int64_t _res_conv_27 = _res_vals[b];
7836                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7837                 FREE((void*)_res_conv_27);
7838                 _res_constr.data[b] = _res_conv_27_conv;
7839         }
7840         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7841         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7842 }
7843
7844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
7845         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7846         FREE((void*)o);
7847         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7848         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7849         return (long)ret_conv;
7850 }
7851
7852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
7853         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
7854         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7855         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7856         return (long)ret_conv;
7857 }
7858
7859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7860         if ((_res & 1) != 0) return;
7861         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7862         FREE((void*)_res);
7863         CResult_TxOutAccessErrorZ_free(_res_conv);
7864 }
7865
7866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7867         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7868         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7869         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7870         return (long)ret_conv;
7871 }
7872
7873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
7874         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7875         *ret_conv = CResult_NoneAPIErrorZ_ok();
7876         return (long)ret_conv;
7877 }
7878
7879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7880         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
7881         FREE((void*)e);
7882         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7883         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
7884         return (long)ret_conv;
7885 }
7886
7887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7888         if ((_res & 1) != 0) return;
7889         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
7890         FREE((void*)_res);
7891         CResult_NoneAPIErrorZ_free(_res_conv);
7892 }
7893
7894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7895         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
7896         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7897         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
7898         return (long)ret_conv;
7899 }
7900
7901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7902         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
7903         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7904         if (_res_constr.datalen > 0)
7905                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
7906         else
7907                 _res_constr.data = NULL;
7908         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7909         for (size_t w = 0; w < _res_constr.datalen; w++) {
7910                 int64_t _res_conv_22 = _res_vals[w];
7911                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
7912                 FREE((void*)_res_conv_22);
7913                 _res_constr.data[w] = _res_conv_22_conv;
7914         }
7915         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7916         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
7917 }
7918
7919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7920         LDKCVec_APIErrorZ _res_constr;
7921         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7922         if (_res_constr.datalen > 0)
7923                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
7924         else
7925                 _res_constr.data = NULL;
7926         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7927         for (size_t k = 0; k < _res_constr.datalen; k++) {
7928                 int64_t _res_conv_10 = _res_vals[k];
7929                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
7930                 FREE((void*)_res_conv_10);
7931                 _res_constr.data[k] = _res_conv_10_conv;
7932         }
7933         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7934         CVec_APIErrorZ_free(_res_constr);
7935 }
7936
7937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7938         LDKCVec_ChannelDetailsZ _res_constr;
7939         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7940         if (_res_constr.datalen > 0)
7941                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7942         else
7943                 _res_constr.data = NULL;
7944         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7945         for (size_t q = 0; q < _res_constr.datalen; q++) {
7946                 int64_t _res_conv_16 = _res_vals[q];
7947                 LDKChannelDetails _res_conv_16_conv;
7948                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7949                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7950                 _res_constr.data[q] = _res_conv_16_conv;
7951         }
7952         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
7953         CVec_ChannelDetailsZ_free(_res_constr);
7954 }
7955
7956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
7957         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7958         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
7959         return (long)ret_conv;
7960 }
7961
7962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
7963         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
7964         FREE((void*)e);
7965         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7966         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
7967         return (long)ret_conv;
7968 }
7969
7970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
7971         if ((_res & 1) != 0) return;
7972         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
7973         FREE((void*)_res);
7974         CResult_NonePaymentSendFailureZ_free(_res_conv);
7975 }
7976
7977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
7978         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
7979         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7980         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
7981         return (long)ret_conv;
7982 }
7983
7984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
7985         LDKCVec_ChannelMonitorZ _res_constr;
7986         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
7987         if (_res_constr.datalen > 0)
7988                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7989         else
7990                 _res_constr.data = NULL;
7991         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
7992         for (size_t q = 0; q < _res_constr.datalen; q++) {
7993                 int64_t _res_conv_16 = _res_vals[q];
7994                 LDKChannelMonitor _res_conv_16_conv;
7995                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7996                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7997                 _res_constr.data[q] = _res_conv_16_conv;
7998         }
7999         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8000         CVec_ChannelMonitorZ_free(_res_constr);
8001 }
8002
8003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
8004         LDKThirtyTwoBytes a_ref;
8005         CHECK((*env)->GetArrayLength(env, a) == 32);
8006         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
8007         LDKChannelManager b_conv;
8008         b_conv.inner = (void*)(b & (~1));
8009         b_conv.is_owned = (b & 1) || (b == 0);
8010         // Warning: we need a move here but no clone is available for LDKChannelManager
8011         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8012         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8013         return (long)ret_ref;
8014 }
8015
8016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8017         if ((_res & 1) != 0) return;
8018         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8019         FREE((void*)_res);
8020         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8021 }
8022
8023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8024         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8025         FREE((void*)o);
8026         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8027         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8028         return (long)ret_conv;
8029 }
8030
8031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8032         LDKDecodeError e_conv;
8033         e_conv.inner = (void*)(e & (~1));
8034         e_conv.is_owned = (e & 1) || (e == 0);
8035         e_conv = DecodeError_clone(&e_conv);
8036         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8037         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8038         return (long)ret_conv;
8039 }
8040
8041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8042         if ((_res & 1) != 0) return;
8043         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8044         FREE((void*)_res);
8045         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
8046 }
8047
8048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8049         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
8050         FREE((void*)o);
8051         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8052         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
8053         return (long)ret_conv;
8054 }
8055
8056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8057         LDKDecodeError e_conv;
8058         e_conv.inner = (void*)(e & (~1));
8059         e_conv.is_owned = (e & 1) || (e == 0);
8060         e_conv = DecodeError_clone(&e_conv);
8061         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8062         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
8063         return (long)ret_conv;
8064 }
8065
8066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8067         if ((_res & 1) != 0) return;
8068         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8069         FREE((void*)_res);
8070         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
8071 }
8072
8073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8074         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
8075         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8076         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
8077         return (long)ret_conv;
8078 }
8079
8080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8081         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
8082         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8083         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
8084         return (long)ret_ref;
8085 }
8086
8087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
8088         LDKSignature a_ref;
8089         CHECK((*env)->GetArrayLength(env, a) == 64);
8090         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
8091         LDKCVec_SignatureZ b_constr;
8092         b_constr.datalen = (*env)->GetArrayLength(env, b);
8093         if (b_constr.datalen > 0)
8094                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8095         else
8096                 b_constr.data = NULL;
8097         for (size_t i = 0; i < b_constr.datalen; i++) {
8098                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
8099                 LDKSignature b_conv_8_ref;
8100                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
8101                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
8102                 b_constr.data[i] = b_conv_8_ref;
8103         }
8104         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8105         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
8106         return (long)ret_ref;
8107 }
8108
8109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8110         if ((_res & 1) != 0) return;
8111         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
8112         FREE((void*)_res);
8113         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
8114 }
8115
8116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8117         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
8118         FREE((void*)o);
8119         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8120         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
8121         return (long)ret_conv;
8122 }
8123
8124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
8125         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8126         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
8127         return (long)ret_conv;
8128 }
8129
8130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8131         if ((_res & 1) != 0) return;
8132         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
8133         FREE((void*)_res);
8134         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
8135 }
8136
8137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8138         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
8139         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8140         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
8141         return (long)ret_conv;
8142 }
8143
8144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8145         LDKSignature o_ref;
8146         CHECK((*env)->GetArrayLength(env, o) == 64);
8147         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
8148         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8149         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
8150         return (long)ret_conv;
8151 }
8152
8153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
8154         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8155         *ret_conv = CResult_SignatureNoneZ_err();
8156         return (long)ret_conv;
8157 }
8158
8159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8160         if ((_res & 1) != 0) return;
8161         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
8162         FREE((void*)_res);
8163         CResult_SignatureNoneZ_free(_res_conv);
8164 }
8165
8166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8167         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
8168         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8169         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
8170         return (long)ret_conv;
8171 }
8172
8173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8174         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
8175         if (o_conv.free == LDKSign_JCalls_free) {
8176                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8177                 LDKSign_JCalls_clone(o_conv.this_arg);
8178         }
8179         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8180         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
8181         return (long)ret_conv;
8182 }
8183
8184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8185         LDKDecodeError e_conv;
8186         e_conv.inner = (void*)(e & (~1));
8187         e_conv.is_owned = (e & 1) || (e == 0);
8188         e_conv = DecodeError_clone(&e_conv);
8189         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8190         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
8191         return (long)ret_conv;
8192 }
8193
8194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8195         if ((_res & 1) != 0) return;
8196         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
8197         FREE((void*)_res);
8198         CResult_SignDecodeErrorZ_free(_res_conv);
8199 }
8200
8201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8202         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
8203         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8204         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
8205         return (long)ret_conv;
8206 }
8207
8208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8209         LDKCVec_CVec_u8ZZ _res_constr;
8210         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8211         if (_res_constr.datalen > 0)
8212                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8213         else
8214                 _res_constr.data = NULL;
8215         for (size_t i = 0; i < _res_constr.datalen; i++) {
8216                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8217                 LDKCVec_u8Z _res_conv_8_ref;
8218                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
8219                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
8220                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
8221                 _res_constr.data[i] = _res_conv_8_ref;
8222         }
8223         CVec_CVec_u8ZZ_free(_res_constr);
8224 }
8225
8226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
8227         LDKCVec_CVec_u8ZZ o_constr;
8228         o_constr.datalen = (*env)->GetArrayLength(env, o);
8229         if (o_constr.datalen > 0)
8230                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8231         else
8232                 o_constr.data = NULL;
8233         for (size_t i = 0; i < o_constr.datalen; i++) {
8234                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
8235                 LDKCVec_u8Z o_conv_8_ref;
8236                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
8237                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
8238                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
8239                 o_constr.data[i] = o_conv_8_ref;
8240         }
8241         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8242         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
8243         return (long)ret_conv;
8244 }
8245
8246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
8247         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8248         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
8249         return (long)ret_conv;
8250 }
8251
8252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8253         if ((_res & 1) != 0) return;
8254         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
8255         FREE((void*)_res);
8256         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
8257 }
8258
8259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8260         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
8261         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8262         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
8263         return (long)ret_conv;
8264 }
8265
8266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8267         LDKInMemorySigner o_conv;
8268         o_conv.inner = (void*)(o & (~1));
8269         o_conv.is_owned = (o & 1) || (o == 0);
8270         o_conv = InMemorySigner_clone(&o_conv);
8271         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8272         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
8273         return (long)ret_conv;
8274 }
8275
8276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8277         LDKDecodeError e_conv;
8278         e_conv.inner = (void*)(e & (~1));
8279         e_conv.is_owned = (e & 1) || (e == 0);
8280         e_conv = DecodeError_clone(&e_conv);
8281         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8282         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
8283         return (long)ret_conv;
8284 }
8285
8286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8287         if ((_res & 1) != 0) return;
8288         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
8289         FREE((void*)_res);
8290         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
8291 }
8292
8293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8294         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
8295         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8296         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
8297         return (long)ret_conv;
8298 }
8299
8300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8301         LDKCVec_TxOutZ _res_constr;
8302         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8303         if (_res_constr.datalen > 0)
8304                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
8305         else
8306                 _res_constr.data = NULL;
8307         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8308         for (size_t h = 0; h < _res_constr.datalen; h++) {
8309                 int64_t _res_conv_7 = _res_vals[h];
8310                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
8311                 FREE((void*)_res_conv_7);
8312                 _res_constr.data[h] = _res_conv_7_conv;
8313         }
8314         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8315         CVec_TxOutZ_free(_res_constr);
8316 }
8317
8318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8319         LDKTransaction o_ref;
8320         o_ref.datalen = (*env)->GetArrayLength(env, o);
8321         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
8322         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
8323         o_ref.data_is_owned = true;
8324         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8325         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
8326         return (long)ret_conv;
8327 }
8328
8329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
8330         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8331         *ret_conv = CResult_TransactionNoneZ_err();
8332         return (long)ret_conv;
8333 }
8334
8335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8336         if ((_res & 1) != 0) return;
8337         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
8338         FREE((void*)_res);
8339         CResult_TransactionNoneZ_free(_res_conv);
8340 }
8341
8342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8343         LDKCVec_RouteHopZ _res_constr;
8344         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8345         if (_res_constr.datalen > 0)
8346                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8347         else
8348                 _res_constr.data = NULL;
8349         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8350         for (size_t k = 0; k < _res_constr.datalen; k++) {
8351                 int64_t _res_conv_10 = _res_vals[k];
8352                 LDKRouteHop _res_conv_10_conv;
8353                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
8354                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
8355                 _res_constr.data[k] = _res_conv_10_conv;
8356         }
8357         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8358         CVec_RouteHopZ_free(_res_constr);
8359 }
8360
8361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8362         LDKCVec_CVec_RouteHopZZ _res_constr;
8363         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8364         if (_res_constr.datalen > 0)
8365                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
8366         else
8367                 _res_constr.data = NULL;
8368         for (size_t m = 0; m < _res_constr.datalen; m++) {
8369                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
8370                 LDKCVec_RouteHopZ _res_conv_12_constr;
8371                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
8372                 if (_res_conv_12_constr.datalen > 0)
8373                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8374                 else
8375                         _res_conv_12_constr.data = NULL;
8376                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
8377                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
8378                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
8379                         LDKRouteHop _res_conv_12_conv_10_conv;
8380                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
8381                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
8382                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
8383                 }
8384                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
8385                 _res_constr.data[m] = _res_conv_12_constr;
8386         }
8387         CVec_CVec_RouteHopZZ_free(_res_constr);
8388 }
8389
8390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8391         LDKRoute o_conv;
8392         o_conv.inner = (void*)(o & (~1));
8393         o_conv.is_owned = (o & 1) || (o == 0);
8394         o_conv = Route_clone(&o_conv);
8395         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8396         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
8397         return (long)ret_conv;
8398 }
8399
8400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8401         LDKDecodeError e_conv;
8402         e_conv.inner = (void*)(e & (~1));
8403         e_conv.is_owned = (e & 1) || (e == 0);
8404         e_conv = DecodeError_clone(&e_conv);
8405         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8406         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
8407         return (long)ret_conv;
8408 }
8409
8410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8411         if ((_res & 1) != 0) return;
8412         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
8413         FREE((void*)_res);
8414         CResult_RouteDecodeErrorZ_free(_res_conv);
8415 }
8416
8417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8418         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
8419         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8420         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
8421         return (long)ret_conv;
8422 }
8423
8424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8425         LDKCVec_RouteHintZ _res_constr;
8426         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8427         if (_res_constr.datalen > 0)
8428                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
8429         else
8430                 _res_constr.data = NULL;
8431         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8432         for (size_t l = 0; l < _res_constr.datalen; l++) {
8433                 int64_t _res_conv_11 = _res_vals[l];
8434                 LDKRouteHint _res_conv_11_conv;
8435                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
8436                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
8437                 _res_constr.data[l] = _res_conv_11_conv;
8438         }
8439         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8440         CVec_RouteHintZ_free(_res_constr);
8441 }
8442
8443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8444         LDKRoute o_conv;
8445         o_conv.inner = (void*)(o & (~1));
8446         o_conv.is_owned = (o & 1) || (o == 0);
8447         o_conv = Route_clone(&o_conv);
8448         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8449         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
8450         return (long)ret_conv;
8451 }
8452
8453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8454         LDKLightningError e_conv;
8455         e_conv.inner = (void*)(e & (~1));
8456         e_conv.is_owned = (e & 1) || (e == 0);
8457         e_conv = LightningError_clone(&e_conv);
8458         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8459         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
8460         return (long)ret_conv;
8461 }
8462
8463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8464         if ((_res & 1) != 0) return;
8465         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
8466         FREE((void*)_res);
8467         CResult_RouteLightningErrorZ_free(_res_conv);
8468 }
8469
8470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8471         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
8472         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8473         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
8474         return (long)ret_conv;
8475 }
8476
8477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
8478         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
8479         FREE((void*)o);
8480         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8481         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
8482         return (long)ret_conv;
8483 }
8484
8485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
8486         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8487         *ret_conv = CResult_NetAddressu8Z_err(e);
8488         return (long)ret_conv;
8489 }
8490
8491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8492         if ((_res & 1) != 0) return;
8493         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
8494         FREE((void*)_res);
8495         CResult_NetAddressu8Z_free(_res_conv);
8496 }
8497
8498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8499         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
8500         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
8501         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
8502         return (long)ret_conv;
8503 }
8504
8505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8506         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
8507         FREE((void*)o);
8508         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8509         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
8510         return (long)ret_conv;
8511 }
8512
8513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8514         LDKDecodeError e_conv;
8515         e_conv.inner = (void*)(e & (~1));
8516         e_conv.is_owned = (e & 1) || (e == 0);
8517         e_conv = DecodeError_clone(&e_conv);
8518         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8519         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
8520         return (long)ret_conv;
8521 }
8522
8523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8524         if ((_res & 1) != 0) return;
8525         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8526         FREE((void*)_res);
8527         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
8528 }
8529
8530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8531         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
8532         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
8533         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
8534         return (long)ret_conv;
8535 }
8536
8537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8538         LDKCVec_UpdateAddHTLCZ _res_constr;
8539         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8540         if (_res_constr.datalen > 0)
8541                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
8542         else
8543                 _res_constr.data = NULL;
8544         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8545         for (size_t p = 0; p < _res_constr.datalen; p++) {
8546                 int64_t _res_conv_15 = _res_vals[p];
8547                 LDKUpdateAddHTLC _res_conv_15_conv;
8548                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
8549                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
8550                 _res_constr.data[p] = _res_conv_15_conv;
8551         }
8552         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8553         CVec_UpdateAddHTLCZ_free(_res_constr);
8554 }
8555
8556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8557         LDKCVec_UpdateFulfillHTLCZ _res_constr;
8558         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8559         if (_res_constr.datalen > 0)
8560                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
8561         else
8562                 _res_constr.data = NULL;
8563         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8564         for (size_t t = 0; t < _res_constr.datalen; t++) {
8565                 int64_t _res_conv_19 = _res_vals[t];
8566                 LDKUpdateFulfillHTLC _res_conv_19_conv;
8567                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
8568                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
8569                 _res_constr.data[t] = _res_conv_19_conv;
8570         }
8571         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8572         CVec_UpdateFulfillHTLCZ_free(_res_constr);
8573 }
8574
8575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8576         LDKCVec_UpdateFailHTLCZ _res_constr;
8577         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8578         if (_res_constr.datalen > 0)
8579                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
8580         else
8581                 _res_constr.data = NULL;
8582         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8583         for (size_t q = 0; q < _res_constr.datalen; q++) {
8584                 int64_t _res_conv_16 = _res_vals[q];
8585                 LDKUpdateFailHTLC _res_conv_16_conv;
8586                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8587                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8588                 _res_constr.data[q] = _res_conv_16_conv;
8589         }
8590         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8591         CVec_UpdateFailHTLCZ_free(_res_constr);
8592 }
8593
8594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
8595         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
8596         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8597         if (_res_constr.datalen > 0)
8598                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
8599         else
8600                 _res_constr.data = NULL;
8601         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
8602         for (size_t z = 0; z < _res_constr.datalen; z++) {
8603                 int64_t _res_conv_25 = _res_vals[z];
8604                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
8605                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
8606                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
8607                 _res_constr.data[z] = _res_conv_25_conv;
8608         }
8609         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
8610         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
8611 }
8612
8613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8614         LDKAcceptChannel o_conv;
8615         o_conv.inner = (void*)(o & (~1));
8616         o_conv.is_owned = (o & 1) || (o == 0);
8617         o_conv = AcceptChannel_clone(&o_conv);
8618         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8619         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
8620         return (long)ret_conv;
8621 }
8622
8623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8624         LDKDecodeError e_conv;
8625         e_conv.inner = (void*)(e & (~1));
8626         e_conv.is_owned = (e & 1) || (e == 0);
8627         e_conv = DecodeError_clone(&e_conv);
8628         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8629         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
8630         return (long)ret_conv;
8631 }
8632
8633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8634         if ((_res & 1) != 0) return;
8635         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
8636         FREE((void*)_res);
8637         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
8638 }
8639
8640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8641         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
8642         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
8643         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
8644         return (long)ret_conv;
8645 }
8646
8647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8648         LDKAnnouncementSignatures o_conv;
8649         o_conv.inner = (void*)(o & (~1));
8650         o_conv.is_owned = (o & 1) || (o == 0);
8651         o_conv = AnnouncementSignatures_clone(&o_conv);
8652         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8653         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
8654         return (long)ret_conv;
8655 }
8656
8657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8658         LDKDecodeError e_conv;
8659         e_conv.inner = (void*)(e & (~1));
8660         e_conv.is_owned = (e & 1) || (e == 0);
8661         e_conv = DecodeError_clone(&e_conv);
8662         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8663         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
8664         return (long)ret_conv;
8665 }
8666
8667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8668         if ((_res & 1) != 0) return;
8669         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8670         FREE((void*)_res);
8671         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
8672 }
8673
8674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8675         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
8676         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
8677         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
8678         return (long)ret_conv;
8679 }
8680
8681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8682         LDKChannelReestablish o_conv;
8683         o_conv.inner = (void*)(o & (~1));
8684         o_conv.is_owned = (o & 1) || (o == 0);
8685         o_conv = ChannelReestablish_clone(&o_conv);
8686         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8687         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
8688         return (long)ret_conv;
8689 }
8690
8691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8692         LDKDecodeError e_conv;
8693         e_conv.inner = (void*)(e & (~1));
8694         e_conv.is_owned = (e & 1) || (e == 0);
8695         e_conv = DecodeError_clone(&e_conv);
8696         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8697         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
8698         return (long)ret_conv;
8699 }
8700
8701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8702         if ((_res & 1) != 0) return;
8703         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
8704         FREE((void*)_res);
8705         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
8706 }
8707
8708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8709         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
8710         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
8711         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
8712         return (long)ret_conv;
8713 }
8714
8715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8716         LDKClosingSigned o_conv;
8717         o_conv.inner = (void*)(o & (~1));
8718         o_conv.is_owned = (o & 1) || (o == 0);
8719         o_conv = ClosingSigned_clone(&o_conv);
8720         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8721         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
8722         return (long)ret_conv;
8723 }
8724
8725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8726         LDKDecodeError e_conv;
8727         e_conv.inner = (void*)(e & (~1));
8728         e_conv.is_owned = (e & 1) || (e == 0);
8729         e_conv = DecodeError_clone(&e_conv);
8730         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8731         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
8732         return (long)ret_conv;
8733 }
8734
8735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8736         if ((_res & 1) != 0) return;
8737         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8738         FREE((void*)_res);
8739         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
8740 }
8741
8742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8743         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
8744         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
8745         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
8746         return (long)ret_conv;
8747 }
8748
8749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8750         LDKCommitmentSigned o_conv;
8751         o_conv.inner = (void*)(o & (~1));
8752         o_conv.is_owned = (o & 1) || (o == 0);
8753         o_conv = CommitmentSigned_clone(&o_conv);
8754         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8755         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
8756         return (long)ret_conv;
8757 }
8758
8759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8760         LDKDecodeError e_conv;
8761         e_conv.inner = (void*)(e & (~1));
8762         e_conv.is_owned = (e & 1) || (e == 0);
8763         e_conv = DecodeError_clone(&e_conv);
8764         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8765         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
8766         return (long)ret_conv;
8767 }
8768
8769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8770         if ((_res & 1) != 0) return;
8771         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8772         FREE((void*)_res);
8773         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
8774 }
8775
8776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8777         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
8778         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8779         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
8780         return (long)ret_conv;
8781 }
8782
8783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8784         LDKFundingCreated o_conv;
8785         o_conv.inner = (void*)(o & (~1));
8786         o_conv.is_owned = (o & 1) || (o == 0);
8787         o_conv = FundingCreated_clone(&o_conv);
8788         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8789         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
8790         return (long)ret_conv;
8791 }
8792
8793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8794         LDKDecodeError e_conv;
8795         e_conv.inner = (void*)(e & (~1));
8796         e_conv.is_owned = (e & 1) || (e == 0);
8797         e_conv = DecodeError_clone(&e_conv);
8798         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8799         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
8800         return (long)ret_conv;
8801 }
8802
8803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8804         if ((_res & 1) != 0) return;
8805         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8806         FREE((void*)_res);
8807         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
8808 }
8809
8810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8811         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
8812         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8813         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
8814         return (long)ret_conv;
8815 }
8816
8817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8818         LDKFundingSigned o_conv;
8819         o_conv.inner = (void*)(o & (~1));
8820         o_conv.is_owned = (o & 1) || (o == 0);
8821         o_conv = FundingSigned_clone(&o_conv);
8822         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8823         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
8824         return (long)ret_conv;
8825 }
8826
8827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8828         LDKDecodeError e_conv;
8829         e_conv.inner = (void*)(e & (~1));
8830         e_conv.is_owned = (e & 1) || (e == 0);
8831         e_conv = DecodeError_clone(&e_conv);
8832         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8833         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
8834         return (long)ret_conv;
8835 }
8836
8837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8838         if ((_res & 1) != 0) return;
8839         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8840         FREE((void*)_res);
8841         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
8842 }
8843
8844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8845         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
8846         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8847         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
8848         return (long)ret_conv;
8849 }
8850
8851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8852         LDKFundingLocked o_conv;
8853         o_conv.inner = (void*)(o & (~1));
8854         o_conv.is_owned = (o & 1) || (o == 0);
8855         o_conv = FundingLocked_clone(&o_conv);
8856         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8857         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
8858         return (long)ret_conv;
8859 }
8860
8861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8862         LDKDecodeError e_conv;
8863         e_conv.inner = (void*)(e & (~1));
8864         e_conv.is_owned = (e & 1) || (e == 0);
8865         e_conv = DecodeError_clone(&e_conv);
8866         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8867         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
8868         return (long)ret_conv;
8869 }
8870
8871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8872         if ((_res & 1) != 0) return;
8873         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8874         FREE((void*)_res);
8875         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
8876 }
8877
8878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8879         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
8880         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8881         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
8882         return (long)ret_conv;
8883 }
8884
8885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8886         LDKInit o_conv;
8887         o_conv.inner = (void*)(o & (~1));
8888         o_conv.is_owned = (o & 1) || (o == 0);
8889         o_conv = Init_clone(&o_conv);
8890         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8891         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
8892         return (long)ret_conv;
8893 }
8894
8895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8896         LDKDecodeError e_conv;
8897         e_conv.inner = (void*)(e & (~1));
8898         e_conv.is_owned = (e & 1) || (e == 0);
8899         e_conv = DecodeError_clone(&e_conv);
8900         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8901         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
8902         return (long)ret_conv;
8903 }
8904
8905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8906         if ((_res & 1) != 0) return;
8907         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
8908         FREE((void*)_res);
8909         CResult_InitDecodeErrorZ_free(_res_conv);
8910 }
8911
8912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8913         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
8914         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8915         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
8916         return (long)ret_conv;
8917 }
8918
8919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8920         LDKOpenChannel o_conv;
8921         o_conv.inner = (void*)(o & (~1));
8922         o_conv.is_owned = (o & 1) || (o == 0);
8923         o_conv = OpenChannel_clone(&o_conv);
8924         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8925         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
8926         return (long)ret_conv;
8927 }
8928
8929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8930         LDKDecodeError e_conv;
8931         e_conv.inner = (void*)(e & (~1));
8932         e_conv.is_owned = (e & 1) || (e == 0);
8933         e_conv = DecodeError_clone(&e_conv);
8934         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8935         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
8936         return (long)ret_conv;
8937 }
8938
8939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8940         if ((_res & 1) != 0) return;
8941         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
8942         FREE((void*)_res);
8943         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
8944 }
8945
8946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8947         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
8948         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8949         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
8950         return (long)ret_conv;
8951 }
8952
8953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8954         LDKRevokeAndACK o_conv;
8955         o_conv.inner = (void*)(o & (~1));
8956         o_conv.is_owned = (o & 1) || (o == 0);
8957         o_conv = RevokeAndACK_clone(&o_conv);
8958         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8959         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
8960         return (long)ret_conv;
8961 }
8962
8963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8964         LDKDecodeError e_conv;
8965         e_conv.inner = (void*)(e & (~1));
8966         e_conv.is_owned = (e & 1) || (e == 0);
8967         e_conv = DecodeError_clone(&e_conv);
8968         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8969         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
8970         return (long)ret_conv;
8971 }
8972
8973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8974         if ((_res & 1) != 0) return;
8975         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
8976         FREE((void*)_res);
8977         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
8978 }
8979
8980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8981         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
8982         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8983         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
8984         return (long)ret_conv;
8985 }
8986
8987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8988         LDKShutdown o_conv;
8989         o_conv.inner = (void*)(o & (~1));
8990         o_conv.is_owned = (o & 1) || (o == 0);
8991         o_conv = Shutdown_clone(&o_conv);
8992         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8993         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
8994         return (long)ret_conv;
8995 }
8996
8997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8998         LDKDecodeError e_conv;
8999         e_conv.inner = (void*)(e & (~1));
9000         e_conv.is_owned = (e & 1) || (e == 0);
9001         e_conv = DecodeError_clone(&e_conv);
9002         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9003         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
9004         return (long)ret_conv;
9005 }
9006
9007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9008         if ((_res & 1) != 0) return;
9009         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
9010         FREE((void*)_res);
9011         CResult_ShutdownDecodeErrorZ_free(_res_conv);
9012 }
9013
9014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9015         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
9016         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9017         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
9018         return (long)ret_conv;
9019 }
9020
9021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9022         LDKUpdateFailHTLC o_conv;
9023         o_conv.inner = (void*)(o & (~1));
9024         o_conv.is_owned = (o & 1) || (o == 0);
9025         o_conv = UpdateFailHTLC_clone(&o_conv);
9026         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9027         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
9028         return (long)ret_conv;
9029 }
9030
9031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9032         LDKDecodeError e_conv;
9033         e_conv.inner = (void*)(e & (~1));
9034         e_conv.is_owned = (e & 1) || (e == 0);
9035         e_conv = DecodeError_clone(&e_conv);
9036         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9037         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
9038         return (long)ret_conv;
9039 }
9040
9041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9042         if ((_res & 1) != 0) return;
9043         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9044         FREE((void*)_res);
9045         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
9046 }
9047
9048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9049         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
9050         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9051         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
9052         return (long)ret_conv;
9053 }
9054
9055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9056         LDKUpdateFailMalformedHTLC o_conv;
9057         o_conv.inner = (void*)(o & (~1));
9058         o_conv.is_owned = (o & 1) || (o == 0);
9059         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
9060         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9061         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
9062         return (long)ret_conv;
9063 }
9064
9065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9066         LDKDecodeError e_conv;
9067         e_conv.inner = (void*)(e & (~1));
9068         e_conv.is_owned = (e & 1) || (e == 0);
9069         e_conv = DecodeError_clone(&e_conv);
9070         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9071         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
9072         return (long)ret_conv;
9073 }
9074
9075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9076         if ((_res & 1) != 0) return;
9077         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9078         FREE((void*)_res);
9079         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
9080 }
9081
9082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9083         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
9084         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
9085         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
9086         return (long)ret_conv;
9087 }
9088
9089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9090         LDKUpdateFee o_conv;
9091         o_conv.inner = (void*)(o & (~1));
9092         o_conv.is_owned = (o & 1) || (o == 0);
9093         o_conv = UpdateFee_clone(&o_conv);
9094         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9095         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
9096         return (long)ret_conv;
9097 }
9098
9099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9100         LDKDecodeError e_conv;
9101         e_conv.inner = (void*)(e & (~1));
9102         e_conv.is_owned = (e & 1) || (e == 0);
9103         e_conv = DecodeError_clone(&e_conv);
9104         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9105         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
9106         return (long)ret_conv;
9107 }
9108
9109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9110         if ((_res & 1) != 0) return;
9111         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9112         FREE((void*)_res);
9113         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
9114 }
9115
9116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9117         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
9118         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
9119         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
9120         return (long)ret_conv;
9121 }
9122
9123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9124         LDKUpdateFulfillHTLC o_conv;
9125         o_conv.inner = (void*)(o & (~1));
9126         o_conv.is_owned = (o & 1) || (o == 0);
9127         o_conv = UpdateFulfillHTLC_clone(&o_conv);
9128         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9129         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
9130         return (long)ret_conv;
9131 }
9132
9133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9134         LDKDecodeError e_conv;
9135         e_conv.inner = (void*)(e & (~1));
9136         e_conv.is_owned = (e & 1) || (e == 0);
9137         e_conv = DecodeError_clone(&e_conv);
9138         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9139         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
9140         return (long)ret_conv;
9141 }
9142
9143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9144         if ((_res & 1) != 0) return;
9145         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9146         FREE((void*)_res);
9147         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
9148 }
9149
9150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9151         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
9152         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
9153         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
9154         return (long)ret_conv;
9155 }
9156
9157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9158         LDKUpdateAddHTLC o_conv;
9159         o_conv.inner = (void*)(o & (~1));
9160         o_conv.is_owned = (o & 1) || (o == 0);
9161         o_conv = UpdateAddHTLC_clone(&o_conv);
9162         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9163         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
9164         return (long)ret_conv;
9165 }
9166
9167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9168         LDKDecodeError e_conv;
9169         e_conv.inner = (void*)(e & (~1));
9170         e_conv.is_owned = (e & 1) || (e == 0);
9171         e_conv = DecodeError_clone(&e_conv);
9172         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9173         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
9174         return (long)ret_conv;
9175 }
9176
9177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9178         if ((_res & 1) != 0) return;
9179         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
9180         FREE((void*)_res);
9181         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
9182 }
9183
9184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9185         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
9186         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
9187         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
9188         return (long)ret_conv;
9189 }
9190
9191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9192         LDKPing o_conv;
9193         o_conv.inner = (void*)(o & (~1));
9194         o_conv.is_owned = (o & 1) || (o == 0);
9195         o_conv = Ping_clone(&o_conv);
9196         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9197         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
9198         return (long)ret_conv;
9199 }
9200
9201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9202         LDKDecodeError e_conv;
9203         e_conv.inner = (void*)(e & (~1));
9204         e_conv.is_owned = (e & 1) || (e == 0);
9205         e_conv = DecodeError_clone(&e_conv);
9206         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9207         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
9208         return (long)ret_conv;
9209 }
9210
9211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9212         if ((_res & 1) != 0) return;
9213         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
9214         FREE((void*)_res);
9215         CResult_PingDecodeErrorZ_free(_res_conv);
9216 }
9217
9218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9219         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
9220         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
9221         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
9222         return (long)ret_conv;
9223 }
9224
9225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9226         LDKPong o_conv;
9227         o_conv.inner = (void*)(o & (~1));
9228         o_conv.is_owned = (o & 1) || (o == 0);
9229         o_conv = Pong_clone(&o_conv);
9230         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9231         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
9232         return (long)ret_conv;
9233 }
9234
9235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9236         LDKDecodeError e_conv;
9237         e_conv.inner = (void*)(e & (~1));
9238         e_conv.is_owned = (e & 1) || (e == 0);
9239         e_conv = DecodeError_clone(&e_conv);
9240         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9241         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
9242         return (long)ret_conv;
9243 }
9244
9245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9246         if ((_res & 1) != 0) return;
9247         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
9248         FREE((void*)_res);
9249         CResult_PongDecodeErrorZ_free(_res_conv);
9250 }
9251
9252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9253         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
9254         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
9255         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
9256         return (long)ret_conv;
9257 }
9258
9259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9260         LDKUnsignedChannelAnnouncement o_conv;
9261         o_conv.inner = (void*)(o & (~1));
9262         o_conv.is_owned = (o & 1) || (o == 0);
9263         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
9264         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9265         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
9266         return (long)ret_conv;
9267 }
9268
9269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9270         LDKDecodeError e_conv;
9271         e_conv.inner = (void*)(e & (~1));
9272         e_conv.is_owned = (e & 1) || (e == 0);
9273         e_conv = DecodeError_clone(&e_conv);
9274         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9275         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
9276         return (long)ret_conv;
9277 }
9278
9279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9280         if ((_res & 1) != 0) return;
9281         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9282         FREE((void*)_res);
9283         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
9284 }
9285
9286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9287         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9288         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
9289         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9290         return (long)ret_conv;
9291 }
9292
9293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9294         LDKChannelAnnouncement o_conv;
9295         o_conv.inner = (void*)(o & (~1));
9296         o_conv.is_owned = (o & 1) || (o == 0);
9297         o_conv = ChannelAnnouncement_clone(&o_conv);
9298         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9299         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
9300         return (long)ret_conv;
9301 }
9302
9303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9304         LDKDecodeError e_conv;
9305         e_conv.inner = (void*)(e & (~1));
9306         e_conv.is_owned = (e & 1) || (e == 0);
9307         e_conv = DecodeError_clone(&e_conv);
9308         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9309         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
9310         return (long)ret_conv;
9311 }
9312
9313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9314         if ((_res & 1) != 0) return;
9315         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9316         FREE((void*)_res);
9317         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
9318 }
9319
9320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9321         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
9322         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
9323         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
9324         return (long)ret_conv;
9325 }
9326
9327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9328         LDKUnsignedChannelUpdate o_conv;
9329         o_conv.inner = (void*)(o & (~1));
9330         o_conv.is_owned = (o & 1) || (o == 0);
9331         o_conv = UnsignedChannelUpdate_clone(&o_conv);
9332         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9333         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
9334         return (long)ret_conv;
9335 }
9336
9337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9338         LDKDecodeError e_conv;
9339         e_conv.inner = (void*)(e & (~1));
9340         e_conv.is_owned = (e & 1) || (e == 0);
9341         e_conv = DecodeError_clone(&e_conv);
9342         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9343         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
9344         return (long)ret_conv;
9345 }
9346
9347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9348         if ((_res & 1) != 0) return;
9349         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9350         FREE((void*)_res);
9351         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
9352 }
9353
9354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9355         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
9356         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
9357         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
9358         return (long)ret_conv;
9359 }
9360
9361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9362         LDKChannelUpdate o_conv;
9363         o_conv.inner = (void*)(o & (~1));
9364         o_conv.is_owned = (o & 1) || (o == 0);
9365         o_conv = ChannelUpdate_clone(&o_conv);
9366         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9367         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
9368         return (long)ret_conv;
9369 }
9370
9371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9372         LDKDecodeError e_conv;
9373         e_conv.inner = (void*)(e & (~1));
9374         e_conv.is_owned = (e & 1) || (e == 0);
9375         e_conv = DecodeError_clone(&e_conv);
9376         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9377         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
9378         return (long)ret_conv;
9379 }
9380
9381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9382         if ((_res & 1) != 0) return;
9383         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9384         FREE((void*)_res);
9385         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
9386 }
9387
9388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9389         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
9390         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
9391         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
9392         return (long)ret_conv;
9393 }
9394
9395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9396         LDKErrorMessage o_conv;
9397         o_conv.inner = (void*)(o & (~1));
9398         o_conv.is_owned = (o & 1) || (o == 0);
9399         o_conv = ErrorMessage_clone(&o_conv);
9400         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9401         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
9402         return (long)ret_conv;
9403 }
9404
9405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9406         LDKDecodeError e_conv;
9407         e_conv.inner = (void*)(e & (~1));
9408         e_conv.is_owned = (e & 1) || (e == 0);
9409         e_conv = DecodeError_clone(&e_conv);
9410         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9411         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
9412         return (long)ret_conv;
9413 }
9414
9415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9416         if ((_res & 1) != 0) return;
9417         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
9418         FREE((void*)_res);
9419         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
9420 }
9421
9422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9423         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
9424         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
9425         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
9426         return (long)ret_conv;
9427 }
9428
9429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9430         LDKUnsignedNodeAnnouncement o_conv;
9431         o_conv.inner = (void*)(o & (~1));
9432         o_conv.is_owned = (o & 1) || (o == 0);
9433         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
9434         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9435         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
9436         return (long)ret_conv;
9437 }
9438
9439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9440         LDKDecodeError e_conv;
9441         e_conv.inner = (void*)(e & (~1));
9442         e_conv.is_owned = (e & 1) || (e == 0);
9443         e_conv = DecodeError_clone(&e_conv);
9444         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9445         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
9446         return (long)ret_conv;
9447 }
9448
9449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9450         if ((_res & 1) != 0) return;
9451         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9452         FREE((void*)_res);
9453         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
9454 }
9455
9456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9457         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
9458         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
9459         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
9460         return (long)ret_conv;
9461 }
9462
9463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9464         LDKNodeAnnouncement o_conv;
9465         o_conv.inner = (void*)(o & (~1));
9466         o_conv.is_owned = (o & 1) || (o == 0);
9467         o_conv = NodeAnnouncement_clone(&o_conv);
9468         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9469         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
9470         return (long)ret_conv;
9471 }
9472
9473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9474         LDKDecodeError e_conv;
9475         e_conv.inner = (void*)(e & (~1));
9476         e_conv.is_owned = (e & 1) || (e == 0);
9477         e_conv = DecodeError_clone(&e_conv);
9478         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9479         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
9480         return (long)ret_conv;
9481 }
9482
9483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9484         if ((_res & 1) != 0) return;
9485         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
9486         FREE((void*)_res);
9487         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
9488 }
9489
9490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9491         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
9492         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
9493         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
9494         return (long)ret_conv;
9495 }
9496
9497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9498         LDKQueryShortChannelIds o_conv;
9499         o_conv.inner = (void*)(o & (~1));
9500         o_conv.is_owned = (o & 1) || (o == 0);
9501         o_conv = QueryShortChannelIds_clone(&o_conv);
9502         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9503         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
9504         return (long)ret_conv;
9505 }
9506
9507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9508         LDKDecodeError e_conv;
9509         e_conv.inner = (void*)(e & (~1));
9510         e_conv.is_owned = (e & 1) || (e == 0);
9511         e_conv = DecodeError_clone(&e_conv);
9512         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9513         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
9514         return (long)ret_conv;
9515 }
9516
9517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9518         if ((_res & 1) != 0) return;
9519         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
9520         FREE((void*)_res);
9521         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
9522 }
9523
9524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9525         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
9526         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
9527         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
9528         return (long)ret_conv;
9529 }
9530
9531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9532         LDKReplyShortChannelIdsEnd o_conv;
9533         o_conv.inner = (void*)(o & (~1));
9534         o_conv.is_owned = (o & 1) || (o == 0);
9535         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
9536         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9537         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
9538         return (long)ret_conv;
9539 }
9540
9541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9542         LDKDecodeError e_conv;
9543         e_conv.inner = (void*)(e & (~1));
9544         e_conv.is_owned = (e & 1) || (e == 0);
9545         e_conv = DecodeError_clone(&e_conv);
9546         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9547         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
9548         return (long)ret_conv;
9549 }
9550
9551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9552         if ((_res & 1) != 0) return;
9553         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
9554         FREE((void*)_res);
9555         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
9556 }
9557
9558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9559         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
9560         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
9561         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
9562         return (long)ret_conv;
9563 }
9564
9565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9566         LDKQueryChannelRange o_conv;
9567         o_conv.inner = (void*)(o & (~1));
9568         o_conv.is_owned = (o & 1) || (o == 0);
9569         o_conv = QueryChannelRange_clone(&o_conv);
9570         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9571         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
9572         return (long)ret_conv;
9573 }
9574
9575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9576         LDKDecodeError e_conv;
9577         e_conv.inner = (void*)(e & (~1));
9578         e_conv.is_owned = (e & 1) || (e == 0);
9579         e_conv = DecodeError_clone(&e_conv);
9580         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9581         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
9582         return (long)ret_conv;
9583 }
9584
9585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9586         if ((_res & 1) != 0) return;
9587         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9588         FREE((void*)_res);
9589         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
9590 }
9591
9592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9593         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
9594         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
9595         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
9596         return (long)ret_conv;
9597 }
9598
9599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9600         LDKReplyChannelRange o_conv;
9601         o_conv.inner = (void*)(o & (~1));
9602         o_conv.is_owned = (o & 1) || (o == 0);
9603         o_conv = ReplyChannelRange_clone(&o_conv);
9604         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9605         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
9606         return (long)ret_conv;
9607 }
9608
9609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9610         LDKDecodeError e_conv;
9611         e_conv.inner = (void*)(e & (~1));
9612         e_conv.is_owned = (e & 1) || (e == 0);
9613         e_conv = DecodeError_clone(&e_conv);
9614         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9615         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
9616         return (long)ret_conv;
9617 }
9618
9619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9620         if ((_res & 1) != 0) return;
9621         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9622         FREE((void*)_res);
9623         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
9624 }
9625
9626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9627         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
9628         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
9629         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
9630         return (long)ret_conv;
9631 }
9632
9633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9634         LDKGossipTimestampFilter o_conv;
9635         o_conv.inner = (void*)(o & (~1));
9636         o_conv.is_owned = (o & 1) || (o == 0);
9637         o_conv = GossipTimestampFilter_clone(&o_conv);
9638         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9639         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
9640         return (long)ret_conv;
9641 }
9642
9643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9644         LDKDecodeError e_conv;
9645         e_conv.inner = (void*)(e & (~1));
9646         e_conv.is_owned = (e & 1) || (e == 0);
9647         e_conv = DecodeError_clone(&e_conv);
9648         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9649         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
9650         return (long)ret_conv;
9651 }
9652
9653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9654         if ((_res & 1) != 0) return;
9655         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
9656         FREE((void*)_res);
9657         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
9658 }
9659
9660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9661         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
9662         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
9663         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
9664         return (long)ret_conv;
9665 }
9666
9667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9668         if ((this_ptr & 1) != 0) return;
9669         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
9670         FREE((void*)this_ptr);
9671         Event_free(this_ptr_conv);
9672 }
9673
9674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9675         LDKEvent* orig_conv = (LDKEvent*)orig;
9676         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
9677         *ret_copy = Event_clone(orig_conv);
9678         long ret_ref = (long)ret_copy;
9679         return ret_ref;
9680 }
9681
9682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
9683         LDKEvent* obj_conv = (LDKEvent*)obj;
9684         LDKCVec_u8Z ret_var = Event_write(obj_conv);
9685         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9686         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9687         CVec_u8Z_free(ret_var);
9688         return ret_arr;
9689 }
9690
9691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9692         if ((this_ptr & 1) != 0) return;
9693         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
9694         FREE((void*)this_ptr);
9695         MessageSendEvent_free(this_ptr_conv);
9696 }
9697
9698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9699         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
9700         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9701         *ret_copy = MessageSendEvent_clone(orig_conv);
9702         long ret_ref = (long)ret_copy;
9703         return ret_ref;
9704 }
9705
9706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9707         if ((this_ptr & 1) != 0) return;
9708         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
9709         FREE((void*)this_ptr);
9710         MessageSendEventsProvider_free(this_ptr_conv);
9711 }
9712
9713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9714         if ((this_ptr & 1) != 0) return;
9715         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
9716         FREE((void*)this_ptr);
9717         EventsProvider_free(this_ptr_conv);
9718 }
9719
9720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9721         if ((this_ptr & 1) != 0) return;
9722         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
9723         FREE((void*)this_ptr);
9724         APIError_free(this_ptr_conv);
9725 }
9726
9727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9728         LDKAPIError* orig_conv = (LDKAPIError*)orig;
9729         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
9730         *ret_copy = APIError_clone(orig_conv);
9731         long ret_ref = (long)ret_copy;
9732         return ret_ref;
9733 }
9734
9735 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9736         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
9737         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
9738         return ret_conv;
9739 }
9740
9741 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
9742         jclass ret_conv = LDKLevel_to_java(env, Level_max());
9743         return ret_conv;
9744 }
9745
9746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9747         if ((this_ptr & 1) != 0) return;
9748         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
9749         FREE((void*)this_ptr);
9750         Logger_free(this_ptr_conv);
9751 }
9752
9753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9754         LDKChannelHandshakeConfig this_ptr_conv;
9755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9756         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9757         ChannelHandshakeConfig_free(this_ptr_conv);
9758 }
9759
9760 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
9761         LDKChannelHandshakeConfig this_ptr_conv;
9762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9763         this_ptr_conv.is_owned = false;
9764         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
9765         return ret_val;
9766 }
9767
9768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
9769         LDKChannelHandshakeConfig this_ptr_conv;
9770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9771         this_ptr_conv.is_owned = false;
9772         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
9773 }
9774
9775 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
9776         LDKChannelHandshakeConfig this_ptr_conv;
9777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9778         this_ptr_conv.is_owned = false;
9779         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
9780         return ret_val;
9781 }
9782
9783 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) {
9784         LDKChannelHandshakeConfig this_ptr_conv;
9785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9786         this_ptr_conv.is_owned = false;
9787         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
9788 }
9789
9790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
9791         LDKChannelHandshakeConfig this_ptr_conv;
9792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9793         this_ptr_conv.is_owned = false;
9794         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
9795         return ret_val;
9796 }
9797
9798 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) {
9799         LDKChannelHandshakeConfig this_ptr_conv;
9800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9801         this_ptr_conv.is_owned = false;
9802         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
9803 }
9804
9805 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) {
9806         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
9807         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9808         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9809         long ret_ref = (long)ret_var.inner;
9810         if (ret_var.is_owned) {
9811                 ret_ref |= 1;
9812         }
9813         return ret_ref;
9814 }
9815
9816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9817         LDKChannelHandshakeConfig orig_conv;
9818         orig_conv.inner = (void*)(orig & (~1));
9819         orig_conv.is_owned = false;
9820         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
9821         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9822         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9823         long ret_ref = (long)ret_var.inner;
9824         if (ret_var.is_owned) {
9825                 ret_ref |= 1;
9826         }
9827         return ret_ref;
9828 }
9829
9830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
9831         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
9832         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9833         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9834         long ret_ref = (long)ret_var.inner;
9835         if (ret_var.is_owned) {
9836                 ret_ref |= 1;
9837         }
9838         return ret_ref;
9839 }
9840
9841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
9842         LDKChannelHandshakeLimits this_ptr_conv;
9843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9844         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9845         ChannelHandshakeLimits_free(this_ptr_conv);
9846 }
9847
9848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9849         LDKChannelHandshakeLimits this_ptr_conv;
9850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9851         this_ptr_conv.is_owned = false;
9852         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
9853         return ret_val;
9854 }
9855
9856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9857         LDKChannelHandshakeLimits this_ptr_conv;
9858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9859         this_ptr_conv.is_owned = false;
9860         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
9861 }
9862
9863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
9864         LDKChannelHandshakeLimits this_ptr_conv;
9865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9866         this_ptr_conv.is_owned = false;
9867         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
9868         return ret_val;
9869 }
9870
9871 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) {
9872         LDKChannelHandshakeLimits this_ptr_conv;
9873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9874         this_ptr_conv.is_owned = false;
9875         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
9876 }
9877
9878 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) {
9879         LDKChannelHandshakeLimits this_ptr_conv;
9880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9881         this_ptr_conv.is_owned = false;
9882         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
9883         return ret_val;
9884 }
9885
9886 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) {
9887         LDKChannelHandshakeLimits this_ptr_conv;
9888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9889         this_ptr_conv.is_owned = false;
9890         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
9891 }
9892
9893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9894         LDKChannelHandshakeLimits this_ptr_conv;
9895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9896         this_ptr_conv.is_owned = false;
9897         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
9898         return ret_val;
9899 }
9900
9901 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) {
9902         LDKChannelHandshakeLimits this_ptr_conv;
9903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9904         this_ptr_conv.is_owned = false;
9905         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
9906 }
9907
9908 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
9909         LDKChannelHandshakeLimits this_ptr_conv;
9910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9911         this_ptr_conv.is_owned = false;
9912         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
9913         return ret_val;
9914 }
9915
9916 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) {
9917         LDKChannelHandshakeLimits this_ptr_conv;
9918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9919         this_ptr_conv.is_owned = false;
9920         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
9921 }
9922
9923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9924         LDKChannelHandshakeLimits this_ptr_conv;
9925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9926         this_ptr_conv.is_owned = false;
9927         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
9928         return ret_val;
9929 }
9930
9931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9932         LDKChannelHandshakeLimits this_ptr_conv;
9933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9934         this_ptr_conv.is_owned = false;
9935         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
9936 }
9937
9938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
9939         LDKChannelHandshakeLimits this_ptr_conv;
9940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9941         this_ptr_conv.is_owned = false;
9942         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
9943         return ret_val;
9944 }
9945
9946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
9947         LDKChannelHandshakeLimits this_ptr_conv;
9948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9949         this_ptr_conv.is_owned = false;
9950         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
9951 }
9952
9953 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
9954         LDKChannelHandshakeLimits this_ptr_conv;
9955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9956         this_ptr_conv.is_owned = false;
9957         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
9958         return ret_val;
9959 }
9960
9961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
9962         LDKChannelHandshakeLimits this_ptr_conv;
9963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9964         this_ptr_conv.is_owned = false;
9965         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
9966 }
9967
9968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
9969         LDKChannelHandshakeLimits this_ptr_conv;
9970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9971         this_ptr_conv.is_owned = false;
9972         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
9973         return ret_val;
9974 }
9975
9976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
9977         LDKChannelHandshakeLimits this_ptr_conv;
9978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9979         this_ptr_conv.is_owned = false;
9980         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
9981 }
9982
9983 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
9984         LDKChannelHandshakeLimits this_ptr_conv;
9985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9986         this_ptr_conv.is_owned = false;
9987         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
9988         return ret_val;
9989 }
9990
9991 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) {
9992         LDKChannelHandshakeLimits this_ptr_conv;
9993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9994         this_ptr_conv.is_owned = false;
9995         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
9996 }
9997
9998 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, int64_t min_dust_limit_satoshis_arg, int64_t max_dust_limit_satoshis_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
9999         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, min_dust_limit_satoshis_arg, max_dust_limit_satoshis_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
10000         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10001         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10002         long ret_ref = (long)ret_var.inner;
10003         if (ret_var.is_owned) {
10004                 ret_ref |= 1;
10005         }
10006         return ret_ref;
10007 }
10008
10009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10010         LDKChannelHandshakeLimits orig_conv;
10011         orig_conv.inner = (void*)(orig & (~1));
10012         orig_conv.is_owned = false;
10013         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
10014         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10015         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10016         long ret_ref = (long)ret_var.inner;
10017         if (ret_var.is_owned) {
10018                 ret_ref |= 1;
10019         }
10020         return ret_ref;
10021 }
10022
10023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
10024         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
10025         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10026         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10027         long ret_ref = (long)ret_var.inner;
10028         if (ret_var.is_owned) {
10029                 ret_ref |= 1;
10030         }
10031         return ret_ref;
10032 }
10033
10034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10035         LDKChannelConfig this_ptr_conv;
10036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10037         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10038         ChannelConfig_free(this_ptr_conv);
10039 }
10040
10041 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
10042         LDKChannelConfig this_ptr_conv;
10043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10044         this_ptr_conv.is_owned = false;
10045         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
10046         return ret_val;
10047 }
10048
10049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
10050         LDKChannelConfig this_ptr_conv;
10051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10052         this_ptr_conv.is_owned = false;
10053         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
10054 }
10055
10056 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
10057         LDKChannelConfig this_ptr_conv;
10058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10059         this_ptr_conv.is_owned = false;
10060         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
10061         return ret_val;
10062 }
10063
10064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10065         LDKChannelConfig this_ptr_conv;
10066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10067         this_ptr_conv.is_owned = false;
10068         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
10069 }
10070
10071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
10072         LDKChannelConfig this_ptr_conv;
10073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10074         this_ptr_conv.is_owned = false;
10075         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
10076         return ret_val;
10077 }
10078
10079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
10080         LDKChannelConfig this_ptr_conv;
10081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10082         this_ptr_conv.is_owned = false;
10083         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
10084 }
10085
10086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
10087         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
10088         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10089         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10090         long ret_ref = (long)ret_var.inner;
10091         if (ret_var.is_owned) {
10092                 ret_ref |= 1;
10093         }
10094         return ret_ref;
10095 }
10096
10097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10098         LDKChannelConfig orig_conv;
10099         orig_conv.inner = (void*)(orig & (~1));
10100         orig_conv.is_owned = false;
10101         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
10102         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10103         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10104         long ret_ref = (long)ret_var.inner;
10105         if (ret_var.is_owned) {
10106                 ret_ref |= 1;
10107         }
10108         return ret_ref;
10109 }
10110
10111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
10112         LDKChannelConfig ret_var = ChannelConfig_default();
10113         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10114         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10115         long ret_ref = (long)ret_var.inner;
10116         if (ret_var.is_owned) {
10117                 ret_ref |= 1;
10118         }
10119         return ret_ref;
10120 }
10121
10122 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
10123         LDKChannelConfig obj_conv;
10124         obj_conv.inner = (void*)(obj & (~1));
10125         obj_conv.is_owned = false;
10126         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
10127         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10128         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10129         CVec_u8Z_free(ret_var);
10130         return ret_arr;
10131 }
10132
10133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10134         LDKu8slice ser_ref;
10135         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10136         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10137         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10138         *ret_conv = ChannelConfig_read(ser_ref);
10139         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10140         return (long)ret_conv;
10141 }
10142
10143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10144         LDKUserConfig this_ptr_conv;
10145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10146         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10147         UserConfig_free(this_ptr_conv);
10148 }
10149
10150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
10151         LDKUserConfig this_ptr_conv;
10152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10153         this_ptr_conv.is_owned = false;
10154         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
10155         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10156         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10157         long ret_ref = (long)ret_var.inner;
10158         if (ret_var.is_owned) {
10159                 ret_ref |= 1;
10160         }
10161         return ret_ref;
10162 }
10163
10164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10165         LDKUserConfig this_ptr_conv;
10166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10167         this_ptr_conv.is_owned = false;
10168         LDKChannelHandshakeConfig val_conv;
10169         val_conv.inner = (void*)(val & (~1));
10170         val_conv.is_owned = (val & 1) || (val == 0);
10171         val_conv = ChannelHandshakeConfig_clone(&val_conv);
10172         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
10173 }
10174
10175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
10176         LDKUserConfig this_ptr_conv;
10177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10178         this_ptr_conv.is_owned = false;
10179         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
10180         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10181         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10182         long ret_ref = (long)ret_var.inner;
10183         if (ret_var.is_owned) {
10184                 ret_ref |= 1;
10185         }
10186         return ret_ref;
10187 }
10188
10189 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) {
10190         LDKUserConfig this_ptr_conv;
10191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10192         this_ptr_conv.is_owned = false;
10193         LDKChannelHandshakeLimits val_conv;
10194         val_conv.inner = (void*)(val & (~1));
10195         val_conv.is_owned = (val & 1) || (val == 0);
10196         val_conv = ChannelHandshakeLimits_clone(&val_conv);
10197         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
10198 }
10199
10200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
10201         LDKUserConfig this_ptr_conv;
10202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10203         this_ptr_conv.is_owned = false;
10204         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
10205         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10206         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10207         long ret_ref = (long)ret_var.inner;
10208         if (ret_var.is_owned) {
10209                 ret_ref |= 1;
10210         }
10211         return ret_ref;
10212 }
10213
10214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10215         LDKUserConfig this_ptr_conv;
10216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10217         this_ptr_conv.is_owned = false;
10218         LDKChannelConfig val_conv;
10219         val_conv.inner = (void*)(val & (~1));
10220         val_conv.is_owned = (val & 1) || (val == 0);
10221         val_conv = ChannelConfig_clone(&val_conv);
10222         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
10223 }
10224
10225 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) {
10226         LDKChannelHandshakeConfig own_channel_config_arg_conv;
10227         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
10228         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
10229         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
10230         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
10231         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
10232         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
10233         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
10234         LDKChannelConfig channel_options_arg_conv;
10235         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
10236         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
10237         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
10238         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
10239         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10240         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10241         long ret_ref = (long)ret_var.inner;
10242         if (ret_var.is_owned) {
10243                 ret_ref |= 1;
10244         }
10245         return ret_ref;
10246 }
10247
10248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10249         LDKUserConfig orig_conv;
10250         orig_conv.inner = (void*)(orig & (~1));
10251         orig_conv.is_owned = false;
10252         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
10253         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10254         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10255         long ret_ref = (long)ret_var.inner;
10256         if (ret_var.is_owned) {
10257                 ret_ref |= 1;
10258         }
10259         return ret_ref;
10260 }
10261
10262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
10263         LDKUserConfig ret_var = UserConfig_default();
10264         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10265         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10266         long ret_ref = (long)ret_var.inner;
10267         if (ret_var.is_owned) {
10268                 ret_ref |= 1;
10269         }
10270         return ret_ref;
10271 }
10272
10273 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10274         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
10275         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
10276         return ret_conv;
10277 }
10278
10279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10280         if ((this_ptr & 1) != 0) return;
10281         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
10282         FREE((void*)this_ptr);
10283         Access_free(this_ptr_conv);
10284 }
10285
10286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10287         if ((this_ptr & 1) != 0) return;
10288         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
10289         FREE((void*)this_ptr);
10290         Listen_free(this_ptr_conv);
10291 }
10292
10293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10294         if ((this_ptr & 1) != 0) return;
10295         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
10296         FREE((void*)this_ptr);
10297         Watch_free(this_ptr_conv);
10298 }
10299
10300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10301         if ((this_ptr & 1) != 0) return;
10302         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
10303         FREE((void*)this_ptr);
10304         Filter_free(this_ptr_conv);
10305 }
10306
10307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10308         if ((this_ptr & 1) != 0) return;
10309         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
10310         FREE((void*)this_ptr);
10311         BroadcasterInterface_free(this_ptr_conv);
10312 }
10313
10314 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10315         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
10316         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
10317         return ret_conv;
10318 }
10319
10320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10321         if ((this_ptr & 1) != 0) return;
10322         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
10323         FREE((void*)this_ptr);
10324         FeeEstimator_free(this_ptr_conv);
10325 }
10326
10327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10328         LDKChainMonitor this_ptr_conv;
10329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10330         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10331         ChainMonitor_free(this_ptr_conv);
10332 }
10333
10334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
10335         LDKChainMonitor this_arg_conv;
10336         this_arg_conv.inner = (void*)(this_arg & (~1));
10337         this_arg_conv.is_owned = false;
10338         unsigned char header_arr[80];
10339         CHECK((*env)->GetArrayLength(env, header) == 80);
10340         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10341         unsigned char (*header_ref)[80] = &header_arr;
10342         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10343         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10344         if (txdata_constr.datalen > 0)
10345                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10346         else
10347                 txdata_constr.data = NULL;
10348         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10349         for (size_t y = 0; y < txdata_constr.datalen; y++) {
10350                 int64_t txdata_conv_24 = txdata_vals[y];
10351                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
10352                 FREE((void*)txdata_conv_24);
10353                 txdata_constr.data[y] = txdata_conv_24_conv;
10354         }
10355         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10356         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
10357 }
10358
10359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t disconnected_height) {
10360         LDKChainMonitor this_arg_conv;
10361         this_arg_conv.inner = (void*)(this_arg & (~1));
10362         this_arg_conv.is_owned = false;
10363         unsigned char header_arr[80];
10364         CHECK((*env)->GetArrayLength(env, header) == 80);
10365         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10366         unsigned char (*header_ref)[80] = &header_arr;
10367         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
10368 }
10369
10370 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) {
10371         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
10372         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10373         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10374                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10375                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10376         }
10377         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10378         if (logger_conv.free == LDKLogger_JCalls_free) {
10379                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10380                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10381         }
10382         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
10383         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
10384                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10385                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
10386         }
10387         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
10388         if (persister_conv.free == LDKPersist_JCalls_free) {
10389                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10390                 LDKPersist_JCalls_clone(persister_conv.this_arg);
10391         }
10392         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
10393         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10394         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10395         long ret_ref = (long)ret_var.inner;
10396         if (ret_var.is_owned) {
10397                 ret_ref |= 1;
10398         }
10399         return ret_ref;
10400 }
10401
10402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
10403         LDKChainMonitor this_arg_conv;
10404         this_arg_conv.inner = (void*)(this_arg & (~1));
10405         this_arg_conv.is_owned = false;
10406         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
10407         *ret = ChainMonitor_as_Watch(&this_arg_conv);
10408         return (long)ret;
10409 }
10410
10411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
10412         LDKChainMonitor this_arg_conv;
10413         this_arg_conv.inner = (void*)(this_arg & (~1));
10414         this_arg_conv.is_owned = false;
10415         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10416         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
10417         return (long)ret;
10418 }
10419
10420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10421         LDKChannelMonitorUpdate this_ptr_conv;
10422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10423         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10424         ChannelMonitorUpdate_free(this_ptr_conv);
10425 }
10426
10427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
10428         LDKChannelMonitorUpdate this_ptr_conv;
10429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10430         this_ptr_conv.is_owned = false;
10431         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
10432         return ret_val;
10433 }
10434
10435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10436         LDKChannelMonitorUpdate this_ptr_conv;
10437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10438         this_ptr_conv.is_owned = false;
10439         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
10440 }
10441
10442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10443         LDKChannelMonitorUpdate orig_conv;
10444         orig_conv.inner = (void*)(orig & (~1));
10445         orig_conv.is_owned = false;
10446         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
10447         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10448         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10449         long ret_ref = (long)ret_var.inner;
10450         if (ret_var.is_owned) {
10451                 ret_ref |= 1;
10452         }
10453         return ret_ref;
10454 }
10455
10456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
10457         LDKChannelMonitorUpdate obj_conv;
10458         obj_conv.inner = (void*)(obj & (~1));
10459         obj_conv.is_owned = false;
10460         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
10461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10463         CVec_u8Z_free(ret_var);
10464         return ret_arr;
10465 }
10466
10467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10468         LDKu8slice ser_ref;
10469         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10470         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10471         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10472         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
10473         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10474         return (long)ret_conv;
10475 }
10476
10477 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10478         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
10479         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
10480         return ret_conv;
10481 }
10482
10483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10484         LDKMonitorUpdateError this_ptr_conv;
10485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10486         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10487         MonitorUpdateError_free(this_ptr_conv);
10488 }
10489
10490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10491         LDKMonitorUpdateError orig_conv;
10492         orig_conv.inner = (void*)(orig & (~1));
10493         orig_conv.is_owned = false;
10494         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
10495         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10496         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10497         long ret_ref = (long)ret_var.inner;
10498         if (ret_var.is_owned) {
10499                 ret_ref |= 1;
10500         }
10501         return ret_ref;
10502 }
10503
10504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10505         if ((this_ptr & 1) != 0) return;
10506         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
10507         FREE((void*)this_ptr);
10508         MonitorEvent_free(this_ptr_conv);
10509 }
10510
10511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10512         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
10513         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
10514         *ret_copy = MonitorEvent_clone(orig_conv);
10515         long ret_ref = (long)ret_copy;
10516         return ret_ref;
10517 }
10518
10519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10520         LDKHTLCUpdate this_ptr_conv;
10521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10522         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10523         HTLCUpdate_free(this_ptr_conv);
10524 }
10525
10526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10527         LDKHTLCUpdate orig_conv;
10528         orig_conv.inner = (void*)(orig & (~1));
10529         orig_conv.is_owned = false;
10530         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
10531         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10532         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10533         long ret_ref = (long)ret_var.inner;
10534         if (ret_var.is_owned) {
10535                 ret_ref |= 1;
10536         }
10537         return ret_ref;
10538 }
10539
10540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
10541         LDKHTLCUpdate obj_conv;
10542         obj_conv.inner = (void*)(obj & (~1));
10543         obj_conv.is_owned = false;
10544         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
10545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10547         CVec_u8Z_free(ret_var);
10548         return ret_arr;
10549 }
10550
10551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10552         LDKu8slice ser_ref;
10553         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10554         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10555         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10556         *ret_conv = HTLCUpdate_read(ser_ref);
10557         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10558         return (long)ret_conv;
10559 }
10560
10561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10562         LDKChannelMonitor this_ptr_conv;
10563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10564         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10565         ChannelMonitor_free(this_ptr_conv);
10566 }
10567
10568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10569         LDKChannelMonitor orig_conv;
10570         orig_conv.inner = (void*)(orig & (~1));
10571         orig_conv.is_owned = false;
10572         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
10573         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10574         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10575         long ret_ref = (long)ret_var.inner;
10576         if (ret_var.is_owned) {
10577                 ret_ref |= 1;
10578         }
10579         return ret_ref;
10580 }
10581
10582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
10583         LDKChannelMonitor obj_conv;
10584         obj_conv.inner = (void*)(obj & (~1));
10585         obj_conv.is_owned = false;
10586         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
10587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10589         CVec_u8Z_free(ret_var);
10590         return ret_arr;
10591 }
10592
10593 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) {
10594         LDKChannelMonitor this_arg_conv;
10595         this_arg_conv.inner = (void*)(this_arg & (~1));
10596         this_arg_conv.is_owned = false;
10597         LDKChannelMonitorUpdate updates_conv;
10598         updates_conv.inner = (void*)(updates & (~1));
10599         updates_conv.is_owned = false;
10600         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
10601         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator;
10602         LDKLogger* logger_conv = (LDKLogger*)logger;
10603         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10604         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
10605         return (long)ret_conv;
10606 }
10607
10608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
10609         LDKChannelMonitor this_arg_conv;
10610         this_arg_conv.inner = (void*)(this_arg & (~1));
10611         this_arg_conv.is_owned = false;
10612         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
10613         return ret_val;
10614 }
10615
10616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
10617         LDKChannelMonitor this_arg_conv;
10618         this_arg_conv.inner = (void*)(this_arg & (~1));
10619         this_arg_conv.is_owned = false;
10620         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10621         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
10622         return (long)ret_ref;
10623 }
10624
10625 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10626         LDKChannelMonitor this_arg_conv;
10627         this_arg_conv.inner = (void*)(this_arg & (~1));
10628         this_arg_conv.is_owned = false;
10629         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
10630         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10631         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10632         for (size_t o = 0; o < ret_var.datalen; o++) {
10633                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
10634                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
10635                 long ret_conv_14_ref = (long)ret_conv_14_copy;
10636                 ret_arr_ptr[o] = ret_conv_14_ref;
10637         }
10638         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10639         FREE(ret_var.data);
10640         return ret_arr;
10641 }
10642
10643 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10644         LDKChannelMonitor this_arg_conv;
10645         this_arg_conv.inner = (void*)(this_arg & (~1));
10646         this_arg_conv.is_owned = false;
10647         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
10648         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10649         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10650         for (size_t h = 0; h < ret_var.datalen; h++) {
10651                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10652                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
10653                 long ret_conv_7_ref = (long)ret_conv_7_copy;
10654                 ret_arr_ptr[h] = ret_conv_7_ref;
10655         }
10656         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10657         FREE(ret_var.data);
10658         return ret_arr;
10659 }
10660
10661 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) {
10662         LDKChannelMonitor this_arg_conv;
10663         this_arg_conv.inner = (void*)(this_arg & (~1));
10664         this_arg_conv.is_owned = false;
10665         LDKLogger* logger_conv = (LDKLogger*)logger;
10666         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
10667         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10668         ;
10669         for (size_t i = 0; i < ret_var.datalen; i++) {
10670                 LDKTransaction ret_conv_8_var = ret_var.data[i];
10671                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
10672                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
10673                 Transaction_free(ret_conv_8_var);
10674                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
10675         }
10676         FREE(ret_var.data);
10677         return ret_arr;
10678 }
10679
10680 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) {
10681         LDKChannelMonitor this_arg_conv;
10682         this_arg_conv.inner = (void*)(this_arg & (~1));
10683         this_arg_conv.is_owned = false;
10684         unsigned char header_arr[80];
10685         CHECK((*env)->GetArrayLength(env, header) == 80);
10686         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10687         unsigned char (*header_ref)[80] = &header_arr;
10688         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10689         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10690         if (txdata_constr.datalen > 0)
10691                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10692         else
10693                 txdata_constr.data = NULL;
10694         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10695         for (size_t y = 0; y < txdata_constr.datalen; y++) {
10696                 int64_t txdata_conv_24 = txdata_vals[y];
10697                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
10698                 FREE((void*)txdata_conv_24);
10699                 txdata_constr.data[y] = txdata_conv_24_conv;
10700         }
10701         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10702         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10703         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10704                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10705                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10706         }
10707         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10708         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
10709                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10710                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
10711         }
10712         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10713         if (logger_conv.free == LDKLogger_JCalls_free) {
10714                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10715                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10716         }
10717         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);
10718         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10719         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10720         for (size_t u = 0; u < ret_var.datalen; u++) {
10721                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10722                 *ret_conv_46_ref = ret_var.data[u];
10723                 ret_arr_ptr[u] = (long)ret_conv_46_ref;
10724         }
10725         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10726         FREE(ret_var.data);
10727         return ret_arr;
10728 }
10729
10730 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) {
10731         LDKChannelMonitor this_arg_conv;
10732         this_arg_conv.inner = (void*)(this_arg & (~1));
10733         this_arg_conv.is_owned = false;
10734         unsigned char header_arr[80];
10735         CHECK((*env)->GetArrayLength(env, header) == 80);
10736         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10737         unsigned char (*header_ref)[80] = &header_arr;
10738         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10739         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
10740                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10741                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
10742         }
10743         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10744         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
10745                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10746                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
10747         }
10748         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10749         if (logger_conv.free == LDKLogger_JCalls_free) {
10750                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10751                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10752         }
10753         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
10754 }
10755
10756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10757         if ((this_ptr & 1) != 0) return;
10758         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
10759         FREE((void*)this_ptr);
10760         Persist_free(this_ptr_conv);
10761 }
10762
10763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
10764         LDKu8slice ser_ref;
10765         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10766         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10767         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
10768         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10769         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
10770         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10771         return (long)ret_conv;
10772 }
10773
10774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10775         LDKOutPoint this_ptr_conv;
10776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10777         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10778         OutPoint_free(this_ptr_conv);
10779 }
10780
10781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
10782         LDKOutPoint this_ptr_conv;
10783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10784         this_ptr_conv.is_owned = false;
10785         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10786         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
10787         return ret_arr;
10788 }
10789
10790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10791         LDKOutPoint this_ptr_conv;
10792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10793         this_ptr_conv.is_owned = false;
10794         LDKThirtyTwoBytes val_ref;
10795         CHECK((*env)->GetArrayLength(env, val) == 32);
10796         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
10797         OutPoint_set_txid(&this_ptr_conv, val_ref);
10798 }
10799
10800 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
10801         LDKOutPoint this_ptr_conv;
10802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10803         this_ptr_conv.is_owned = false;
10804         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
10805         return ret_val;
10806 }
10807
10808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
10809         LDKOutPoint this_ptr_conv;
10810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10811         this_ptr_conv.is_owned = false;
10812         OutPoint_set_index(&this_ptr_conv, val);
10813 }
10814
10815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
10816         LDKThirtyTwoBytes txid_arg_ref;
10817         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
10818         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
10819         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
10820         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10821         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10822         long ret_ref = (long)ret_var.inner;
10823         if (ret_var.is_owned) {
10824                 ret_ref |= 1;
10825         }
10826         return ret_ref;
10827 }
10828
10829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10830         LDKOutPoint orig_conv;
10831         orig_conv.inner = (void*)(orig & (~1));
10832         orig_conv.is_owned = false;
10833         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
10834         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10835         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10836         long ret_ref = (long)ret_var.inner;
10837         if (ret_var.is_owned) {
10838                 ret_ref |= 1;
10839         }
10840         return ret_ref;
10841 }
10842
10843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
10844         LDKOutPoint this_arg_conv;
10845         this_arg_conv.inner = (void*)(this_arg & (~1));
10846         this_arg_conv.is_owned = false;
10847         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
10849         return ret_arr;
10850 }
10851
10852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
10853         LDKOutPoint obj_conv;
10854         obj_conv.inner = (void*)(obj & (~1));
10855         obj_conv.is_owned = false;
10856         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
10857         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10858         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10859         CVec_u8Z_free(ret_var);
10860         return ret_arr;
10861 }
10862
10863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
10864         LDKu8slice ser_ref;
10865         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
10866         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
10867         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10868         *ret_conv = OutPoint_read(ser_ref);
10869         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
10870         return (long)ret_conv;
10871 }
10872
10873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
10874         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10876         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10877         DelayedPaymentOutputDescriptor_free(this_ptr_conv);
10878 }
10879
10880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
10881         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10883         this_ptr_conv.is_owned = false;
10884         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
10885         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10886         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10887         long ret_ref = (long)ret_var.inner;
10888         if (ret_var.is_owned) {
10889                 ret_ref |= 1;
10890         }
10891         return ret_ref;
10892 }
10893
10894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10895         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10897         this_ptr_conv.is_owned = false;
10898         LDKOutPoint val_conv;
10899         val_conv.inner = (void*)(val & (~1));
10900         val_conv.is_owned = (val & 1) || (val == 0);
10901         val_conv = OutPoint_clone(&val_conv);
10902         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
10903 }
10904
10905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
10906         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10908         this_ptr_conv.is_owned = false;
10909         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
10910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
10911         return ret_arr;
10912 }
10913
10914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10915         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10917         this_ptr_conv.is_owned = false;
10918         LDKPublicKey val_ref;
10919         CHECK((*env)->GetArrayLength(env, val) == 33);
10920         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
10921         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
10922 }
10923
10924 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
10925         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10927         this_ptr_conv.is_owned = false;
10928         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
10929         return ret_val;
10930 }
10931
10932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
10933         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10935         this_ptr_conv.is_owned = false;
10936         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
10937 }
10938
10939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10940         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10942         this_ptr_conv.is_owned = false;
10943         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
10944         FREE((void*)val);
10945         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
10946 }
10947
10948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
10949         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10951         this_ptr_conv.is_owned = false;
10952         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
10953         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
10954         return ret_arr;
10955 }
10956
10957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10958         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10960         this_ptr_conv.is_owned = false;
10961         LDKPublicKey val_ref;
10962         CHECK((*env)->GetArrayLength(env, val) == 33);
10963         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
10964         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
10965 }
10966
10967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
10968         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10970         this_ptr_conv.is_owned = false;
10971         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10972         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
10973         return ret_arr;
10974 }
10975
10976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
10977         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10979         this_ptr_conv.is_owned = false;
10980         LDKThirtyTwoBytes val_ref;
10981         CHECK((*env)->GetArrayLength(env, val) == 32);
10982         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
10983         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
10984 }
10985
10986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
10987         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10989         this_ptr_conv.is_owned = false;
10990         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
10991         return ret_val;
10992 }
10993
10994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
10995         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10997         this_ptr_conv.is_owned = false;
10998         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
10999 }
11000
11001 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) {
11002         LDKOutPoint outpoint_arg_conv;
11003         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11004         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11005         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11006         LDKPublicKey per_commitment_point_arg_ref;
11007         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
11008         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
11009         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
11010         FREE((void*)output_arg);
11011         LDKPublicKey revocation_pubkey_arg_ref;
11012         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
11013         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
11014         LDKThirtyTwoBytes channel_keys_id_arg_ref;
11015         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
11016         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
11017         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);
11018         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11019         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11020         long ret_ref = (long)ret_var.inner;
11021         if (ret_var.is_owned) {
11022                 ret_ref |= 1;
11023         }
11024         return ret_ref;
11025 }
11026
11027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11028         LDKDelayedPaymentOutputDescriptor orig_conv;
11029         orig_conv.inner = (void*)(orig & (~1));
11030         orig_conv.is_owned = false;
11031         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
11032         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11033         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11034         long ret_ref = (long)ret_var.inner;
11035         if (ret_var.is_owned) {
11036                 ret_ref |= 1;
11037         }
11038         return ret_ref;
11039 }
11040
11041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11042         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11044         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11045         StaticPaymentOutputDescriptor_free(this_ptr_conv);
11046 }
11047
11048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
11049         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11051         this_ptr_conv.is_owned = false;
11052         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
11053         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11054         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11055         long ret_ref = (long)ret_var.inner;
11056         if (ret_var.is_owned) {
11057                 ret_ref |= 1;
11058         }
11059         return ret_ref;
11060 }
11061
11062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11063         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11065         this_ptr_conv.is_owned = false;
11066         LDKOutPoint val_conv;
11067         val_conv.inner = (void*)(val & (~1));
11068         val_conv.is_owned = (val & 1) || (val == 0);
11069         val_conv = OutPoint_clone(&val_conv);
11070         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
11071 }
11072
11073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11074         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11076         this_ptr_conv.is_owned = false;
11077         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
11078         FREE((void*)val);
11079         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
11080 }
11081
11082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11083         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11085         this_ptr_conv.is_owned = false;
11086         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11087         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
11088         return ret_arr;
11089 }
11090
11091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11092         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11094         this_ptr_conv.is_owned = false;
11095         LDKThirtyTwoBytes val_ref;
11096         CHECK((*env)->GetArrayLength(env, val) == 32);
11097         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11098         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
11099 }
11100
11101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11102         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11104         this_ptr_conv.is_owned = false;
11105         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
11106         return ret_val;
11107 }
11108
11109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11110         LDKStaticPaymentOutputDescriptor this_ptr_conv;
11111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11112         this_ptr_conv.is_owned = false;
11113         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
11114 }
11115
11116 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) {
11117         LDKOutPoint outpoint_arg_conv;
11118         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11119         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11120         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11121         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
11122         FREE((void*)output_arg);
11123         LDKThirtyTwoBytes channel_keys_id_arg_ref;
11124         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
11125         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
11126         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
11127         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11128         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11129         long ret_ref = (long)ret_var.inner;
11130         if (ret_var.is_owned) {
11131                 ret_ref |= 1;
11132         }
11133         return ret_ref;
11134 }
11135
11136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11137         LDKStaticPaymentOutputDescriptor orig_conv;
11138         orig_conv.inner = (void*)(orig & (~1));
11139         orig_conv.is_owned = false;
11140         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
11141         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11142         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11143         long ret_ref = (long)ret_var.inner;
11144         if (ret_var.is_owned) {
11145                 ret_ref |= 1;
11146         }
11147         return ret_ref;
11148 }
11149
11150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11151         if ((this_ptr & 1) != 0) return;
11152         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
11153         FREE((void*)this_ptr);
11154         SpendableOutputDescriptor_free(this_ptr_conv);
11155 }
11156
11157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11158         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
11159         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
11160         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
11161         long ret_ref = (long)ret_copy;
11162         return ret_ref;
11163 }
11164
11165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
11166         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
11167         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
11168         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11169         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11170         CVec_u8Z_free(ret_var);
11171         return ret_arr;
11172 }
11173
11174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11175         LDKu8slice ser_ref;
11176         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11177         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11178         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
11179         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
11180         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11181         return (long)ret_conv;
11182 }
11183
11184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11185         LDKSign* orig_conv = (LDKSign*)orig;
11186         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
11187         *ret = Sign_clone(orig_conv);
11188         return (long)ret;
11189 }
11190
11191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11192         if ((this_ptr & 1) != 0) return;
11193         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
11194         FREE((void*)this_ptr);
11195         Sign_free(this_ptr_conv);
11196 }
11197
11198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11199         if ((this_ptr & 1) != 0) return;
11200         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
11201         FREE((void*)this_ptr);
11202         KeysInterface_free(this_ptr_conv);
11203 }
11204
11205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11206         LDKInMemorySigner this_ptr_conv;
11207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11208         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11209         InMemorySigner_free(this_ptr_conv);
11210 }
11211
11212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11213         LDKInMemorySigner this_ptr_conv;
11214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11215         this_ptr_conv.is_owned = false;
11216         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11217         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
11218         return ret_arr;
11219 }
11220
11221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11222         LDKInMemorySigner this_ptr_conv;
11223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11224         this_ptr_conv.is_owned = false;
11225         LDKSecretKey val_ref;
11226         CHECK((*env)->GetArrayLength(env, val) == 32);
11227         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11228         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
11229 }
11230
11231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11232         LDKInMemorySigner this_ptr_conv;
11233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11234         this_ptr_conv.is_owned = false;
11235         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11236         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
11237         return ret_arr;
11238 }
11239
11240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11241         LDKInMemorySigner this_ptr_conv;
11242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11243         this_ptr_conv.is_owned = false;
11244         LDKSecretKey val_ref;
11245         CHECK((*env)->GetArrayLength(env, val) == 32);
11246         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11247         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
11248 }
11249
11250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11251         LDKInMemorySigner this_ptr_conv;
11252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11253         this_ptr_conv.is_owned = false;
11254         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11255         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
11256         return ret_arr;
11257 }
11258
11259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11260         LDKInMemorySigner this_ptr_conv;
11261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11262         this_ptr_conv.is_owned = false;
11263         LDKSecretKey val_ref;
11264         CHECK((*env)->GetArrayLength(env, val) == 32);
11265         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11266         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
11267 }
11268
11269 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11270         LDKInMemorySigner this_ptr_conv;
11271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11272         this_ptr_conv.is_owned = false;
11273         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11274         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
11275         return ret_arr;
11276 }
11277
11278 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) {
11279         LDKInMemorySigner this_ptr_conv;
11280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11281         this_ptr_conv.is_owned = false;
11282         LDKSecretKey val_ref;
11283         CHECK((*env)->GetArrayLength(env, val) == 32);
11284         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11285         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
11286 }
11287
11288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
11289         LDKInMemorySigner this_ptr_conv;
11290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11291         this_ptr_conv.is_owned = false;
11292         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11293         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
11294         return ret_arr;
11295 }
11296
11297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11298         LDKInMemorySigner this_ptr_conv;
11299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11300         this_ptr_conv.is_owned = false;
11301         LDKSecretKey val_ref;
11302         CHECK((*env)->GetArrayLength(env, val) == 32);
11303         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
11304         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
11305 }
11306
11307 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
11308         LDKInMemorySigner this_ptr_conv;
11309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11310         this_ptr_conv.is_owned = false;
11311         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11312         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
11313         return ret_arr;
11314 }
11315
11316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11317         LDKInMemorySigner this_ptr_conv;
11318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11319         this_ptr_conv.is_owned = false;
11320         LDKThirtyTwoBytes val_ref;
11321         CHECK((*env)->GetArrayLength(env, val) == 32);
11322         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11323         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
11324 }
11325
11326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11327         LDKInMemorySigner orig_conv;
11328         orig_conv.inner = (void*)(orig & (~1));
11329         orig_conv.is_owned = false;
11330         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
11331         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11332         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11333         long ret_ref = (long)ret_var.inner;
11334         if (ret_var.is_owned) {
11335                 ret_ref |= 1;
11336         }
11337         return ret_ref;
11338 }
11339
11340 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) {
11341         LDKSecretKey funding_key_ref;
11342         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
11343         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
11344         LDKSecretKey revocation_base_key_ref;
11345         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
11346         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
11347         LDKSecretKey payment_key_ref;
11348         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
11349         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
11350         LDKSecretKey delayed_payment_base_key_ref;
11351         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
11352         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
11353         LDKSecretKey htlc_base_key_ref;
11354         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
11355         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
11356         LDKThirtyTwoBytes commitment_seed_ref;
11357         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
11358         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
11359         LDKThirtyTwoBytes channel_keys_id_ref;
11360         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
11361         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
11362         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);
11363         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11364         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11365         long ret_ref = (long)ret_var.inner;
11366         if (ret_var.is_owned) {
11367                 ret_ref |= 1;
11368         }
11369         return ret_ref;
11370 }
11371
11372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
11373         LDKInMemorySigner this_arg_conv;
11374         this_arg_conv.inner = (void*)(this_arg & (~1));
11375         this_arg_conv.is_owned = false;
11376         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
11377         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11378         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11379         long ret_ref = (long)ret_var.inner;
11380         if (ret_var.is_owned) {
11381                 ret_ref |= 1;
11382         }
11383         return ret_ref;
11384 }
11385
11386 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
11387         LDKInMemorySigner this_arg_conv;
11388         this_arg_conv.inner = (void*)(this_arg & (~1));
11389         this_arg_conv.is_owned = false;
11390         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
11391         return ret_val;
11392 }
11393
11394 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
11395         LDKInMemorySigner this_arg_conv;
11396         this_arg_conv.inner = (void*)(this_arg & (~1));
11397         this_arg_conv.is_owned = false;
11398         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
11399         return ret_val;
11400 }
11401
11402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
11403         LDKInMemorySigner this_arg_conv;
11404         this_arg_conv.inner = (void*)(this_arg & (~1));
11405         this_arg_conv.is_owned = false;
11406         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
11407         return ret_val;
11408 }
11409
11410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
11411         LDKInMemorySigner this_arg_conv;
11412         this_arg_conv.inner = (void*)(this_arg & (~1));
11413         this_arg_conv.is_owned = false;
11414         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
11415         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11416         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11417         long ret_ref = (long)ret_var.inner;
11418         if (ret_var.is_owned) {
11419                 ret_ref |= 1;
11420         }
11421         return ret_ref;
11422 }
11423
11424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
11425         LDKInMemorySigner this_arg_conv;
11426         this_arg_conv.inner = (void*)(this_arg & (~1));
11427         this_arg_conv.is_owned = false;
11428         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
11429         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11430         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11431         long ret_ref = (long)ret_var.inner;
11432         if (ret_var.is_owned) {
11433                 ret_ref |= 1;
11434         }
11435         return ret_ref;
11436 }
11437
11438 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) {
11439         LDKInMemorySigner this_arg_conv;
11440         this_arg_conv.inner = (void*)(this_arg & (~1));
11441         this_arg_conv.is_owned = false;
11442         LDKTransaction spend_tx_ref;
11443         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
11444         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
11445         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
11446         spend_tx_ref.data_is_owned = true;
11447         LDKStaticPaymentOutputDescriptor descriptor_conv;
11448         descriptor_conv.inner = (void*)(descriptor & (~1));
11449         descriptor_conv.is_owned = false;
11450         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11451         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
11452         return (long)ret_conv;
11453 }
11454
11455 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) {
11456         LDKInMemorySigner this_arg_conv;
11457         this_arg_conv.inner = (void*)(this_arg & (~1));
11458         this_arg_conv.is_owned = false;
11459         LDKTransaction spend_tx_ref;
11460         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
11461         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
11462         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
11463         spend_tx_ref.data_is_owned = true;
11464         LDKDelayedPaymentOutputDescriptor descriptor_conv;
11465         descriptor_conv.inner = (void*)(descriptor & (~1));
11466         descriptor_conv.is_owned = false;
11467         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11468         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
11469         return (long)ret_conv;
11470 }
11471
11472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
11473         LDKInMemorySigner this_arg_conv;
11474         this_arg_conv.inner = (void*)(this_arg & (~1));
11475         this_arg_conv.is_owned = false;
11476         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
11477         *ret = InMemorySigner_as_Sign(&this_arg_conv);
11478         return (long)ret;
11479 }
11480
11481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
11482         LDKInMemorySigner obj_conv;
11483         obj_conv.inner = (void*)(obj & (~1));
11484         obj_conv.is_owned = false;
11485         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
11486         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11487         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11488         CVec_u8Z_free(ret_var);
11489         return ret_arr;
11490 }
11491
11492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
11493         LDKu8slice ser_ref;
11494         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
11495         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
11496         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11497         *ret_conv = InMemorySigner_read(ser_ref);
11498         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
11499         return (long)ret_conv;
11500 }
11501
11502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11503         LDKKeysManager this_ptr_conv;
11504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11505         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11506         KeysManager_free(this_ptr_conv);
11507 }
11508
11509 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) {
11510         unsigned char seed_arr[32];
11511         CHECK((*env)->GetArrayLength(env, seed) == 32);
11512         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
11513         unsigned char (*seed_ref)[32] = &seed_arr;
11514         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
11515         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11516         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11517         long ret_ref = (long)ret_var.inner;
11518         if (ret_var.is_owned) {
11519                 ret_ref |= 1;
11520         }
11521         return ret_ref;
11522 }
11523
11524 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) {
11525         LDKKeysManager this_arg_conv;
11526         this_arg_conv.inner = (void*)(this_arg & (~1));
11527         this_arg_conv.is_owned = false;
11528         unsigned char params_arr[32];
11529         CHECK((*env)->GetArrayLength(env, params) == 32);
11530         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
11531         unsigned char (*params_ref)[32] = &params_arr;
11532         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
11533         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11534         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11535         long ret_ref = (long)ret_var.inner;
11536         if (ret_var.is_owned) {
11537                 ret_ref |= 1;
11538         }
11539         return ret_ref;
11540 }
11541
11542 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) {
11543         LDKKeysManager this_arg_conv;
11544         this_arg_conv.inner = (void*)(this_arg & (~1));
11545         this_arg_conv.is_owned = false;
11546         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
11547         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
11548         if (descriptors_constr.datalen > 0)
11549                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
11550         else
11551                 descriptors_constr.data = NULL;
11552         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
11553         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
11554                 int64_t descriptors_conv_27 = descriptors_vals[b];
11555                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
11556                 FREE((void*)descriptors_conv_27);
11557                 descriptors_constr.data[b] = descriptors_conv_27_conv;
11558         }
11559         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
11560         LDKCVec_TxOutZ outputs_constr;
11561         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
11562         if (outputs_constr.datalen > 0)
11563                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
11564         else
11565                 outputs_constr.data = NULL;
11566         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
11567         for (size_t h = 0; h < outputs_constr.datalen; h++) {
11568                 int64_t outputs_conv_7 = outputs_vals[h];
11569                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
11570                 FREE((void*)outputs_conv_7);
11571                 outputs_constr.data[h] = outputs_conv_7_conv;
11572         }
11573         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
11574         LDKCVec_u8Z change_destination_script_ref;
11575         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
11576         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
11577         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
11578         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11579         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
11580         return (long)ret_conv;
11581 }
11582
11583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
11584         LDKKeysManager this_arg_conv;
11585         this_arg_conv.inner = (void*)(this_arg & (~1));
11586         this_arg_conv.is_owned = false;
11587         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
11588         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
11589         return (long)ret;
11590 }
11591
11592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11593         LDKChannelManager this_ptr_conv;
11594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11595         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11596         ChannelManager_free(this_ptr_conv);
11597 }
11598
11599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11600         LDKChannelDetails this_ptr_conv;
11601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11602         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11603         ChannelDetails_free(this_ptr_conv);
11604 }
11605
11606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11607         LDKChannelDetails this_ptr_conv;
11608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11609         this_ptr_conv.is_owned = false;
11610         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
11611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
11612         return ret_arr;
11613 }
11614
11615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11616         LDKChannelDetails this_ptr_conv;
11617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11618         this_ptr_conv.is_owned = false;
11619         LDKThirtyTwoBytes val_ref;
11620         CHECK((*env)->GetArrayLength(env, val) == 32);
11621         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
11622         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
11623 }
11624
11625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11626         LDKChannelDetails this_ptr_conv;
11627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11628         this_ptr_conv.is_owned = false;
11629         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
11631         return ret_arr;
11632 }
11633
11634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
11635         LDKChannelDetails this_ptr_conv;
11636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11637         this_ptr_conv.is_owned = false;
11638         LDKPublicKey val_ref;
11639         CHECK((*env)->GetArrayLength(env, val) == 33);
11640         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
11641         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
11642 }
11643
11644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
11645         LDKChannelDetails this_ptr_conv;
11646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11647         this_ptr_conv.is_owned = false;
11648         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
11649         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11650         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11651         long ret_ref = (long)ret_var.inner;
11652         if (ret_var.is_owned) {
11653                 ret_ref |= 1;
11654         }
11655         return ret_ref;
11656 }
11657
11658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11659         LDKChannelDetails this_ptr_conv;
11660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11661         this_ptr_conv.is_owned = false;
11662         LDKInitFeatures val_conv;
11663         val_conv.inner = (void*)(val & (~1));
11664         val_conv.is_owned = (val & 1) || (val == 0);
11665         val_conv = InitFeatures_clone(&val_conv);
11666         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
11667 }
11668
11669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
11670         LDKChannelDetails this_ptr_conv;
11671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11672         this_ptr_conv.is_owned = false;
11673         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
11674         return ret_val;
11675 }
11676
11677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11678         LDKChannelDetails this_ptr_conv;
11679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11680         this_ptr_conv.is_owned = false;
11681         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
11682 }
11683
11684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
11685         LDKChannelDetails this_ptr_conv;
11686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11687         this_ptr_conv.is_owned = false;
11688         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
11689         return ret_val;
11690 }
11691
11692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11693         LDKChannelDetails this_ptr_conv;
11694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11695         this_ptr_conv.is_owned = false;
11696         ChannelDetails_set_user_id(&this_ptr_conv, val);
11697 }
11698
11699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
11700         LDKChannelDetails this_ptr_conv;
11701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11702         this_ptr_conv.is_owned = false;
11703         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
11704         return ret_val;
11705 }
11706
11707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11708         LDKChannelDetails this_ptr_conv;
11709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11710         this_ptr_conv.is_owned = false;
11711         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
11712 }
11713
11714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
11715         LDKChannelDetails this_ptr_conv;
11716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11717         this_ptr_conv.is_owned = false;
11718         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
11719         return ret_val;
11720 }
11721
11722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
11723         LDKChannelDetails this_ptr_conv;
11724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11725         this_ptr_conv.is_owned = false;
11726         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
11727 }
11728
11729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr) {
11730         LDKChannelDetails this_ptr_conv;
11731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11732         this_ptr_conv.is_owned = false;
11733         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
11734         return ret_val;
11735 }
11736
11737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
11738         LDKChannelDetails this_ptr_conv;
11739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11740         this_ptr_conv.is_owned = false;
11741         ChannelDetails_set_is_live(&this_ptr_conv, val);
11742 }
11743
11744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11745         LDKChannelDetails orig_conv;
11746         orig_conv.inner = (void*)(orig & (~1));
11747         orig_conv.is_owned = false;
11748         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
11749         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11750         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11751         long ret_ref = (long)ret_var.inner;
11752         if (ret_var.is_owned) {
11753                 ret_ref |= 1;
11754         }
11755         return ret_ref;
11756 }
11757
11758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
11759         if ((this_ptr & 1) != 0) return;
11760         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
11761         FREE((void*)this_ptr);
11762         PaymentSendFailure_free(this_ptr_conv);
11763 }
11764
11765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11766         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
11767         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
11768         *ret_copy = PaymentSendFailure_clone(orig_conv);
11769         long ret_ref = (long)ret_copy;
11770         return ret_ref;
11771 }
11772
11773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv *env, jclass clz, jclass network, int64_t fee_est, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t keys_manager, int64_t config, int64_t current_blockchain_height) {
11774         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
11775         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
11776         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
11777                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11778                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
11779         }
11780         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
11781         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
11782                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11783                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
11784         }
11785         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
11786         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
11787                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11788                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
11789         }
11790         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11791         if (logger_conv.free == LDKLogger_JCalls_free) {
11792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11793                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11794         }
11795         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
11796         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
11797                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11798                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
11799         }
11800         LDKUserConfig config_conv;
11801         config_conv.inner = (void*)(config & (~1));
11802         config_conv.is_owned = (config & 1) || (config == 0);
11803         config_conv = UserConfig_clone(&config_conv);
11804         LDKChannelManager ret_var = ChannelManager_new(network_conv, fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, current_blockchain_height);
11805         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11806         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11807         long ret_ref = (long)ret_var.inner;
11808         if (ret_var.is_owned) {
11809                 ret_ref |= 1;
11810         }
11811         return ret_ref;
11812 }
11813
11814 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) {
11815         LDKChannelManager this_arg_conv;
11816         this_arg_conv.inner = (void*)(this_arg & (~1));
11817         this_arg_conv.is_owned = false;
11818         LDKPublicKey their_network_key_ref;
11819         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
11820         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
11821         LDKUserConfig override_config_conv;
11822         override_config_conv.inner = (void*)(override_config & (~1));
11823         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
11824         override_config_conv = UserConfig_clone(&override_config_conv);
11825         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11826         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
11827         return (long)ret_conv;
11828 }
11829
11830 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
11831         LDKChannelManager this_arg_conv;
11832         this_arg_conv.inner = (void*)(this_arg & (~1));
11833         this_arg_conv.is_owned = false;
11834         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
11835         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11836         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11837         for (size_t q = 0; q < ret_var.datalen; q++) {
11838                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11839                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11840                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11841                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
11842                 if (ret_conv_16_var.is_owned) {
11843                         ret_conv_16_ref |= 1;
11844                 }
11845                 ret_arr_ptr[q] = ret_conv_16_ref;
11846         }
11847         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11848         FREE(ret_var.data);
11849         return ret_arr;
11850 }
11851
11852 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
11853         LDKChannelManager this_arg_conv;
11854         this_arg_conv.inner = (void*)(this_arg & (~1));
11855         this_arg_conv.is_owned = false;
11856         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
11857         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11858         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11859         for (size_t q = 0; q < ret_var.datalen; q++) {
11860                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11861                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11862                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11863                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
11864                 if (ret_conv_16_var.is_owned) {
11865                         ret_conv_16_ref |= 1;
11866                 }
11867                 ret_arr_ptr[q] = ret_conv_16_ref;
11868         }
11869         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11870         FREE(ret_var.data);
11871         return ret_arr;
11872 }
11873
11874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
11875         LDKChannelManager this_arg_conv;
11876         this_arg_conv.inner = (void*)(this_arg & (~1));
11877         this_arg_conv.is_owned = false;
11878         unsigned char channel_id_arr[32];
11879         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
11880         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
11881         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
11882         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11883         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
11884         return (long)ret_conv;
11885 }
11886
11887 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) {
11888         LDKChannelManager this_arg_conv;
11889         this_arg_conv.inner = (void*)(this_arg & (~1));
11890         this_arg_conv.is_owned = false;
11891         unsigned char channel_id_arr[32];
11892         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
11893         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
11894         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
11895         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11896         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
11897         return (long)ret_conv;
11898 }
11899
11900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
11901         LDKChannelManager this_arg_conv;
11902         this_arg_conv.inner = (void*)(this_arg & (~1));
11903         this_arg_conv.is_owned = false;
11904         ChannelManager_force_close_all_channels(&this_arg_conv);
11905 }
11906
11907 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) {
11908         LDKChannelManager this_arg_conv;
11909         this_arg_conv.inner = (void*)(this_arg & (~1));
11910         this_arg_conv.is_owned = false;
11911         LDKRoute route_conv;
11912         route_conv.inner = (void*)(route & (~1));
11913         route_conv.is_owned = false;
11914         LDKThirtyTwoBytes payment_hash_ref;
11915         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
11916         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
11917         LDKThirtyTwoBytes payment_secret_ref;
11918         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
11919         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
11920         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11921         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
11922         return (long)ret_conv;
11923 }
11924
11925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int64_t funding_txo) {
11926         LDKChannelManager this_arg_conv;
11927         this_arg_conv.inner = (void*)(this_arg & (~1));
11928         this_arg_conv.is_owned = false;
11929         unsigned char temporary_channel_id_arr[32];
11930         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
11931         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
11932         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
11933         LDKOutPoint funding_txo_conv;
11934         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11935         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
11936         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
11937         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
11938 }
11939
11940 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) {
11941         LDKChannelManager this_arg_conv;
11942         this_arg_conv.inner = (void*)(this_arg & (~1));
11943         this_arg_conv.is_owned = false;
11944         LDKThreeBytes rgb_ref;
11945         CHECK((*env)->GetArrayLength(env, rgb) == 3);
11946         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
11947         LDKThirtyTwoBytes alias_ref;
11948         CHECK((*env)->GetArrayLength(env, alias) == 32);
11949         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
11950         LDKCVec_NetAddressZ addresses_constr;
11951         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
11952         if (addresses_constr.datalen > 0)
11953                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
11954         else
11955                 addresses_constr.data = NULL;
11956         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
11957         for (size_t m = 0; m < addresses_constr.datalen; m++) {
11958                 int64_t addresses_conv_12 = addresses_vals[m];
11959                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
11960                 FREE((void*)addresses_conv_12);
11961                 addresses_constr.data[m] = addresses_conv_12_conv;
11962         }
11963         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
11964         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
11965 }
11966
11967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
11968         LDKChannelManager this_arg_conv;
11969         this_arg_conv.inner = (void*)(this_arg & (~1));
11970         this_arg_conv.is_owned = false;
11971         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
11972 }
11973
11974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv *env, jclass clz, int64_t this_arg) {
11975         LDKChannelManager this_arg_conv;
11976         this_arg_conv.inner = (void*)(this_arg & (~1));
11977         this_arg_conv.is_owned = false;
11978         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
11979 }
11980
11981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
11982         LDKChannelManager this_arg_conv;
11983         this_arg_conv.inner = (void*)(this_arg & (~1));
11984         this_arg_conv.is_owned = false;
11985         unsigned char payment_hash_arr[32];
11986         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
11987         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
11988         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11989         LDKThirtyTwoBytes payment_secret_ref;
11990         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
11991         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
11992         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
11993         return ret_val;
11994 }
11995
11996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
11997         LDKChannelManager this_arg_conv;
11998         this_arg_conv.inner = (void*)(this_arg & (~1));
11999         this_arg_conv.is_owned = false;
12000         LDKThirtyTwoBytes payment_preimage_ref;
12001         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
12002         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
12003         LDKThirtyTwoBytes payment_secret_ref;
12004         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
12005         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
12006         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
12007         return ret_val;
12008 }
12009
12010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
12011         LDKChannelManager this_arg_conv;
12012         this_arg_conv.inner = (void*)(this_arg & (~1));
12013         this_arg_conv.is_owned = false;
12014         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
12016         return ret_arr;
12017 }
12018
12019 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) {
12020         LDKChannelManager this_arg_conv;
12021         this_arg_conv.inner = (void*)(this_arg & (~1));
12022         this_arg_conv.is_owned = false;
12023         LDKOutPoint funding_txo_conv;
12024         funding_txo_conv.inner = (void*)(funding_txo & (~1));
12025         funding_txo_conv.is_owned = false;
12026         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
12027 }
12028
12029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
12030         LDKChannelManager this_arg_conv;
12031         this_arg_conv.inner = (void*)(this_arg & (~1));
12032         this_arg_conv.is_owned = false;
12033         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
12034         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
12035         return (long)ret;
12036 }
12037
12038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
12039         LDKChannelManager this_arg_conv;
12040         this_arg_conv.inner = (void*)(this_arg & (~1));
12041         this_arg_conv.is_owned = false;
12042         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12043         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
12044         return (long)ret;
12045 }
12046
12047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
12048         LDKChannelManager this_arg_conv;
12049         this_arg_conv.inner = (void*)(this_arg & (~1));
12050         this_arg_conv.is_owned = false;
12051         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
12052         *ret = ChannelManager_as_Listen(&this_arg_conv);
12053         return (long)ret;
12054 }
12055
12056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
12057         LDKChannelManager this_arg_conv;
12058         this_arg_conv.inner = (void*)(this_arg & (~1));
12059         this_arg_conv.is_owned = false;
12060         unsigned char header_arr[80];
12061         CHECK((*env)->GetArrayLength(env, header) == 80);
12062         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12063         unsigned char (*header_ref)[80] = &header_arr;
12064         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12065         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12066         if (txdata_constr.datalen > 0)
12067                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12068         else
12069                 txdata_constr.data = NULL;
12070         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12071         for (size_t y = 0; y < txdata_constr.datalen; y++) {
12072                 int64_t txdata_conv_24 = txdata_vals[y];
12073                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
12074                 FREE((void*)txdata_conv_24);
12075                 txdata_constr.data[y] = txdata_conv_24_conv;
12076         }
12077         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12078         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
12079 }
12080
12081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header) {
12082         LDKChannelManager this_arg_conv;
12083         this_arg_conv.inner = (void*)(this_arg & (~1));
12084         this_arg_conv.is_owned = false;
12085         unsigned char header_arr[80];
12086         CHECK((*env)->GetArrayLength(env, header) == 80);
12087         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12088         unsigned char (*header_ref)[80] = &header_arr;
12089         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
12090 }
12091
12092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
12093         LDKChannelManager this_arg_conv;
12094         this_arg_conv.inner = (void*)(this_arg & (~1));
12095         this_arg_conv.is_owned = false;
12096         ChannelManager_await_persistable_update(&this_arg_conv);
12097 }
12098
12099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
12100         LDKChannelManager this_arg_conv;
12101         this_arg_conv.inner = (void*)(this_arg & (~1));
12102         this_arg_conv.is_owned = false;
12103         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12104         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
12105         return (long)ret;
12106 }
12107
12108 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
12109         LDKChannelManager obj_conv;
12110         obj_conv.inner = (void*)(obj & (~1));
12111         obj_conv.is_owned = false;
12112         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
12113         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12114         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12115         CVec_u8Z_free(ret_var);
12116         return ret_arr;
12117 }
12118
12119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12120         LDKChannelManagerReadArgs this_ptr_conv;
12121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12122         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12123         ChannelManagerReadArgs_free(this_ptr_conv);
12124 }
12125
12126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
12127         LDKChannelManagerReadArgs this_ptr_conv;
12128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12129         this_ptr_conv.is_owned = false;
12130         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
12131         return ret_ret;
12132 }
12133
12134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12135         LDKChannelManagerReadArgs this_ptr_conv;
12136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12137         this_ptr_conv.is_owned = false;
12138         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
12139         if (val_conv.free == LDKKeysInterface_JCalls_free) {
12140                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12141                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
12142         }
12143         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
12144 }
12145
12146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
12147         LDKChannelManagerReadArgs this_ptr_conv;
12148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12149         this_ptr_conv.is_owned = false;
12150         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
12151         return ret_ret;
12152 }
12153
12154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12155         LDKChannelManagerReadArgs this_ptr_conv;
12156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12157         this_ptr_conv.is_owned = false;
12158         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
12159         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
12160                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12161                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
12162         }
12163         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
12164 }
12165
12166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
12167         LDKChannelManagerReadArgs this_ptr_conv;
12168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12169         this_ptr_conv.is_owned = false;
12170         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
12171         return ret_ret;
12172 }
12173
12174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12175         LDKChannelManagerReadArgs this_ptr_conv;
12176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12177         this_ptr_conv.is_owned = false;
12178         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
12179         if (val_conv.free == LDKWatch_JCalls_free) {
12180                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12181                 LDKWatch_JCalls_clone(val_conv.this_arg);
12182         }
12183         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
12184 }
12185
12186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
12187         LDKChannelManagerReadArgs this_ptr_conv;
12188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12189         this_ptr_conv.is_owned = false;
12190         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
12191         return ret_ret;
12192 }
12193
12194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12195         LDKChannelManagerReadArgs this_ptr_conv;
12196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12197         this_ptr_conv.is_owned = false;
12198         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
12199         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
12200                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12201                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
12202         }
12203         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
12204 }
12205
12206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
12207         LDKChannelManagerReadArgs this_ptr_conv;
12208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12209         this_ptr_conv.is_owned = false;
12210         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
12211         return ret_ret;
12212 }
12213
12214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12215         LDKChannelManagerReadArgs this_ptr_conv;
12216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12217         this_ptr_conv.is_owned = false;
12218         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
12219         if (val_conv.free == LDKLogger_JCalls_free) {
12220                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12221                 LDKLogger_JCalls_clone(val_conv.this_arg);
12222         }
12223         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
12224 }
12225
12226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
12227         LDKChannelManagerReadArgs this_ptr_conv;
12228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12229         this_ptr_conv.is_owned = false;
12230         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
12231         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12232         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12233         long ret_ref = (long)ret_var.inner;
12234         if (ret_var.is_owned) {
12235                 ret_ref |= 1;
12236         }
12237         return ret_ref;
12238 }
12239
12240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12241         LDKChannelManagerReadArgs this_ptr_conv;
12242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12243         this_ptr_conv.is_owned = false;
12244         LDKUserConfig val_conv;
12245         val_conv.inner = (void*)(val & (~1));
12246         val_conv.is_owned = (val & 1) || (val == 0);
12247         val_conv = UserConfig_clone(&val_conv);
12248         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
12249 }
12250
12251 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) {
12252         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
12253         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
12254                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12255                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
12256         }
12257         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12258         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
12259                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12260                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
12261         }
12262         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
12263         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
12264                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12265                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
12266         }
12267         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
12268         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
12269                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12270                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
12271         }
12272         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12273         if (logger_conv.free == LDKLogger_JCalls_free) {
12274                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12275                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12276         }
12277         LDKUserConfig default_config_conv;
12278         default_config_conv.inner = (void*)(default_config & (~1));
12279         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
12280         default_config_conv = UserConfig_clone(&default_config_conv);
12281         LDKCVec_ChannelMonitorZ channel_monitors_constr;
12282         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
12283         if (channel_monitors_constr.datalen > 0)
12284                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
12285         else
12286                 channel_monitors_constr.data = NULL;
12287         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
12288         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
12289                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
12290                 LDKChannelMonitor channel_monitors_conv_16_conv;
12291                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
12292                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
12293                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
12294         }
12295         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
12296         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);
12297         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12298         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12299         long ret_ref = (long)ret_var.inner;
12300         if (ret_var.is_owned) {
12301                 ret_ref |= 1;
12302         }
12303         return ret_ref;
12304 }
12305
12306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
12307         LDKu8slice ser_ref;
12308         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
12309         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
12310         LDKChannelManagerReadArgs arg_conv;
12311         arg_conv.inner = (void*)(arg & (~1));
12312         arg_conv.is_owned = (arg & 1) || (arg == 0);
12313         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
12314         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12315         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
12316         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
12317         return (long)ret_conv;
12318 }
12319
12320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12321         LDKDecodeError this_ptr_conv;
12322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12323         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12324         DecodeError_free(this_ptr_conv);
12325 }
12326
12327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12328         LDKDecodeError orig_conv;
12329         orig_conv.inner = (void*)(orig & (~1));
12330         orig_conv.is_owned = false;
12331         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
12332         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12333         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12334         long ret_ref = (long)ret_var.inner;
12335         if (ret_var.is_owned) {
12336                 ret_ref |= 1;
12337         }
12338         return ret_ref;
12339 }
12340
12341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12342         LDKInit this_ptr_conv;
12343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12344         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12345         Init_free(this_ptr_conv);
12346 }
12347
12348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
12349         LDKInit this_ptr_conv;
12350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12351         this_ptr_conv.is_owned = false;
12352         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
12353         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12354         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12355         long ret_ref = (long)ret_var.inner;
12356         if (ret_var.is_owned) {
12357                 ret_ref |= 1;
12358         }
12359         return ret_ref;
12360 }
12361
12362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12363         LDKInit this_ptr_conv;
12364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12365         this_ptr_conv.is_owned = false;
12366         LDKInitFeatures val_conv;
12367         val_conv.inner = (void*)(val & (~1));
12368         val_conv.is_owned = (val & 1) || (val == 0);
12369         val_conv = InitFeatures_clone(&val_conv);
12370         Init_set_features(&this_ptr_conv, val_conv);
12371 }
12372
12373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
12374         LDKInitFeatures features_arg_conv;
12375         features_arg_conv.inner = (void*)(features_arg & (~1));
12376         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
12377         features_arg_conv = InitFeatures_clone(&features_arg_conv);
12378         LDKInit ret_var = Init_new(features_arg_conv);
12379         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12380         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12381         long ret_ref = (long)ret_var.inner;
12382         if (ret_var.is_owned) {
12383                 ret_ref |= 1;
12384         }
12385         return ret_ref;
12386 }
12387
12388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12389         LDKInit orig_conv;
12390         orig_conv.inner = (void*)(orig & (~1));
12391         orig_conv.is_owned = false;
12392         LDKInit ret_var = Init_clone(&orig_conv);
12393         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12394         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12395         long ret_ref = (long)ret_var.inner;
12396         if (ret_var.is_owned) {
12397                 ret_ref |= 1;
12398         }
12399         return ret_ref;
12400 }
12401
12402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12403         LDKErrorMessage this_ptr_conv;
12404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12405         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12406         ErrorMessage_free(this_ptr_conv);
12407 }
12408
12409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12410         LDKErrorMessage this_ptr_conv;
12411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12412         this_ptr_conv.is_owned = false;
12413         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12414         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
12415         return ret_arr;
12416 }
12417
12418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12419         LDKErrorMessage this_ptr_conv;
12420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12421         this_ptr_conv.is_owned = false;
12422         LDKThirtyTwoBytes val_ref;
12423         CHECK((*env)->GetArrayLength(env, val) == 32);
12424         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12425         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
12426 }
12427
12428 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
12429         LDKErrorMessage this_ptr_conv;
12430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12431         this_ptr_conv.is_owned = false;
12432         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
12433         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
12434         return _conv;
12435 }
12436
12437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12438         LDKErrorMessage this_ptr_conv;
12439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12440         this_ptr_conv.is_owned = false;
12441         LDKCVec_u8Z val_ref;
12442         val_ref.datalen = (*env)->GetArrayLength(env, val);
12443         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
12444         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
12445         ErrorMessage_set_data(&this_ptr_conv, val_ref);
12446 }
12447
12448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray data_arg) {
12449         LDKThirtyTwoBytes channel_id_arg_ref;
12450         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
12451         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
12452         LDKCVec_u8Z data_arg_ref;
12453         data_arg_ref.datalen = (*env)->GetArrayLength(env, data_arg);
12454         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
12455         (*env)->GetByteArrayRegion(env, data_arg, 0, data_arg_ref.datalen, data_arg_ref.data);
12456         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
12457         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12458         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12459         long ret_ref = (long)ret_var.inner;
12460         if (ret_var.is_owned) {
12461                 ret_ref |= 1;
12462         }
12463         return ret_ref;
12464 }
12465
12466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12467         LDKErrorMessage orig_conv;
12468         orig_conv.inner = (void*)(orig & (~1));
12469         orig_conv.is_owned = false;
12470         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
12471         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12472         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12473         long ret_ref = (long)ret_var.inner;
12474         if (ret_var.is_owned) {
12475                 ret_ref |= 1;
12476         }
12477         return ret_ref;
12478 }
12479
12480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12481         LDKPing this_ptr_conv;
12482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12483         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12484         Ping_free(this_ptr_conv);
12485 }
12486
12487 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
12488         LDKPing this_ptr_conv;
12489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12490         this_ptr_conv.is_owned = false;
12491         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
12492         return ret_val;
12493 }
12494
12495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12496         LDKPing this_ptr_conv;
12497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12498         this_ptr_conv.is_owned = false;
12499         Ping_set_ponglen(&this_ptr_conv, val);
12500 }
12501
12502 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
12503         LDKPing this_ptr_conv;
12504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12505         this_ptr_conv.is_owned = false;
12506         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
12507         return ret_val;
12508 }
12509
12510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12511         LDKPing this_ptr_conv;
12512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12513         this_ptr_conv.is_owned = false;
12514         Ping_set_byteslen(&this_ptr_conv, val);
12515 }
12516
12517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
12518         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
12519         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12520         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12521         long ret_ref = (long)ret_var.inner;
12522         if (ret_var.is_owned) {
12523                 ret_ref |= 1;
12524         }
12525         return ret_ref;
12526 }
12527
12528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12529         LDKPing orig_conv;
12530         orig_conv.inner = (void*)(orig & (~1));
12531         orig_conv.is_owned = false;
12532         LDKPing ret_var = Ping_clone(&orig_conv);
12533         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12534         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12535         long ret_ref = (long)ret_var.inner;
12536         if (ret_var.is_owned) {
12537                 ret_ref |= 1;
12538         }
12539         return ret_ref;
12540 }
12541
12542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12543         LDKPong this_ptr_conv;
12544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12545         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12546         Pong_free(this_ptr_conv);
12547 }
12548
12549 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
12550         LDKPong this_ptr_conv;
12551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12552         this_ptr_conv.is_owned = false;
12553         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
12554         return ret_val;
12555 }
12556
12557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12558         LDKPong this_ptr_conv;
12559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12560         this_ptr_conv.is_owned = false;
12561         Pong_set_byteslen(&this_ptr_conv, val);
12562 }
12563
12564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
12565         LDKPong ret_var = Pong_new(byteslen_arg);
12566         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12567         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12568         long ret_ref = (long)ret_var.inner;
12569         if (ret_var.is_owned) {
12570                 ret_ref |= 1;
12571         }
12572         return ret_ref;
12573 }
12574
12575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12576         LDKPong orig_conv;
12577         orig_conv.inner = (void*)(orig & (~1));
12578         orig_conv.is_owned = false;
12579         LDKPong ret_var = Pong_clone(&orig_conv);
12580         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12581         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12582         long ret_ref = (long)ret_var.inner;
12583         if (ret_var.is_owned) {
12584                 ret_ref |= 1;
12585         }
12586         return ret_ref;
12587 }
12588
12589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12590         LDKOpenChannel this_ptr_conv;
12591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12592         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12593         OpenChannel_free(this_ptr_conv);
12594 }
12595
12596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
12597         LDKOpenChannel this_ptr_conv;
12598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12599         this_ptr_conv.is_owned = false;
12600         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
12602         return ret_arr;
12603 }
12604
12605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12606         LDKOpenChannel this_ptr_conv;
12607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12608         this_ptr_conv.is_owned = false;
12609         LDKThirtyTwoBytes val_ref;
12610         CHECK((*env)->GetArrayLength(env, val) == 32);
12611         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12612         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
12613 }
12614
12615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12616         LDKOpenChannel this_ptr_conv;
12617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12618         this_ptr_conv.is_owned = false;
12619         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12620         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
12621         return ret_arr;
12622 }
12623
12624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12625         LDKOpenChannel this_ptr_conv;
12626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12627         this_ptr_conv.is_owned = false;
12628         LDKThirtyTwoBytes val_ref;
12629         CHECK((*env)->GetArrayLength(env, val) == 32);
12630         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12631         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
12632 }
12633
12634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12635         LDKOpenChannel this_ptr_conv;
12636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12637         this_ptr_conv.is_owned = false;
12638         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
12639         return ret_val;
12640 }
12641
12642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12643         LDKOpenChannel this_ptr_conv;
12644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12645         this_ptr_conv.is_owned = false;
12646         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
12647 }
12648
12649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12650         LDKOpenChannel this_ptr_conv;
12651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12652         this_ptr_conv.is_owned = false;
12653         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
12654         return ret_val;
12655 }
12656
12657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12658         LDKOpenChannel this_ptr_conv;
12659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12660         this_ptr_conv.is_owned = false;
12661         OpenChannel_set_push_msat(&this_ptr_conv, val);
12662 }
12663
12664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12665         LDKOpenChannel this_ptr_conv;
12666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12667         this_ptr_conv.is_owned = false;
12668         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
12669         return ret_val;
12670 }
12671
12672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12673         LDKOpenChannel this_ptr_conv;
12674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12675         this_ptr_conv.is_owned = false;
12676         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
12677 }
12678
12679 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) {
12680         LDKOpenChannel this_ptr_conv;
12681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12682         this_ptr_conv.is_owned = false;
12683         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
12684         return ret_val;
12685 }
12686
12687 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) {
12688         LDKOpenChannel this_ptr_conv;
12689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12690         this_ptr_conv.is_owned = false;
12691         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12692 }
12693
12694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12695         LDKOpenChannel this_ptr_conv;
12696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12697         this_ptr_conv.is_owned = false;
12698         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12699         return ret_val;
12700 }
12701
12702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12703         LDKOpenChannel this_ptr_conv;
12704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12705         this_ptr_conv.is_owned = false;
12706         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12707 }
12708
12709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12710         LDKOpenChannel this_ptr_conv;
12711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12712         this_ptr_conv.is_owned = false;
12713         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
12714         return ret_val;
12715 }
12716
12717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12718         LDKOpenChannel this_ptr_conv;
12719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12720         this_ptr_conv.is_owned = false;
12721         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12722 }
12723
12724 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
12725         LDKOpenChannel this_ptr_conv;
12726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12727         this_ptr_conv.is_owned = false;
12728         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
12729         return ret_val;
12730 }
12731
12732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
12733         LDKOpenChannel this_ptr_conv;
12734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12735         this_ptr_conv.is_owned = false;
12736         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
12737 }
12738
12739 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
12740         LDKOpenChannel this_ptr_conv;
12741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12742         this_ptr_conv.is_owned = false;
12743         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
12744         return ret_val;
12745 }
12746
12747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12748         LDKOpenChannel this_ptr_conv;
12749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12750         this_ptr_conv.is_owned = false;
12751         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
12752 }
12753
12754 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
12755         LDKOpenChannel this_ptr_conv;
12756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12757         this_ptr_conv.is_owned = false;
12758         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
12759         return ret_val;
12760 }
12761
12762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
12763         LDKOpenChannel this_ptr_conv;
12764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12765         this_ptr_conv.is_owned = false;
12766         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12767 }
12768
12769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
12770         LDKOpenChannel this_ptr_conv;
12771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12772         this_ptr_conv.is_owned = false;
12773         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12774         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
12775         return ret_arr;
12776 }
12777
12778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12779         LDKOpenChannel this_ptr_conv;
12780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12781         this_ptr_conv.is_owned = false;
12782         LDKPublicKey val_ref;
12783         CHECK((*env)->GetArrayLength(env, val) == 33);
12784         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12785         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12786 }
12787
12788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12789         LDKOpenChannel this_ptr_conv;
12790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12791         this_ptr_conv.is_owned = false;
12792         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12793         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
12794         return ret_arr;
12795 }
12796
12797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12798         LDKOpenChannel this_ptr_conv;
12799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12800         this_ptr_conv.is_owned = false;
12801         LDKPublicKey val_ref;
12802         CHECK((*env)->GetArrayLength(env, val) == 33);
12803         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12804         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
12805 }
12806
12807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
12808         LDKOpenChannel this_ptr_conv;
12809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12810         this_ptr_conv.is_owned = false;
12811         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
12813         return ret_arr;
12814 }
12815
12816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12817         LDKOpenChannel this_ptr_conv;
12818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12819         this_ptr_conv.is_owned = false;
12820         LDKPublicKey val_ref;
12821         CHECK((*env)->GetArrayLength(env, val) == 33);
12822         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12823         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
12824 }
12825
12826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12827         LDKOpenChannel this_ptr_conv;
12828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12829         this_ptr_conv.is_owned = false;
12830         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
12832         return ret_arr;
12833 }
12834
12835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12836         LDKOpenChannel this_ptr_conv;
12837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12838         this_ptr_conv.is_owned = false;
12839         LDKPublicKey val_ref;
12840         CHECK((*env)->GetArrayLength(env, val) == 33);
12841         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12842         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12843 }
12844
12845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
12846         LDKOpenChannel this_ptr_conv;
12847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12848         this_ptr_conv.is_owned = false;
12849         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
12851         return ret_arr;
12852 }
12853
12854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12855         LDKOpenChannel this_ptr_conv;
12856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12857         this_ptr_conv.is_owned = false;
12858         LDKPublicKey val_ref;
12859         CHECK((*env)->GetArrayLength(env, val) == 33);
12860         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12861         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
12862 }
12863
12864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
12865         LDKOpenChannel this_ptr_conv;
12866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12867         this_ptr_conv.is_owned = false;
12868         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12869         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
12870         return ret_arr;
12871 }
12872
12873 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) {
12874         LDKOpenChannel this_ptr_conv;
12875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12876         this_ptr_conv.is_owned = false;
12877         LDKPublicKey val_ref;
12878         CHECK((*env)->GetArrayLength(env, val) == 33);
12879         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
12880         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
12881 }
12882
12883 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
12884         LDKOpenChannel this_ptr_conv;
12885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12886         this_ptr_conv.is_owned = false;
12887         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
12888         return ret_val;
12889 }
12890
12891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
12892         LDKOpenChannel this_ptr_conv;
12893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12894         this_ptr_conv.is_owned = false;
12895         OpenChannel_set_channel_flags(&this_ptr_conv, val);
12896 }
12897
12898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12899         LDKOpenChannel orig_conv;
12900         orig_conv.inner = (void*)(orig & (~1));
12901         orig_conv.is_owned = false;
12902         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
12903         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12904         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12905         long ret_ref = (long)ret_var.inner;
12906         if (ret_var.is_owned) {
12907                 ret_ref |= 1;
12908         }
12909         return ret_ref;
12910 }
12911
12912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12913         LDKAcceptChannel this_ptr_conv;
12914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12915         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12916         AcceptChannel_free(this_ptr_conv);
12917 }
12918
12919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
12920         LDKAcceptChannel this_ptr_conv;
12921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12922         this_ptr_conv.is_owned = false;
12923         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
12924         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
12925         return ret_arr;
12926 }
12927
12928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
12929         LDKAcceptChannel this_ptr_conv;
12930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12931         this_ptr_conv.is_owned = false;
12932         LDKThirtyTwoBytes val_ref;
12933         CHECK((*env)->GetArrayLength(env, val) == 32);
12934         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
12935         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
12936 }
12937
12938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12939         LDKAcceptChannel this_ptr_conv;
12940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12941         this_ptr_conv.is_owned = false;
12942         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
12943         return ret_val;
12944 }
12945
12946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12947         LDKAcceptChannel this_ptr_conv;
12948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12949         this_ptr_conv.is_owned = false;
12950         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
12951 }
12952
12953 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) {
12954         LDKAcceptChannel this_ptr_conv;
12955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12956         this_ptr_conv.is_owned = false;
12957         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
12958         return ret_val;
12959 }
12960
12961 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) {
12962         LDKAcceptChannel this_ptr_conv;
12963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12964         this_ptr_conv.is_owned = false;
12965         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12966 }
12967
12968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
12969         LDKAcceptChannel this_ptr_conv;
12970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12971         this_ptr_conv.is_owned = false;
12972         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12973         return ret_val;
12974 }
12975
12976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12977         LDKAcceptChannel this_ptr_conv;
12978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12979         this_ptr_conv.is_owned = false;
12980         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12981 }
12982
12983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
12984         LDKAcceptChannel this_ptr_conv;
12985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12986         this_ptr_conv.is_owned = false;
12987         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
12988         return ret_val;
12989 }
12990
12991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
12992         LDKAcceptChannel this_ptr_conv;
12993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12994         this_ptr_conv.is_owned = false;
12995         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12996 }
12997
12998 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
12999         LDKAcceptChannel this_ptr_conv;
13000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13001         this_ptr_conv.is_owned = false;
13002         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
13003         return ret_val;
13004 }
13005
13006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13007         LDKAcceptChannel this_ptr_conv;
13008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13009         this_ptr_conv.is_owned = false;
13010         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
13011 }
13012
13013 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13014         LDKAcceptChannel this_ptr_conv;
13015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13016         this_ptr_conv.is_owned = false;
13017         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
13018         return ret_val;
13019 }
13020
13021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13022         LDKAcceptChannel this_ptr_conv;
13023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13024         this_ptr_conv.is_owned = false;
13025         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
13026 }
13027
13028 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13029         LDKAcceptChannel this_ptr_conv;
13030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13031         this_ptr_conv.is_owned = false;
13032         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
13033         return ret_val;
13034 }
13035
13036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13037         LDKAcceptChannel this_ptr_conv;
13038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13039         this_ptr_conv.is_owned = false;
13040         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
13041 }
13042
13043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13044         LDKAcceptChannel this_ptr_conv;
13045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13046         this_ptr_conv.is_owned = false;
13047         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
13049         return ret_arr;
13050 }
13051
13052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13053         LDKAcceptChannel this_ptr_conv;
13054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13055         this_ptr_conv.is_owned = false;
13056         LDKPublicKey val_ref;
13057         CHECK((*env)->GetArrayLength(env, val) == 33);
13058         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13059         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
13060 }
13061
13062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13063         LDKAcceptChannel this_ptr_conv;
13064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13065         this_ptr_conv.is_owned = false;
13066         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13067         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
13068         return ret_arr;
13069 }
13070
13071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13072         LDKAcceptChannel this_ptr_conv;
13073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13074         this_ptr_conv.is_owned = false;
13075         LDKPublicKey val_ref;
13076         CHECK((*env)->GetArrayLength(env, val) == 33);
13077         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13078         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
13079 }
13080
13081 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13082         LDKAcceptChannel this_ptr_conv;
13083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13084         this_ptr_conv.is_owned = false;
13085         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13086         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
13087         return ret_arr;
13088 }
13089
13090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13091         LDKAcceptChannel this_ptr_conv;
13092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13093         this_ptr_conv.is_owned = false;
13094         LDKPublicKey val_ref;
13095         CHECK((*env)->GetArrayLength(env, val) == 33);
13096         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13097         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
13098 }
13099
13100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13101         LDKAcceptChannel this_ptr_conv;
13102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13103         this_ptr_conv.is_owned = false;
13104         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
13106         return ret_arr;
13107 }
13108
13109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13110         LDKAcceptChannel this_ptr_conv;
13111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13112         this_ptr_conv.is_owned = false;
13113         LDKPublicKey val_ref;
13114         CHECK((*env)->GetArrayLength(env, val) == 33);
13115         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13116         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13117 }
13118
13119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13120         LDKAcceptChannel this_ptr_conv;
13121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13122         this_ptr_conv.is_owned = false;
13123         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13124         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
13125         return ret_arr;
13126 }
13127
13128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13129         LDKAcceptChannel this_ptr_conv;
13130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13131         this_ptr_conv.is_owned = false;
13132         LDKPublicKey val_ref;
13133         CHECK((*env)->GetArrayLength(env, val) == 33);
13134         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13135         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
13136 }
13137
13138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13139         LDKAcceptChannel this_ptr_conv;
13140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13141         this_ptr_conv.is_owned = false;
13142         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13143         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
13144         return ret_arr;
13145 }
13146
13147 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) {
13148         LDKAcceptChannel this_ptr_conv;
13149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13150         this_ptr_conv.is_owned = false;
13151         LDKPublicKey val_ref;
13152         CHECK((*env)->GetArrayLength(env, val) == 33);
13153         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13154         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
13155 }
13156
13157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13158         LDKAcceptChannel orig_conv;
13159         orig_conv.inner = (void*)(orig & (~1));
13160         orig_conv.is_owned = false;
13161         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
13162         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13163         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13164         long ret_ref = (long)ret_var.inner;
13165         if (ret_var.is_owned) {
13166                 ret_ref |= 1;
13167         }
13168         return ret_ref;
13169 }
13170
13171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13172         LDKFundingCreated this_ptr_conv;
13173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13174         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13175         FundingCreated_free(this_ptr_conv);
13176 }
13177
13178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13179         LDKFundingCreated this_ptr_conv;
13180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13181         this_ptr_conv.is_owned = false;
13182         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13183         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
13184         return ret_arr;
13185 }
13186
13187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13188         LDKFundingCreated this_ptr_conv;
13189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13190         this_ptr_conv.is_owned = false;
13191         LDKThirtyTwoBytes val_ref;
13192         CHECK((*env)->GetArrayLength(env, val) == 32);
13193         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13194         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
13195 }
13196
13197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
13198         LDKFundingCreated this_ptr_conv;
13199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13200         this_ptr_conv.is_owned = false;
13201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
13203         return ret_arr;
13204 }
13205
13206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13207         LDKFundingCreated this_ptr_conv;
13208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13209         this_ptr_conv.is_owned = false;
13210         LDKThirtyTwoBytes val_ref;
13211         CHECK((*env)->GetArrayLength(env, val) == 32);
13212         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13213         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
13214 }
13215
13216 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
13217         LDKFundingCreated this_ptr_conv;
13218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13219         this_ptr_conv.is_owned = false;
13220         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
13221         return ret_val;
13222 }
13223
13224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13225         LDKFundingCreated this_ptr_conv;
13226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13227         this_ptr_conv.is_owned = false;
13228         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
13229 }
13230
13231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13232         LDKFundingCreated this_ptr_conv;
13233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13234         this_ptr_conv.is_owned = false;
13235         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13236         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
13237         return ret_arr;
13238 }
13239
13240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13241         LDKFundingCreated this_ptr_conv;
13242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13243         this_ptr_conv.is_owned = false;
13244         LDKSignature val_ref;
13245         CHECK((*env)->GetArrayLength(env, val) == 64);
13246         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13247         FundingCreated_set_signature(&this_ptr_conv, val_ref);
13248 }
13249
13250 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) {
13251         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
13252         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
13253         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
13254         LDKThirtyTwoBytes funding_txid_arg_ref;
13255         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
13256         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
13257         LDKSignature signature_arg_ref;
13258         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13259         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13260         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
13261         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13262         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13263         long ret_ref = (long)ret_var.inner;
13264         if (ret_var.is_owned) {
13265                 ret_ref |= 1;
13266         }
13267         return ret_ref;
13268 }
13269
13270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13271         LDKFundingCreated orig_conv;
13272         orig_conv.inner = (void*)(orig & (~1));
13273         orig_conv.is_owned = false;
13274         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
13275         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13276         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13277         long ret_ref = (long)ret_var.inner;
13278         if (ret_var.is_owned) {
13279                 ret_ref |= 1;
13280         }
13281         return ret_ref;
13282 }
13283
13284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13285         LDKFundingSigned this_ptr_conv;
13286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13287         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13288         FundingSigned_free(this_ptr_conv);
13289 }
13290
13291 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13292         LDKFundingSigned this_ptr_conv;
13293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13294         this_ptr_conv.is_owned = false;
13295         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13296         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
13297         return ret_arr;
13298 }
13299
13300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13301         LDKFundingSigned this_ptr_conv;
13302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13303         this_ptr_conv.is_owned = false;
13304         LDKThirtyTwoBytes val_ref;
13305         CHECK((*env)->GetArrayLength(env, val) == 32);
13306         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13307         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
13308 }
13309
13310 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13311         LDKFundingSigned this_ptr_conv;
13312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13313         this_ptr_conv.is_owned = false;
13314         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13315         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
13316         return ret_arr;
13317 }
13318
13319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13320         LDKFundingSigned this_ptr_conv;
13321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13322         this_ptr_conv.is_owned = false;
13323         LDKSignature val_ref;
13324         CHECK((*env)->GetArrayLength(env, val) == 64);
13325         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13326         FundingSigned_set_signature(&this_ptr_conv, val_ref);
13327 }
13328
13329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
13330         LDKThirtyTwoBytes channel_id_arg_ref;
13331         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13332         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13333         LDKSignature signature_arg_ref;
13334         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13335         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13336         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
13337         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13338         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13339         long ret_ref = (long)ret_var.inner;
13340         if (ret_var.is_owned) {
13341                 ret_ref |= 1;
13342         }
13343         return ret_ref;
13344 }
13345
13346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13347         LDKFundingSigned orig_conv;
13348         orig_conv.inner = (void*)(orig & (~1));
13349         orig_conv.is_owned = false;
13350         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
13351         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13352         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13353         long ret_ref = (long)ret_var.inner;
13354         if (ret_var.is_owned) {
13355                 ret_ref |= 1;
13356         }
13357         return ret_ref;
13358 }
13359
13360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13361         LDKFundingLocked this_ptr_conv;
13362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13363         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13364         FundingLocked_free(this_ptr_conv);
13365 }
13366
13367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13368         LDKFundingLocked this_ptr_conv;
13369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13370         this_ptr_conv.is_owned = false;
13371         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13372         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
13373         return ret_arr;
13374 }
13375
13376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13377         LDKFundingLocked this_ptr_conv;
13378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13379         this_ptr_conv.is_owned = false;
13380         LDKThirtyTwoBytes val_ref;
13381         CHECK((*env)->GetArrayLength(env, val) == 32);
13382         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13383         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
13384 }
13385
13386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
13387         LDKFundingLocked this_ptr_conv;
13388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13389         this_ptr_conv.is_owned = false;
13390         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13391         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
13392         return ret_arr;
13393 }
13394
13395 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) {
13396         LDKFundingLocked this_ptr_conv;
13397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13398         this_ptr_conv.is_owned = false;
13399         LDKPublicKey val_ref;
13400         CHECK((*env)->GetArrayLength(env, val) == 33);
13401         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
13402         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
13403 }
13404
13405 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) {
13406         LDKThirtyTwoBytes channel_id_arg_ref;
13407         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13408         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13409         LDKPublicKey next_per_commitment_point_arg_ref;
13410         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
13411         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
13412         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
13413         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13414         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13415         long ret_ref = (long)ret_var.inner;
13416         if (ret_var.is_owned) {
13417                 ret_ref |= 1;
13418         }
13419         return ret_ref;
13420 }
13421
13422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13423         LDKFundingLocked orig_conv;
13424         orig_conv.inner = (void*)(orig & (~1));
13425         orig_conv.is_owned = false;
13426         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
13427         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13428         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13429         long ret_ref = (long)ret_var.inner;
13430         if (ret_var.is_owned) {
13431                 ret_ref |= 1;
13432         }
13433         return ret_ref;
13434 }
13435
13436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13437         LDKShutdown this_ptr_conv;
13438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13439         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13440         Shutdown_free(this_ptr_conv);
13441 }
13442
13443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13444         LDKShutdown this_ptr_conv;
13445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13446         this_ptr_conv.is_owned = false;
13447         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13448         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
13449         return ret_arr;
13450 }
13451
13452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13453         LDKShutdown this_ptr_conv;
13454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13455         this_ptr_conv.is_owned = false;
13456         LDKThirtyTwoBytes val_ref;
13457         CHECK((*env)->GetArrayLength(env, val) == 32);
13458         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13459         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
13460 }
13461
13462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13463         LDKShutdown this_ptr_conv;
13464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13465         this_ptr_conv.is_owned = false;
13466         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
13467         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13468         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13469         return ret_arr;
13470 }
13471
13472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13473         LDKShutdown this_ptr_conv;
13474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13475         this_ptr_conv.is_owned = false;
13476         LDKCVec_u8Z val_ref;
13477         val_ref.datalen = (*env)->GetArrayLength(env, val);
13478         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13479         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13480         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
13481 }
13482
13483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
13484         LDKThirtyTwoBytes channel_id_arg_ref;
13485         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13486         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13487         LDKCVec_u8Z scriptpubkey_arg_ref;
13488         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
13489         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13490         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
13491         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
13492         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13493         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13494         long ret_ref = (long)ret_var.inner;
13495         if (ret_var.is_owned) {
13496                 ret_ref |= 1;
13497         }
13498         return ret_ref;
13499 }
13500
13501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13502         LDKShutdown orig_conv;
13503         orig_conv.inner = (void*)(orig & (~1));
13504         orig_conv.is_owned = false;
13505         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
13506         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13507         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13508         long ret_ref = (long)ret_var.inner;
13509         if (ret_var.is_owned) {
13510                 ret_ref |= 1;
13511         }
13512         return ret_ref;
13513 }
13514
13515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13516         LDKClosingSigned this_ptr_conv;
13517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13518         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13519         ClosingSigned_free(this_ptr_conv);
13520 }
13521
13522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13523         LDKClosingSigned this_ptr_conv;
13524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13525         this_ptr_conv.is_owned = false;
13526         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13527         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
13528         return ret_arr;
13529 }
13530
13531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13532         LDKClosingSigned this_ptr_conv;
13533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13534         this_ptr_conv.is_owned = false;
13535         LDKThirtyTwoBytes val_ref;
13536         CHECK((*env)->GetArrayLength(env, val) == 32);
13537         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13538         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
13539 }
13540
13541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13542         LDKClosingSigned this_ptr_conv;
13543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13544         this_ptr_conv.is_owned = false;
13545         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
13546         return ret_val;
13547 }
13548
13549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13550         LDKClosingSigned this_ptr_conv;
13551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13552         this_ptr_conv.is_owned = false;
13553         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
13554 }
13555
13556 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13557         LDKClosingSigned this_ptr_conv;
13558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13559         this_ptr_conv.is_owned = false;
13560         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
13562         return ret_arr;
13563 }
13564
13565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13566         LDKClosingSigned this_ptr_conv;
13567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13568         this_ptr_conv.is_owned = false;
13569         LDKSignature val_ref;
13570         CHECK((*env)->GetArrayLength(env, val) == 64);
13571         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13572         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
13573 }
13574
13575 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) {
13576         LDKThirtyTwoBytes channel_id_arg_ref;
13577         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13578         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13579         LDKSignature signature_arg_ref;
13580         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13581         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13582         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
13583         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13584         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13585         long ret_ref = (long)ret_var.inner;
13586         if (ret_var.is_owned) {
13587                 ret_ref |= 1;
13588         }
13589         return ret_ref;
13590 }
13591
13592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13593         LDKClosingSigned orig_conv;
13594         orig_conv.inner = (void*)(orig & (~1));
13595         orig_conv.is_owned = false;
13596         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
13597         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13598         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13599         long ret_ref = (long)ret_var.inner;
13600         if (ret_var.is_owned) {
13601                 ret_ref |= 1;
13602         }
13603         return ret_ref;
13604 }
13605
13606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13607         LDKUpdateAddHTLC this_ptr_conv;
13608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13609         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13610         UpdateAddHTLC_free(this_ptr_conv);
13611 }
13612
13613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13614         LDKUpdateAddHTLC this_ptr_conv;
13615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13616         this_ptr_conv.is_owned = false;
13617         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13618         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
13619         return ret_arr;
13620 }
13621
13622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13623         LDKUpdateAddHTLC this_ptr_conv;
13624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13625         this_ptr_conv.is_owned = false;
13626         LDKThirtyTwoBytes val_ref;
13627         CHECK((*env)->GetArrayLength(env, val) == 32);
13628         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13629         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
13630 }
13631
13632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13633         LDKUpdateAddHTLC this_ptr_conv;
13634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13635         this_ptr_conv.is_owned = false;
13636         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
13637         return ret_val;
13638 }
13639
13640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13641         LDKUpdateAddHTLC this_ptr_conv;
13642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13643         this_ptr_conv.is_owned = false;
13644         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
13645 }
13646
13647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13648         LDKUpdateAddHTLC this_ptr_conv;
13649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13650         this_ptr_conv.is_owned = false;
13651         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
13652         return ret_val;
13653 }
13654
13655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13656         LDKUpdateAddHTLC this_ptr_conv;
13657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13658         this_ptr_conv.is_owned = false;
13659         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
13660 }
13661
13662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13663         LDKUpdateAddHTLC this_ptr_conv;
13664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13665         this_ptr_conv.is_owned = false;
13666         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
13668         return ret_arr;
13669 }
13670
13671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13672         LDKUpdateAddHTLC this_ptr_conv;
13673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13674         this_ptr_conv.is_owned = false;
13675         LDKThirtyTwoBytes val_ref;
13676         CHECK((*env)->GetArrayLength(env, val) == 32);
13677         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13678         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
13679 }
13680
13681 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
13682         LDKUpdateAddHTLC this_ptr_conv;
13683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13684         this_ptr_conv.is_owned = false;
13685         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
13686         return ret_val;
13687 }
13688
13689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13690         LDKUpdateAddHTLC this_ptr_conv;
13691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13692         this_ptr_conv.is_owned = false;
13693         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
13694 }
13695
13696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13697         LDKUpdateAddHTLC orig_conv;
13698         orig_conv.inner = (void*)(orig & (~1));
13699         orig_conv.is_owned = false;
13700         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
13701         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13702         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13703         long ret_ref = (long)ret_var.inner;
13704         if (ret_var.is_owned) {
13705                 ret_ref |= 1;
13706         }
13707         return ret_ref;
13708 }
13709
13710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13711         LDKUpdateFulfillHTLC this_ptr_conv;
13712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13713         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13714         UpdateFulfillHTLC_free(this_ptr_conv);
13715 }
13716
13717 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13718         LDKUpdateFulfillHTLC this_ptr_conv;
13719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13720         this_ptr_conv.is_owned = false;
13721         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13722         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
13723         return ret_arr;
13724 }
13725
13726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13727         LDKUpdateFulfillHTLC this_ptr_conv;
13728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13729         this_ptr_conv.is_owned = false;
13730         LDKThirtyTwoBytes val_ref;
13731         CHECK((*env)->GetArrayLength(env, val) == 32);
13732         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13733         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
13734 }
13735
13736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13737         LDKUpdateFulfillHTLC this_ptr_conv;
13738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13739         this_ptr_conv.is_owned = false;
13740         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
13741         return ret_val;
13742 }
13743
13744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13745         LDKUpdateFulfillHTLC this_ptr_conv;
13746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13747         this_ptr_conv.is_owned = false;
13748         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
13749 }
13750
13751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
13752         LDKUpdateFulfillHTLC this_ptr_conv;
13753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13754         this_ptr_conv.is_owned = false;
13755         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13756         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
13757         return ret_arr;
13758 }
13759
13760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13761         LDKUpdateFulfillHTLC this_ptr_conv;
13762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13763         this_ptr_conv.is_owned = false;
13764         LDKThirtyTwoBytes val_ref;
13765         CHECK((*env)->GetArrayLength(env, val) == 32);
13766         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13767         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
13768 }
13769
13770 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) {
13771         LDKThirtyTwoBytes channel_id_arg_ref;
13772         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13773         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13774         LDKThirtyTwoBytes payment_preimage_arg_ref;
13775         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
13776         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
13777         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
13778         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13779         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13780         long ret_ref = (long)ret_var.inner;
13781         if (ret_var.is_owned) {
13782                 ret_ref |= 1;
13783         }
13784         return ret_ref;
13785 }
13786
13787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13788         LDKUpdateFulfillHTLC orig_conv;
13789         orig_conv.inner = (void*)(orig & (~1));
13790         orig_conv.is_owned = false;
13791         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
13792         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13793         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13794         long ret_ref = (long)ret_var.inner;
13795         if (ret_var.is_owned) {
13796                 ret_ref |= 1;
13797         }
13798         return ret_ref;
13799 }
13800
13801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13802         LDKUpdateFailHTLC this_ptr_conv;
13803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13804         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13805         UpdateFailHTLC_free(this_ptr_conv);
13806 }
13807
13808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13809         LDKUpdateFailHTLC this_ptr_conv;
13810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13811         this_ptr_conv.is_owned = false;
13812         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13813         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
13814         return ret_arr;
13815 }
13816
13817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13818         LDKUpdateFailHTLC this_ptr_conv;
13819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13820         this_ptr_conv.is_owned = false;
13821         LDKThirtyTwoBytes val_ref;
13822         CHECK((*env)->GetArrayLength(env, val) == 32);
13823         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13824         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
13825 }
13826
13827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13828         LDKUpdateFailHTLC this_ptr_conv;
13829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13830         this_ptr_conv.is_owned = false;
13831         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
13832         return ret_val;
13833 }
13834
13835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13836         LDKUpdateFailHTLC this_ptr_conv;
13837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13838         this_ptr_conv.is_owned = false;
13839         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
13840 }
13841
13842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13843         LDKUpdateFailHTLC orig_conv;
13844         orig_conv.inner = (void*)(orig & (~1));
13845         orig_conv.is_owned = false;
13846         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
13847         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13848         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13849         long ret_ref = (long)ret_var.inner;
13850         if (ret_var.is_owned) {
13851                 ret_ref |= 1;
13852         }
13853         return ret_ref;
13854 }
13855
13856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13857         LDKUpdateFailMalformedHTLC this_ptr_conv;
13858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13859         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13860         UpdateFailMalformedHTLC_free(this_ptr_conv);
13861 }
13862
13863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13864         LDKUpdateFailMalformedHTLC this_ptr_conv;
13865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13866         this_ptr_conv.is_owned = false;
13867         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13868         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
13869         return ret_arr;
13870 }
13871
13872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13873         LDKUpdateFailMalformedHTLC this_ptr_conv;
13874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13875         this_ptr_conv.is_owned = false;
13876         LDKThirtyTwoBytes val_ref;
13877         CHECK((*env)->GetArrayLength(env, val) == 32);
13878         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13879         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
13880 }
13881
13882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13883         LDKUpdateFailMalformedHTLC this_ptr_conv;
13884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13885         this_ptr_conv.is_owned = false;
13886         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
13887         return ret_val;
13888 }
13889
13890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13891         LDKUpdateFailMalformedHTLC this_ptr_conv;
13892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13893         this_ptr_conv.is_owned = false;
13894         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
13895 }
13896
13897 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
13898         LDKUpdateFailMalformedHTLC this_ptr_conv;
13899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13900         this_ptr_conv.is_owned = false;
13901         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
13902         return ret_val;
13903 }
13904
13905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13906         LDKUpdateFailMalformedHTLC this_ptr_conv;
13907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13908         this_ptr_conv.is_owned = false;
13909         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
13910 }
13911
13912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13913         LDKUpdateFailMalformedHTLC orig_conv;
13914         orig_conv.inner = (void*)(orig & (~1));
13915         orig_conv.is_owned = false;
13916         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
13917         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13918         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13919         long ret_ref = (long)ret_var.inner;
13920         if (ret_var.is_owned) {
13921                 ret_ref |= 1;
13922         }
13923         return ret_ref;
13924 }
13925
13926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13927         LDKCommitmentSigned this_ptr_conv;
13928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13929         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13930         CommitmentSigned_free(this_ptr_conv);
13931 }
13932
13933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13934         LDKCommitmentSigned this_ptr_conv;
13935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13936         this_ptr_conv.is_owned = false;
13937         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13938         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
13939         return ret_arr;
13940 }
13941
13942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13943         LDKCommitmentSigned this_ptr_conv;
13944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13945         this_ptr_conv.is_owned = false;
13946         LDKThirtyTwoBytes val_ref;
13947         CHECK((*env)->GetArrayLength(env, val) == 32);
13948         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13949         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
13950 }
13951
13952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
13953         LDKCommitmentSigned this_ptr_conv;
13954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13955         this_ptr_conv.is_owned = false;
13956         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
13957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
13958         return ret_arr;
13959 }
13960
13961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13962         LDKCommitmentSigned this_ptr_conv;
13963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13964         this_ptr_conv.is_owned = false;
13965         LDKSignature val_ref;
13966         CHECK((*env)->GetArrayLength(env, val) == 64);
13967         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
13968         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
13969 }
13970
13971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
13972         LDKCommitmentSigned this_ptr_conv;
13973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13974         this_ptr_conv.is_owned = false;
13975         LDKCVec_SignatureZ val_constr;
13976         val_constr.datalen = (*env)->GetArrayLength(env, val);
13977         if (val_constr.datalen > 0)
13978                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13979         else
13980                 val_constr.data = NULL;
13981         for (size_t i = 0; i < val_constr.datalen; i++) {
13982                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
13983                 LDKSignature val_conv_8_ref;
13984                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
13985                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
13986                 val_constr.data[i] = val_conv_8_ref;
13987         }
13988         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
13989 }
13990
13991 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) {
13992         LDKThirtyTwoBytes channel_id_arg_ref;
13993         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
13994         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
13995         LDKSignature signature_arg_ref;
13996         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
13997         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
13998         LDKCVec_SignatureZ htlc_signatures_arg_constr;
13999         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
14000         if (htlc_signatures_arg_constr.datalen > 0)
14001                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14002         else
14003                 htlc_signatures_arg_constr.data = NULL;
14004         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
14005                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
14006                 LDKSignature htlc_signatures_arg_conv_8_ref;
14007                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
14008                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
14009                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
14010         }
14011         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
14012         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14013         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14014         long ret_ref = (long)ret_var.inner;
14015         if (ret_var.is_owned) {
14016                 ret_ref |= 1;
14017         }
14018         return ret_ref;
14019 }
14020
14021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14022         LDKCommitmentSigned orig_conv;
14023         orig_conv.inner = (void*)(orig & (~1));
14024         orig_conv.is_owned = false;
14025         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
14026         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14027         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14028         long ret_ref = (long)ret_var.inner;
14029         if (ret_var.is_owned) {
14030                 ret_ref |= 1;
14031         }
14032         return ret_ref;
14033 }
14034
14035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14036         LDKRevokeAndACK this_ptr_conv;
14037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14038         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14039         RevokeAndACK_free(this_ptr_conv);
14040 }
14041
14042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14043         LDKRevokeAndACK this_ptr_conv;
14044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14045         this_ptr_conv.is_owned = false;
14046         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
14048         return ret_arr;
14049 }
14050
14051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14052         LDKRevokeAndACK this_ptr_conv;
14053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14054         this_ptr_conv.is_owned = false;
14055         LDKThirtyTwoBytes val_ref;
14056         CHECK((*env)->GetArrayLength(env, val) == 32);
14057         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14058         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
14059 }
14060
14061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
14062         LDKRevokeAndACK this_ptr_conv;
14063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14064         this_ptr_conv.is_owned = false;
14065         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14066         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
14067         return ret_arr;
14068 }
14069
14070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14071         LDKRevokeAndACK this_ptr_conv;
14072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14073         this_ptr_conv.is_owned = false;
14074         LDKThirtyTwoBytes val_ref;
14075         CHECK((*env)->GetArrayLength(env, val) == 32);
14076         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14077         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
14078 }
14079
14080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14081         LDKRevokeAndACK this_ptr_conv;
14082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14083         this_ptr_conv.is_owned = false;
14084         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
14086         return ret_arr;
14087 }
14088
14089 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) {
14090         LDKRevokeAndACK this_ptr_conv;
14091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14092         this_ptr_conv.is_owned = false;
14093         LDKPublicKey val_ref;
14094         CHECK((*env)->GetArrayLength(env, val) == 33);
14095         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14096         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14097 }
14098
14099 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) {
14100         LDKThirtyTwoBytes channel_id_arg_ref;
14101         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14102         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14103         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
14104         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
14105         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
14106         LDKPublicKey next_per_commitment_point_arg_ref;
14107         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
14108         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
14109         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
14110         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14111         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14112         long ret_ref = (long)ret_var.inner;
14113         if (ret_var.is_owned) {
14114                 ret_ref |= 1;
14115         }
14116         return ret_ref;
14117 }
14118
14119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14120         LDKRevokeAndACK orig_conv;
14121         orig_conv.inner = (void*)(orig & (~1));
14122         orig_conv.is_owned = false;
14123         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
14124         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14125         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14126         long ret_ref = (long)ret_var.inner;
14127         if (ret_var.is_owned) {
14128                 ret_ref |= 1;
14129         }
14130         return ret_ref;
14131 }
14132
14133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14134         LDKUpdateFee this_ptr_conv;
14135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14136         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14137         UpdateFee_free(this_ptr_conv);
14138 }
14139
14140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14141         LDKUpdateFee this_ptr_conv;
14142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14143         this_ptr_conv.is_owned = false;
14144         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14145         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
14146         return ret_arr;
14147 }
14148
14149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14150         LDKUpdateFee this_ptr_conv;
14151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14152         this_ptr_conv.is_owned = false;
14153         LDKThirtyTwoBytes val_ref;
14154         CHECK((*env)->GetArrayLength(env, val) == 32);
14155         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14156         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
14157 }
14158
14159 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
14160         LDKUpdateFee this_ptr_conv;
14161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14162         this_ptr_conv.is_owned = false;
14163         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
14164         return ret_val;
14165 }
14166
14167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14168         LDKUpdateFee this_ptr_conv;
14169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14170         this_ptr_conv.is_owned = false;
14171         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
14172 }
14173
14174 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) {
14175         LDKThirtyTwoBytes channel_id_arg_ref;
14176         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14177         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14178         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
14179         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14180         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14181         long ret_ref = (long)ret_var.inner;
14182         if (ret_var.is_owned) {
14183                 ret_ref |= 1;
14184         }
14185         return ret_ref;
14186 }
14187
14188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14189         LDKUpdateFee orig_conv;
14190         orig_conv.inner = (void*)(orig & (~1));
14191         orig_conv.is_owned = false;
14192         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
14193         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14194         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14195         long ret_ref = (long)ret_var.inner;
14196         if (ret_var.is_owned) {
14197                 ret_ref |= 1;
14198         }
14199         return ret_ref;
14200 }
14201
14202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14203         LDKDataLossProtect this_ptr_conv;
14204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14205         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14206         DataLossProtect_free(this_ptr_conv);
14207 }
14208
14209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
14210         LDKDataLossProtect this_ptr_conv;
14211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14212         this_ptr_conv.is_owned = false;
14213         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14214         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
14215         return ret_arr;
14216 }
14217
14218 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) {
14219         LDKDataLossProtect this_ptr_conv;
14220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14221         this_ptr_conv.is_owned = false;
14222         LDKThirtyTwoBytes val_ref;
14223         CHECK((*env)->GetArrayLength(env, val) == 32);
14224         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14225         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
14226 }
14227
14228 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14229         LDKDataLossProtect this_ptr_conv;
14230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14231         this_ptr_conv.is_owned = false;
14232         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14233         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
14234         return ret_arr;
14235 }
14236
14237 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) {
14238         LDKDataLossProtect this_ptr_conv;
14239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14240         this_ptr_conv.is_owned = false;
14241         LDKPublicKey val_ref;
14242         CHECK((*env)->GetArrayLength(env, val) == 33);
14243         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14244         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
14245 }
14246
14247 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) {
14248         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
14249         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
14250         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
14251         LDKPublicKey my_current_per_commitment_point_arg_ref;
14252         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
14253         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
14254         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
14255         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14256         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14257         long ret_ref = (long)ret_var.inner;
14258         if (ret_var.is_owned) {
14259                 ret_ref |= 1;
14260         }
14261         return ret_ref;
14262 }
14263
14264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14265         LDKDataLossProtect orig_conv;
14266         orig_conv.inner = (void*)(orig & (~1));
14267         orig_conv.is_owned = false;
14268         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
14269         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14270         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14271         long ret_ref = (long)ret_var.inner;
14272         if (ret_var.is_owned) {
14273                 ret_ref |= 1;
14274         }
14275         return ret_ref;
14276 }
14277
14278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14279         LDKChannelReestablish this_ptr_conv;
14280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14281         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14282         ChannelReestablish_free(this_ptr_conv);
14283 }
14284
14285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14286         LDKChannelReestablish this_ptr_conv;
14287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14288         this_ptr_conv.is_owned = false;
14289         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
14291         return ret_arr;
14292 }
14293
14294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14295         LDKChannelReestablish this_ptr_conv;
14296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14297         this_ptr_conv.is_owned = false;
14298         LDKThirtyTwoBytes val_ref;
14299         CHECK((*env)->GetArrayLength(env, val) == 32);
14300         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14301         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
14302 }
14303
14304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
14305         LDKChannelReestablish this_ptr_conv;
14306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14307         this_ptr_conv.is_owned = false;
14308         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
14309         return ret_val;
14310 }
14311
14312 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) {
14313         LDKChannelReestablish this_ptr_conv;
14314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14315         this_ptr_conv.is_owned = false;
14316         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
14317 }
14318
14319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
14320         LDKChannelReestablish this_ptr_conv;
14321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14322         this_ptr_conv.is_owned = false;
14323         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
14324         return ret_val;
14325 }
14326
14327 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) {
14328         LDKChannelReestablish this_ptr_conv;
14329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14330         this_ptr_conv.is_owned = false;
14331         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
14332 }
14333
14334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14335         LDKChannelReestablish orig_conv;
14336         orig_conv.inner = (void*)(orig & (~1));
14337         orig_conv.is_owned = false;
14338         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
14339         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14340         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14341         long ret_ref = (long)ret_var.inner;
14342         if (ret_var.is_owned) {
14343                 ret_ref |= 1;
14344         }
14345         return ret_ref;
14346 }
14347
14348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14349         LDKAnnouncementSignatures this_ptr_conv;
14350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14351         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14352         AnnouncementSignatures_free(this_ptr_conv);
14353 }
14354
14355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14356         LDKAnnouncementSignatures this_ptr_conv;
14357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14358         this_ptr_conv.is_owned = false;
14359         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14360         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
14361         return ret_arr;
14362 }
14363
14364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14365         LDKAnnouncementSignatures this_ptr_conv;
14366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14367         this_ptr_conv.is_owned = false;
14368         LDKThirtyTwoBytes val_ref;
14369         CHECK((*env)->GetArrayLength(env, val) == 32);
14370         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14371         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
14372 }
14373
14374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14375         LDKAnnouncementSignatures this_ptr_conv;
14376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14377         this_ptr_conv.is_owned = false;
14378         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
14379         return ret_val;
14380 }
14381
14382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14383         LDKAnnouncementSignatures this_ptr_conv;
14384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14385         this_ptr_conv.is_owned = false;
14386         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
14387 }
14388
14389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14390         LDKAnnouncementSignatures this_ptr_conv;
14391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14392         this_ptr_conv.is_owned = false;
14393         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14394         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
14395         return ret_arr;
14396 }
14397
14398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14399         LDKAnnouncementSignatures this_ptr_conv;
14400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14401         this_ptr_conv.is_owned = false;
14402         LDKSignature val_ref;
14403         CHECK((*env)->GetArrayLength(env, val) == 64);
14404         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14405         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
14406 }
14407
14408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14409         LDKAnnouncementSignatures this_ptr_conv;
14410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14411         this_ptr_conv.is_owned = false;
14412         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14413         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
14414         return ret_arr;
14415 }
14416
14417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14418         LDKAnnouncementSignatures this_ptr_conv;
14419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14420         this_ptr_conv.is_owned = false;
14421         LDKSignature val_ref;
14422         CHECK((*env)->GetArrayLength(env, val) == 64);
14423         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14424         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
14425 }
14426
14427 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) {
14428         LDKThirtyTwoBytes channel_id_arg_ref;
14429         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
14430         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
14431         LDKSignature node_signature_arg_ref;
14432         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
14433         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
14434         LDKSignature bitcoin_signature_arg_ref;
14435         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
14436         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
14437         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
14438         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14439         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14440         long ret_ref = (long)ret_var.inner;
14441         if (ret_var.is_owned) {
14442                 ret_ref |= 1;
14443         }
14444         return ret_ref;
14445 }
14446
14447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14448         LDKAnnouncementSignatures orig_conv;
14449         orig_conv.inner = (void*)(orig & (~1));
14450         orig_conv.is_owned = false;
14451         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
14452         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14453         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14454         long ret_ref = (long)ret_var.inner;
14455         if (ret_var.is_owned) {
14456                 ret_ref |= 1;
14457         }
14458         return ret_ref;
14459 }
14460
14461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14462         if ((this_ptr & 1) != 0) return;
14463         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
14464         FREE((void*)this_ptr);
14465         NetAddress_free(this_ptr_conv);
14466 }
14467
14468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14469         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
14470         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
14471         *ret_copy = NetAddress_clone(orig_conv);
14472         long ret_ref = (long)ret_copy;
14473         return ret_ref;
14474 }
14475
14476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
14477         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
14478         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
14479         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14480         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14481         CVec_u8Z_free(ret_var);
14482         return ret_arr;
14483 }
14484
14485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14486         LDKu8slice ser_ref;
14487         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14488         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14489         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14490         *ret_conv = Result_read(ser_ref);
14491         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14492         return (long)ret_conv;
14493 }
14494
14495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14496         LDKUnsignedNodeAnnouncement this_ptr_conv;
14497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14498         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14499         UnsignedNodeAnnouncement_free(this_ptr_conv);
14500 }
14501
14502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
14503         LDKUnsignedNodeAnnouncement this_ptr_conv;
14504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14505         this_ptr_conv.is_owned = false;
14506         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
14507         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14508         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14509         long ret_ref = (long)ret_var.inner;
14510         if (ret_var.is_owned) {
14511                 ret_ref |= 1;
14512         }
14513         return ret_ref;
14514 }
14515
14516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14517         LDKUnsignedNodeAnnouncement this_ptr_conv;
14518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14519         this_ptr_conv.is_owned = false;
14520         LDKNodeFeatures val_conv;
14521         val_conv.inner = (void*)(val & (~1));
14522         val_conv.is_owned = (val & 1) || (val == 0);
14523         val_conv = NodeFeatures_clone(&val_conv);
14524         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
14525 }
14526
14527 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
14528         LDKUnsignedNodeAnnouncement this_ptr_conv;
14529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14530         this_ptr_conv.is_owned = false;
14531         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
14532         return ret_val;
14533 }
14534
14535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14536         LDKUnsignedNodeAnnouncement this_ptr_conv;
14537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14538         this_ptr_conv.is_owned = false;
14539         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
14540 }
14541
14542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14543         LDKUnsignedNodeAnnouncement this_ptr_conv;
14544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14545         this_ptr_conv.is_owned = false;
14546         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14547         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
14548         return ret_arr;
14549 }
14550
14551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14552         LDKUnsignedNodeAnnouncement this_ptr_conv;
14553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14554         this_ptr_conv.is_owned = false;
14555         LDKPublicKey val_ref;
14556         CHECK((*env)->GetArrayLength(env, val) == 33);
14557         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14558         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
14559 }
14560
14561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
14562         LDKUnsignedNodeAnnouncement this_ptr_conv;
14563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14564         this_ptr_conv.is_owned = false;
14565         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
14566         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
14567         return ret_arr;
14568 }
14569
14570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14571         LDKUnsignedNodeAnnouncement this_ptr_conv;
14572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14573         this_ptr_conv.is_owned = false;
14574         LDKThreeBytes val_ref;
14575         CHECK((*env)->GetArrayLength(env, val) == 3);
14576         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
14577         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
14578 }
14579
14580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
14581         LDKUnsignedNodeAnnouncement this_ptr_conv;
14582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14583         this_ptr_conv.is_owned = false;
14584         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
14586         return ret_arr;
14587 }
14588
14589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14590         LDKUnsignedNodeAnnouncement this_ptr_conv;
14591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14592         this_ptr_conv.is_owned = false;
14593         LDKThirtyTwoBytes val_ref;
14594         CHECK((*env)->GetArrayLength(env, val) == 32);
14595         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14596         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
14597 }
14598
14599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
14600         LDKUnsignedNodeAnnouncement this_ptr_conv;
14601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14602         this_ptr_conv.is_owned = false;
14603         LDKCVec_NetAddressZ val_constr;
14604         val_constr.datalen = (*env)->GetArrayLength(env, val);
14605         if (val_constr.datalen > 0)
14606                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14607         else
14608                 val_constr.data = NULL;
14609         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
14610         for (size_t m = 0; m < val_constr.datalen; m++) {
14611                 int64_t val_conv_12 = val_vals[m];
14612                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
14613                 FREE((void*)val_conv_12);
14614                 val_constr.data[m] = val_conv_12_conv;
14615         }
14616         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
14617         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
14618 }
14619
14620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14621         LDKUnsignedNodeAnnouncement orig_conv;
14622         orig_conv.inner = (void*)(orig & (~1));
14623         orig_conv.is_owned = false;
14624         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
14625         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14626         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14627         long ret_ref = (long)ret_var.inner;
14628         if (ret_var.is_owned) {
14629                 ret_ref |= 1;
14630         }
14631         return ret_ref;
14632 }
14633
14634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14635         LDKNodeAnnouncement this_ptr_conv;
14636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14637         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14638         NodeAnnouncement_free(this_ptr_conv);
14639 }
14640
14641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
14642         LDKNodeAnnouncement this_ptr_conv;
14643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14644         this_ptr_conv.is_owned = false;
14645         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14646         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
14647         return ret_arr;
14648 }
14649
14650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14651         LDKNodeAnnouncement this_ptr_conv;
14652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14653         this_ptr_conv.is_owned = false;
14654         LDKSignature val_ref;
14655         CHECK((*env)->GetArrayLength(env, val) == 64);
14656         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14657         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
14658 }
14659
14660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
14661         LDKNodeAnnouncement this_ptr_conv;
14662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14663         this_ptr_conv.is_owned = false;
14664         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
14665         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14666         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14667         long ret_ref = (long)ret_var.inner;
14668         if (ret_var.is_owned) {
14669                 ret_ref |= 1;
14670         }
14671         return ret_ref;
14672 }
14673
14674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14675         LDKNodeAnnouncement this_ptr_conv;
14676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14677         this_ptr_conv.is_owned = false;
14678         LDKUnsignedNodeAnnouncement val_conv;
14679         val_conv.inner = (void*)(val & (~1));
14680         val_conv.is_owned = (val & 1) || (val == 0);
14681         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
14682         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
14683 }
14684
14685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
14686         LDKSignature signature_arg_ref;
14687         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
14688         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
14689         LDKUnsignedNodeAnnouncement contents_arg_conv;
14690         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14691         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14692         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
14693         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
14694         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14695         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14696         long ret_ref = (long)ret_var.inner;
14697         if (ret_var.is_owned) {
14698                 ret_ref |= 1;
14699         }
14700         return ret_ref;
14701 }
14702
14703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14704         LDKNodeAnnouncement orig_conv;
14705         orig_conv.inner = (void*)(orig & (~1));
14706         orig_conv.is_owned = false;
14707         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
14708         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14709         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14710         long ret_ref = (long)ret_var.inner;
14711         if (ret_var.is_owned) {
14712                 ret_ref |= 1;
14713         }
14714         return ret_ref;
14715 }
14716
14717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14718         LDKUnsignedChannelAnnouncement this_ptr_conv;
14719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14720         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14721         UnsignedChannelAnnouncement_free(this_ptr_conv);
14722 }
14723
14724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
14725         LDKUnsignedChannelAnnouncement this_ptr_conv;
14726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14727         this_ptr_conv.is_owned = false;
14728         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
14729         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14730         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14731         long ret_ref = (long)ret_var.inner;
14732         if (ret_var.is_owned) {
14733                 ret_ref |= 1;
14734         }
14735         return ret_ref;
14736 }
14737
14738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14739         LDKUnsignedChannelAnnouncement this_ptr_conv;
14740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14741         this_ptr_conv.is_owned = false;
14742         LDKChannelFeatures val_conv;
14743         val_conv.inner = (void*)(val & (~1));
14744         val_conv.is_owned = (val & 1) || (val == 0);
14745         val_conv = ChannelFeatures_clone(&val_conv);
14746         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
14747 }
14748
14749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14750         LDKUnsignedChannelAnnouncement this_ptr_conv;
14751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14752         this_ptr_conv.is_owned = false;
14753         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14754         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
14755         return ret_arr;
14756 }
14757
14758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14759         LDKUnsignedChannelAnnouncement this_ptr_conv;
14760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14761         this_ptr_conv.is_owned = false;
14762         LDKThirtyTwoBytes val_ref;
14763         CHECK((*env)->GetArrayLength(env, val) == 32);
14764         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14765         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
14766 }
14767
14768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14769         LDKUnsignedChannelAnnouncement this_ptr_conv;
14770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14771         this_ptr_conv.is_owned = false;
14772         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
14773         return ret_val;
14774 }
14775
14776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14777         LDKUnsignedChannelAnnouncement this_ptr_conv;
14778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14779         this_ptr_conv.is_owned = false;
14780         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
14781 }
14782
14783 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
14784         LDKUnsignedChannelAnnouncement this_ptr_conv;
14785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14786         this_ptr_conv.is_owned = false;
14787         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14788         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
14789         return ret_arr;
14790 }
14791
14792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14793         LDKUnsignedChannelAnnouncement this_ptr_conv;
14794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14795         this_ptr_conv.is_owned = false;
14796         LDKPublicKey val_ref;
14797         CHECK((*env)->GetArrayLength(env, val) == 33);
14798         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14799         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
14800 }
14801
14802 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
14803         LDKUnsignedChannelAnnouncement this_ptr_conv;
14804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14805         this_ptr_conv.is_owned = false;
14806         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14807         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
14808         return ret_arr;
14809 }
14810
14811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14812         LDKUnsignedChannelAnnouncement this_ptr_conv;
14813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14814         this_ptr_conv.is_owned = false;
14815         LDKPublicKey val_ref;
14816         CHECK((*env)->GetArrayLength(env, val) == 33);
14817         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14818         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
14819 }
14820
14821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
14822         LDKUnsignedChannelAnnouncement this_ptr_conv;
14823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14824         this_ptr_conv.is_owned = false;
14825         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14826         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
14827         return ret_arr;
14828 }
14829
14830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14831         LDKUnsignedChannelAnnouncement this_ptr_conv;
14832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14833         this_ptr_conv.is_owned = false;
14834         LDKPublicKey val_ref;
14835         CHECK((*env)->GetArrayLength(env, val) == 33);
14836         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14837         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
14838 }
14839
14840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
14841         LDKUnsignedChannelAnnouncement this_ptr_conv;
14842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14843         this_ptr_conv.is_owned = false;
14844         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14845         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
14846         return ret_arr;
14847 }
14848
14849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14850         LDKUnsignedChannelAnnouncement this_ptr_conv;
14851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14852         this_ptr_conv.is_owned = false;
14853         LDKPublicKey val_ref;
14854         CHECK((*env)->GetArrayLength(env, val) == 33);
14855         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14856         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
14857 }
14858
14859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14860         LDKUnsignedChannelAnnouncement orig_conv;
14861         orig_conv.inner = (void*)(orig & (~1));
14862         orig_conv.is_owned = false;
14863         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
14864         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14865         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14866         long ret_ref = (long)ret_var.inner;
14867         if (ret_var.is_owned) {
14868                 ret_ref |= 1;
14869         }
14870         return ret_ref;
14871 }
14872
14873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14874         LDKChannelAnnouncement this_ptr_conv;
14875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14876         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14877         ChannelAnnouncement_free(this_ptr_conv);
14878 }
14879
14880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
14881         LDKChannelAnnouncement this_ptr_conv;
14882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14883         this_ptr_conv.is_owned = false;
14884         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14885         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
14886         return ret_arr;
14887 }
14888
14889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14890         LDKChannelAnnouncement this_ptr_conv;
14891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14892         this_ptr_conv.is_owned = false;
14893         LDKSignature val_ref;
14894         CHECK((*env)->GetArrayLength(env, val) == 64);
14895         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14896         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
14897 }
14898
14899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
14900         LDKChannelAnnouncement this_ptr_conv;
14901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14902         this_ptr_conv.is_owned = false;
14903         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14904         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
14905         return ret_arr;
14906 }
14907
14908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14909         LDKChannelAnnouncement this_ptr_conv;
14910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14911         this_ptr_conv.is_owned = false;
14912         LDKSignature val_ref;
14913         CHECK((*env)->GetArrayLength(env, val) == 64);
14914         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14915         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
14916 }
14917
14918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
14919         LDKChannelAnnouncement this_ptr_conv;
14920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14921         this_ptr_conv.is_owned = false;
14922         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
14924         return ret_arr;
14925 }
14926
14927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14928         LDKChannelAnnouncement this_ptr_conv;
14929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14930         this_ptr_conv.is_owned = false;
14931         LDKSignature val_ref;
14932         CHECK((*env)->GetArrayLength(env, val) == 64);
14933         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14934         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
14935 }
14936
14937 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
14938         LDKChannelAnnouncement this_ptr_conv;
14939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14940         this_ptr_conv.is_owned = false;
14941         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
14942         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
14943         return ret_arr;
14944 }
14945
14946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14947         LDKChannelAnnouncement this_ptr_conv;
14948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14949         this_ptr_conv.is_owned = false;
14950         LDKSignature val_ref;
14951         CHECK((*env)->GetArrayLength(env, val) == 64);
14952         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
14953         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
14954 }
14955
14956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
14957         LDKChannelAnnouncement this_ptr_conv;
14958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14959         this_ptr_conv.is_owned = false;
14960         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
14961         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14962         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14963         long ret_ref = (long)ret_var.inner;
14964         if (ret_var.is_owned) {
14965                 ret_ref |= 1;
14966         }
14967         return ret_ref;
14968 }
14969
14970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14971         LDKChannelAnnouncement this_ptr_conv;
14972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14973         this_ptr_conv.is_owned = false;
14974         LDKUnsignedChannelAnnouncement val_conv;
14975         val_conv.inner = (void*)(val & (~1));
14976         val_conv.is_owned = (val & 1) || (val == 0);
14977         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
14978         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
14979 }
14980
14981 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) {
14982         LDKSignature node_signature_1_arg_ref;
14983         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
14984         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
14985         LDKSignature node_signature_2_arg_ref;
14986         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
14987         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
14988         LDKSignature bitcoin_signature_1_arg_ref;
14989         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
14990         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
14991         LDKSignature bitcoin_signature_2_arg_ref;
14992         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
14993         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
14994         LDKUnsignedChannelAnnouncement contents_arg_conv;
14995         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14996         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14997         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
14998         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);
14999         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15000         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15001         long ret_ref = (long)ret_var.inner;
15002         if (ret_var.is_owned) {
15003                 ret_ref |= 1;
15004         }
15005         return ret_ref;
15006 }
15007
15008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15009         LDKChannelAnnouncement orig_conv;
15010         orig_conv.inner = (void*)(orig & (~1));
15011         orig_conv.is_owned = false;
15012         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
15013         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15014         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15015         long ret_ref = (long)ret_var.inner;
15016         if (ret_var.is_owned) {
15017                 ret_ref |= 1;
15018         }
15019         return ret_ref;
15020 }
15021
15022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15023         LDKUnsignedChannelUpdate this_ptr_conv;
15024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15025         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15026         UnsignedChannelUpdate_free(this_ptr_conv);
15027 }
15028
15029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15030         LDKUnsignedChannelUpdate this_ptr_conv;
15031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15032         this_ptr_conv.is_owned = false;
15033         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15034         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
15035         return ret_arr;
15036 }
15037
15038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15039         LDKUnsignedChannelUpdate this_ptr_conv;
15040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15041         this_ptr_conv.is_owned = false;
15042         LDKThirtyTwoBytes val_ref;
15043         CHECK((*env)->GetArrayLength(env, val) == 32);
15044         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15045         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
15046 }
15047
15048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15049         LDKUnsignedChannelUpdate this_ptr_conv;
15050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15051         this_ptr_conv.is_owned = false;
15052         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
15053         return ret_val;
15054 }
15055
15056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15057         LDKUnsignedChannelUpdate this_ptr_conv;
15058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15059         this_ptr_conv.is_owned = false;
15060         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
15061 }
15062
15063 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15064         LDKUnsignedChannelUpdate this_ptr_conv;
15065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15066         this_ptr_conv.is_owned = false;
15067         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
15068         return ret_val;
15069 }
15070
15071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15072         LDKUnsignedChannelUpdate this_ptr_conv;
15073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15074         this_ptr_conv.is_owned = false;
15075         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
15076 }
15077
15078 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
15079         LDKUnsignedChannelUpdate this_ptr_conv;
15080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15081         this_ptr_conv.is_owned = false;
15082         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
15083         return ret_val;
15084 }
15085
15086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
15087         LDKUnsignedChannelUpdate this_ptr_conv;
15088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15089         this_ptr_conv.is_owned = false;
15090         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
15091 }
15092
15093 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
15094         LDKUnsignedChannelUpdate this_ptr_conv;
15095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15096         this_ptr_conv.is_owned = false;
15097         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
15098         return ret_val;
15099 }
15100
15101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15102         LDKUnsignedChannelUpdate this_ptr_conv;
15103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15104         this_ptr_conv.is_owned = false;
15105         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
15106 }
15107
15108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15109         LDKUnsignedChannelUpdate this_ptr_conv;
15110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15111         this_ptr_conv.is_owned = false;
15112         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
15113         return ret_val;
15114 }
15115
15116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15117         LDKUnsignedChannelUpdate this_ptr_conv;
15118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15119         this_ptr_conv.is_owned = false;
15120         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
15121 }
15122
15123 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15124         LDKUnsignedChannelUpdate this_ptr_conv;
15125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15126         this_ptr_conv.is_owned = false;
15127         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
15128         return ret_val;
15129 }
15130
15131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15132         LDKUnsignedChannelUpdate this_ptr_conv;
15133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15134         this_ptr_conv.is_owned = false;
15135         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
15136 }
15137
15138 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
15139         LDKUnsignedChannelUpdate this_ptr_conv;
15140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15141         this_ptr_conv.is_owned = false;
15142         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
15143         return ret_val;
15144 }
15145
15146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15147         LDKUnsignedChannelUpdate this_ptr_conv;
15148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15149         this_ptr_conv.is_owned = false;
15150         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
15151 }
15152
15153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15154         LDKUnsignedChannelUpdate orig_conv;
15155         orig_conv.inner = (void*)(orig & (~1));
15156         orig_conv.is_owned = false;
15157         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
15158         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15159         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15160         long ret_ref = (long)ret_var.inner;
15161         if (ret_var.is_owned) {
15162                 ret_ref |= 1;
15163         }
15164         return ret_ref;
15165 }
15166
15167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15168         LDKChannelUpdate this_ptr_conv;
15169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15170         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15171         ChannelUpdate_free(this_ptr_conv);
15172 }
15173
15174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
15175         LDKChannelUpdate this_ptr_conv;
15176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15177         this_ptr_conv.is_owned = false;
15178         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
15179         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
15180         return ret_arr;
15181 }
15182
15183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15184         LDKChannelUpdate this_ptr_conv;
15185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15186         this_ptr_conv.is_owned = false;
15187         LDKSignature val_ref;
15188         CHECK((*env)->GetArrayLength(env, val) == 64);
15189         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
15190         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
15191 }
15192
15193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
15194         LDKChannelUpdate this_ptr_conv;
15195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15196         this_ptr_conv.is_owned = false;
15197         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
15198         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15199         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15200         long ret_ref = (long)ret_var.inner;
15201         if (ret_var.is_owned) {
15202                 ret_ref |= 1;
15203         }
15204         return ret_ref;
15205 }
15206
15207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15208         LDKChannelUpdate this_ptr_conv;
15209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15210         this_ptr_conv.is_owned = false;
15211         LDKUnsignedChannelUpdate val_conv;
15212         val_conv.inner = (void*)(val & (~1));
15213         val_conv.is_owned = (val & 1) || (val == 0);
15214         val_conv = UnsignedChannelUpdate_clone(&val_conv);
15215         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
15216 }
15217
15218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
15219         LDKSignature signature_arg_ref;
15220         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
15221         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
15222         LDKUnsignedChannelUpdate contents_arg_conv;
15223         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15224         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15225         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
15226         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
15227         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15228         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15229         long ret_ref = (long)ret_var.inner;
15230         if (ret_var.is_owned) {
15231                 ret_ref |= 1;
15232         }
15233         return ret_ref;
15234 }
15235
15236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15237         LDKChannelUpdate orig_conv;
15238         orig_conv.inner = (void*)(orig & (~1));
15239         orig_conv.is_owned = false;
15240         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
15241         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15242         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15243         long ret_ref = (long)ret_var.inner;
15244         if (ret_var.is_owned) {
15245                 ret_ref |= 1;
15246         }
15247         return ret_ref;
15248 }
15249
15250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15251         LDKQueryChannelRange this_ptr_conv;
15252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15253         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15254         QueryChannelRange_free(this_ptr_conv);
15255 }
15256
15257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15258         LDKQueryChannelRange this_ptr_conv;
15259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15260         this_ptr_conv.is_owned = false;
15261         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
15263         return ret_arr;
15264 }
15265
15266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15267         LDKQueryChannelRange this_ptr_conv;
15268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15269         this_ptr_conv.is_owned = false;
15270         LDKThirtyTwoBytes val_ref;
15271         CHECK((*env)->GetArrayLength(env, val) == 32);
15272         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15273         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15274 }
15275
15276 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
15277         LDKQueryChannelRange this_ptr_conv;
15278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15279         this_ptr_conv.is_owned = false;
15280         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
15281         return ret_val;
15282 }
15283
15284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15285         LDKQueryChannelRange this_ptr_conv;
15286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15287         this_ptr_conv.is_owned = false;
15288         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
15289 }
15290
15291 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
15292         LDKQueryChannelRange this_ptr_conv;
15293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15294         this_ptr_conv.is_owned = false;
15295         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
15296         return ret_val;
15297 }
15298
15299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15300         LDKQueryChannelRange this_ptr_conv;
15301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15302         this_ptr_conv.is_owned = false;
15303         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
15304 }
15305
15306 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) {
15307         LDKThirtyTwoBytes chain_hash_arg_ref;
15308         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15309         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15310         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
15311         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15312         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15313         long ret_ref = (long)ret_var.inner;
15314         if (ret_var.is_owned) {
15315                 ret_ref |= 1;
15316         }
15317         return ret_ref;
15318 }
15319
15320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15321         LDKQueryChannelRange orig_conv;
15322         orig_conv.inner = (void*)(orig & (~1));
15323         orig_conv.is_owned = false;
15324         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
15325         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15326         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15327         long ret_ref = (long)ret_var.inner;
15328         if (ret_var.is_owned) {
15329                 ret_ref |= 1;
15330         }
15331         return ret_ref;
15332 }
15333
15334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15335         LDKReplyChannelRange this_ptr_conv;
15336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15337         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15338         ReplyChannelRange_free(this_ptr_conv);
15339 }
15340
15341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15342         LDKReplyChannelRange this_ptr_conv;
15343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15344         this_ptr_conv.is_owned = false;
15345         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15346         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
15347         return ret_arr;
15348 }
15349
15350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15351         LDKReplyChannelRange this_ptr_conv;
15352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15353         this_ptr_conv.is_owned = false;
15354         LDKThirtyTwoBytes val_ref;
15355         CHECK((*env)->GetArrayLength(env, val) == 32);
15356         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15357         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15358 }
15359
15360 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
15361         LDKReplyChannelRange this_ptr_conv;
15362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15363         this_ptr_conv.is_owned = false;
15364         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
15365         return ret_val;
15366 }
15367
15368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15369         LDKReplyChannelRange this_ptr_conv;
15370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15371         this_ptr_conv.is_owned = false;
15372         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
15373 }
15374
15375 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
15376         LDKReplyChannelRange this_ptr_conv;
15377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15378         this_ptr_conv.is_owned = false;
15379         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
15380         return ret_val;
15381 }
15382
15383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15384         LDKReplyChannelRange this_ptr_conv;
15385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15386         this_ptr_conv.is_owned = false;
15387         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
15388 }
15389
15390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
15391         LDKReplyChannelRange this_ptr_conv;
15392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15393         this_ptr_conv.is_owned = false;
15394         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
15395         return ret_val;
15396 }
15397
15398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15399         LDKReplyChannelRange this_ptr_conv;
15400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15401         this_ptr_conv.is_owned = false;
15402         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
15403 }
15404
15405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15406         LDKReplyChannelRange this_ptr_conv;
15407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15408         this_ptr_conv.is_owned = false;
15409         LDKCVec_u64Z val_constr;
15410         val_constr.datalen = (*env)->GetArrayLength(env, val);
15411         if (val_constr.datalen > 0)
15412                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15413         else
15414                 val_constr.data = NULL;
15415         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15416         for (size_t g = 0; g < val_constr.datalen; g++) {
15417                 int64_t val_conv_6 = val_vals[g];
15418                 val_constr.data[g] = val_conv_6;
15419         }
15420         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15421         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
15422 }
15423
15424 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) {
15425         LDKThirtyTwoBytes chain_hash_arg_ref;
15426         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15427         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15428         LDKCVec_u64Z short_channel_ids_arg_constr;
15429         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
15430         if (short_channel_ids_arg_constr.datalen > 0)
15431                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15432         else
15433                 short_channel_ids_arg_constr.data = NULL;
15434         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
15435         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
15436                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
15437                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
15438         }
15439         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
15440         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
15441         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15442         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15443         long ret_ref = (long)ret_var.inner;
15444         if (ret_var.is_owned) {
15445                 ret_ref |= 1;
15446         }
15447         return ret_ref;
15448 }
15449
15450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15451         LDKReplyChannelRange orig_conv;
15452         orig_conv.inner = (void*)(orig & (~1));
15453         orig_conv.is_owned = false;
15454         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
15455         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15456         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15457         long ret_ref = (long)ret_var.inner;
15458         if (ret_var.is_owned) {
15459                 ret_ref |= 1;
15460         }
15461         return ret_ref;
15462 }
15463
15464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15465         LDKQueryShortChannelIds this_ptr_conv;
15466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15467         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15468         QueryShortChannelIds_free(this_ptr_conv);
15469 }
15470
15471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15472         LDKQueryShortChannelIds this_ptr_conv;
15473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15474         this_ptr_conv.is_owned = false;
15475         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15476         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
15477         return ret_arr;
15478 }
15479
15480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15481         LDKQueryShortChannelIds this_ptr_conv;
15482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15483         this_ptr_conv.is_owned = false;
15484         LDKThirtyTwoBytes val_ref;
15485         CHECK((*env)->GetArrayLength(env, val) == 32);
15486         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15487         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
15488 }
15489
15490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15491         LDKQueryShortChannelIds this_ptr_conv;
15492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15493         this_ptr_conv.is_owned = false;
15494         LDKCVec_u64Z val_constr;
15495         val_constr.datalen = (*env)->GetArrayLength(env, val);
15496         if (val_constr.datalen > 0)
15497                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15498         else
15499                 val_constr.data = NULL;
15500         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15501         for (size_t g = 0; g < val_constr.datalen; g++) {
15502                 int64_t val_conv_6 = val_vals[g];
15503                 val_constr.data[g] = val_conv_6;
15504         }
15505         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15506         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
15507 }
15508
15509 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) {
15510         LDKThirtyTwoBytes chain_hash_arg_ref;
15511         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15512         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15513         LDKCVec_u64Z short_channel_ids_arg_constr;
15514         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
15515         if (short_channel_ids_arg_constr.datalen > 0)
15516                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15517         else
15518                 short_channel_ids_arg_constr.data = NULL;
15519         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
15520         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
15521                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
15522                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
15523         }
15524         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
15525         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
15526         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15527         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15528         long ret_ref = (long)ret_var.inner;
15529         if (ret_var.is_owned) {
15530                 ret_ref |= 1;
15531         }
15532         return ret_ref;
15533 }
15534
15535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15536         LDKQueryShortChannelIds orig_conv;
15537         orig_conv.inner = (void*)(orig & (~1));
15538         orig_conv.is_owned = false;
15539         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
15540         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15541         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15542         long ret_ref = (long)ret_var.inner;
15543         if (ret_var.is_owned) {
15544                 ret_ref |= 1;
15545         }
15546         return ret_ref;
15547 }
15548
15549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15550         LDKReplyShortChannelIdsEnd this_ptr_conv;
15551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15552         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15553         ReplyShortChannelIdsEnd_free(this_ptr_conv);
15554 }
15555
15556 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15557         LDKReplyShortChannelIdsEnd 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, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
15562         return ret_arr;
15563 }
15564
15565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15566         LDKReplyShortChannelIdsEnd this_ptr_conv;
15567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15568         this_ptr_conv.is_owned = false;
15569         LDKThirtyTwoBytes val_ref;
15570         CHECK((*env)->GetArrayLength(env, val) == 32);
15571         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15572         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
15573 }
15574
15575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
15576         LDKReplyShortChannelIdsEnd this_ptr_conv;
15577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15578         this_ptr_conv.is_owned = false;
15579         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
15580         return ret_val;
15581 }
15582
15583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15584         LDKReplyShortChannelIdsEnd this_ptr_conv;
15585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15586         this_ptr_conv.is_owned = false;
15587         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
15588 }
15589
15590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
15591         LDKThirtyTwoBytes chain_hash_arg_ref;
15592         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15593         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15594         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
15595         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15596         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15597         long ret_ref = (long)ret_var.inner;
15598         if (ret_var.is_owned) {
15599                 ret_ref |= 1;
15600         }
15601         return ret_ref;
15602 }
15603
15604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15605         LDKReplyShortChannelIdsEnd orig_conv;
15606         orig_conv.inner = (void*)(orig & (~1));
15607         orig_conv.is_owned = false;
15608         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
15609         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15610         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15611         long ret_ref = (long)ret_var.inner;
15612         if (ret_var.is_owned) {
15613                 ret_ref |= 1;
15614         }
15615         return ret_ref;
15616 }
15617
15618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15619         LDKGossipTimestampFilter this_ptr_conv;
15620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15621         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15622         GossipTimestampFilter_free(this_ptr_conv);
15623 }
15624
15625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
15626         LDKGossipTimestampFilter this_ptr_conv;
15627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15628         this_ptr_conv.is_owned = false;
15629         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
15631         return ret_arr;
15632 }
15633
15634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15635         LDKGossipTimestampFilter this_ptr_conv;
15636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15637         this_ptr_conv.is_owned = false;
15638         LDKThirtyTwoBytes val_ref;
15639         CHECK((*env)->GetArrayLength(env, val) == 32);
15640         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15641         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
15642 }
15643
15644 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
15645         LDKGossipTimestampFilter this_ptr_conv;
15646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15647         this_ptr_conv.is_owned = false;
15648         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
15649         return ret_val;
15650 }
15651
15652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15653         LDKGossipTimestampFilter this_ptr_conv;
15654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15655         this_ptr_conv.is_owned = false;
15656         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
15657 }
15658
15659 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
15660         LDKGossipTimestampFilter this_ptr_conv;
15661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15662         this_ptr_conv.is_owned = false;
15663         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
15664         return ret_val;
15665 }
15666
15667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
15668         LDKGossipTimestampFilter this_ptr_conv;
15669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15670         this_ptr_conv.is_owned = false;
15671         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
15672 }
15673
15674 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) {
15675         LDKThirtyTwoBytes chain_hash_arg_ref;
15676         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
15677         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
15678         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
15679         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15680         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15681         long ret_ref = (long)ret_var.inner;
15682         if (ret_var.is_owned) {
15683                 ret_ref |= 1;
15684         }
15685         return ret_ref;
15686 }
15687
15688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15689         LDKGossipTimestampFilter orig_conv;
15690         orig_conv.inner = (void*)(orig & (~1));
15691         orig_conv.is_owned = false;
15692         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
15693         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15694         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15695         long ret_ref = (long)ret_var.inner;
15696         if (ret_var.is_owned) {
15697                 ret_ref |= 1;
15698         }
15699         return ret_ref;
15700 }
15701
15702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15703         if ((this_ptr & 1) != 0) return;
15704         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
15705         FREE((void*)this_ptr);
15706         ErrorAction_free(this_ptr_conv);
15707 }
15708
15709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15710         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
15711         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
15712         *ret_copy = ErrorAction_clone(orig_conv);
15713         long ret_ref = (long)ret_copy;
15714         return ret_ref;
15715 }
15716
15717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15718         LDKLightningError this_ptr_conv;
15719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15720         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15721         LightningError_free(this_ptr_conv);
15722 }
15723
15724 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
15725         LDKLightningError this_ptr_conv;
15726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15727         this_ptr_conv.is_owned = false;
15728         LDKStr _str = LightningError_get_err(&this_ptr_conv);
15729         jstring _conv = str_ref_to_java(env, _str.chars, _str.len);
15730         return _conv;
15731 }
15732
15733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15734         LDKLightningError this_ptr_conv;
15735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15736         this_ptr_conv.is_owned = false;
15737         LDKCVec_u8Z val_ref;
15738         val_ref.datalen = (*env)->GetArrayLength(env, val);
15739         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
15740         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
15741         LightningError_set_err(&this_ptr_conv, val_ref);
15742 }
15743
15744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
15745         LDKLightningError this_ptr_conv;
15746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15747         this_ptr_conv.is_owned = false;
15748         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
15749         *ret_copy = LightningError_get_action(&this_ptr_conv);
15750         long ret_ref = (long)ret_copy;
15751         return ret_ref;
15752 }
15753
15754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15755         LDKLightningError this_ptr_conv;
15756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15757         this_ptr_conv.is_owned = false;
15758         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
15759         FREE((void*)val);
15760         LightningError_set_action(&this_ptr_conv, val_conv);
15761 }
15762
15763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, int8_tArray err_arg, int64_t action_arg) {
15764         LDKCVec_u8Z err_arg_ref;
15765         err_arg_ref.datalen = (*env)->GetArrayLength(env, err_arg);
15766         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
15767         (*env)->GetByteArrayRegion(env, err_arg, 0, err_arg_ref.datalen, err_arg_ref.data);
15768         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
15769         FREE((void*)action_arg);
15770         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
15771         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15772         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15773         long ret_ref = (long)ret_var.inner;
15774         if (ret_var.is_owned) {
15775                 ret_ref |= 1;
15776         }
15777         return ret_ref;
15778 }
15779
15780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15781         LDKLightningError orig_conv;
15782         orig_conv.inner = (void*)(orig & (~1));
15783         orig_conv.is_owned = false;
15784         LDKLightningError ret_var = LightningError_clone(&orig_conv);
15785         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15786         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15787         long ret_ref = (long)ret_var.inner;
15788         if (ret_var.is_owned) {
15789                 ret_ref |= 1;
15790         }
15791         return ret_ref;
15792 }
15793
15794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15795         LDKCommitmentUpdate this_ptr_conv;
15796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15797         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15798         CommitmentUpdate_free(this_ptr_conv);
15799 }
15800
15801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15802         LDKCommitmentUpdate this_ptr_conv;
15803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15804         this_ptr_conv.is_owned = false;
15805         LDKCVec_UpdateAddHTLCZ val_constr;
15806         val_constr.datalen = (*env)->GetArrayLength(env, val);
15807         if (val_constr.datalen > 0)
15808                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
15809         else
15810                 val_constr.data = NULL;
15811         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15812         for (size_t p = 0; p < val_constr.datalen; p++) {
15813                 int64_t val_conv_15 = val_vals[p];
15814                 LDKUpdateAddHTLC val_conv_15_conv;
15815                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
15816                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
15817                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
15818                 val_constr.data[p] = val_conv_15_conv;
15819         }
15820         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15821         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
15822 }
15823
15824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15825         LDKCommitmentUpdate this_ptr_conv;
15826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15827         this_ptr_conv.is_owned = false;
15828         LDKCVec_UpdateFulfillHTLCZ val_constr;
15829         val_constr.datalen = (*env)->GetArrayLength(env, val);
15830         if (val_constr.datalen > 0)
15831                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
15832         else
15833                 val_constr.data = NULL;
15834         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15835         for (size_t t = 0; t < val_constr.datalen; t++) {
15836                 int64_t val_conv_19 = val_vals[t];
15837                 LDKUpdateFulfillHTLC val_conv_19_conv;
15838                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
15839                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
15840                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
15841                 val_constr.data[t] = val_conv_19_conv;
15842         }
15843         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15844         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
15845 }
15846
15847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
15848         LDKCommitmentUpdate this_ptr_conv;
15849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15850         this_ptr_conv.is_owned = false;
15851         LDKCVec_UpdateFailHTLCZ val_constr;
15852         val_constr.datalen = (*env)->GetArrayLength(env, val);
15853         if (val_constr.datalen > 0)
15854                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15855         else
15856                 val_constr.data = NULL;
15857         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15858         for (size_t q = 0; q < val_constr.datalen; q++) {
15859                 int64_t val_conv_16 = val_vals[q];
15860                 LDKUpdateFailHTLC val_conv_16_conv;
15861                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
15862                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
15863                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
15864                 val_constr.data[q] = val_conv_16_conv;
15865         }
15866         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15867         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
15868 }
15869
15870 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) {
15871         LDKCommitmentUpdate this_ptr_conv;
15872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15873         this_ptr_conv.is_owned = false;
15874         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
15875         val_constr.datalen = (*env)->GetArrayLength(env, val);
15876         if (val_constr.datalen > 0)
15877                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15878         else
15879                 val_constr.data = NULL;
15880         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
15881         for (size_t z = 0; z < val_constr.datalen; z++) {
15882                 int64_t val_conv_25 = val_vals[z];
15883                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
15884                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
15885                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
15886                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
15887                 val_constr.data[z] = val_conv_25_conv;
15888         }
15889         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
15890         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
15891 }
15892
15893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
15894         LDKCommitmentUpdate this_ptr_conv;
15895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15896         this_ptr_conv.is_owned = false;
15897         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
15898         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15899         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15900         long ret_ref = (long)ret_var.inner;
15901         if (ret_var.is_owned) {
15902                 ret_ref |= 1;
15903         }
15904         return ret_ref;
15905 }
15906
15907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15908         LDKCommitmentUpdate this_ptr_conv;
15909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15910         this_ptr_conv.is_owned = false;
15911         LDKUpdateFee val_conv;
15912         val_conv.inner = (void*)(val & (~1));
15913         val_conv.is_owned = (val & 1) || (val == 0);
15914         val_conv = UpdateFee_clone(&val_conv);
15915         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
15916 }
15917
15918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
15919         LDKCommitmentUpdate this_ptr_conv;
15920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15921         this_ptr_conv.is_owned = false;
15922         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
15923         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15924         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15925         long ret_ref = (long)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_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15933         LDKCommitmentUpdate this_ptr_conv;
15934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15935         this_ptr_conv.is_owned = false;
15936         LDKCommitmentSigned val_conv;
15937         val_conv.inner = (void*)(val & (~1));
15938         val_conv.is_owned = (val & 1) || (val == 0);
15939         val_conv = CommitmentSigned_clone(&val_conv);
15940         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
15941 }
15942
15943 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) {
15944         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
15945         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
15946         if (update_add_htlcs_arg_constr.datalen > 0)
15947                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
15948         else
15949                 update_add_htlcs_arg_constr.data = NULL;
15950         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
15951         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
15952                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
15953                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
15954                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
15955                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
15956                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
15957                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
15958         }
15959         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
15960         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
15961         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
15962         if (update_fulfill_htlcs_arg_constr.datalen > 0)
15963                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
15964         else
15965                 update_fulfill_htlcs_arg_constr.data = NULL;
15966         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
15967         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
15968                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
15969                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
15970                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
15971                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
15972                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
15973                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
15974         }
15975         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
15976         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
15977         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
15978         if (update_fail_htlcs_arg_constr.datalen > 0)
15979                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15980         else
15981                 update_fail_htlcs_arg_constr.data = NULL;
15982         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
15983         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
15984                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
15985                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
15986                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
15987                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
15988                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
15989                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
15990         }
15991         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
15992         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
15993         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
15994         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
15995                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15996         else
15997                 update_fail_malformed_htlcs_arg_constr.data = NULL;
15998         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
15999         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
16000                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
16001                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
16002                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
16003                 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);
16004                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
16005                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
16006         }
16007         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
16008         LDKUpdateFee update_fee_arg_conv;
16009         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
16010         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
16011         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
16012         LDKCommitmentSigned commitment_signed_arg_conv;
16013         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
16014         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
16015         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
16016         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);
16017         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16018         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16019         long ret_ref = (long)ret_var.inner;
16020         if (ret_var.is_owned) {
16021                 ret_ref |= 1;
16022         }
16023         return ret_ref;
16024 }
16025
16026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16027         LDKCommitmentUpdate orig_conv;
16028         orig_conv.inner = (void*)(orig & (~1));
16029         orig_conv.is_owned = false;
16030         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
16031         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16032         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16033         long ret_ref = (long)ret_var.inner;
16034         if (ret_var.is_owned) {
16035                 ret_ref |= 1;
16036         }
16037         return ret_ref;
16038 }
16039
16040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16041         if ((this_ptr & 1) != 0) return;
16042         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
16043         FREE((void*)this_ptr);
16044         HTLCFailChannelUpdate_free(this_ptr_conv);
16045 }
16046
16047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16048         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
16049         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
16050         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
16051         long ret_ref = (long)ret_copy;
16052         return ret_ref;
16053 }
16054
16055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16056         if ((this_ptr & 1) != 0) return;
16057         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
16058         FREE((void*)this_ptr);
16059         ChannelMessageHandler_free(this_ptr_conv);
16060 }
16061
16062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16063         if ((this_ptr & 1) != 0) return;
16064         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
16065         FREE((void*)this_ptr);
16066         RoutingMessageHandler_free(this_ptr_conv);
16067 }
16068
16069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
16070         LDKAcceptChannel obj_conv;
16071         obj_conv.inner = (void*)(obj & (~1));
16072         obj_conv.is_owned = false;
16073         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
16074         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16075         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16076         CVec_u8Z_free(ret_var);
16077         return ret_arr;
16078 }
16079
16080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16081         LDKu8slice ser_ref;
16082         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16083         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16084         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
16085         *ret_conv = AcceptChannel_read(ser_ref);
16086         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16087         return (long)ret_conv;
16088 }
16089
16090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
16091         LDKAnnouncementSignatures obj_conv;
16092         obj_conv.inner = (void*)(obj & (~1));
16093         obj_conv.is_owned = false;
16094         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
16095         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16096         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16097         CVec_u8Z_free(ret_var);
16098         return ret_arr;
16099 }
16100
16101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16102         LDKu8slice ser_ref;
16103         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16104         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16105         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
16106         *ret_conv = AnnouncementSignatures_read(ser_ref);
16107         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16108         return (long)ret_conv;
16109 }
16110
16111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
16112         LDKChannelReestablish obj_conv;
16113         obj_conv.inner = (void*)(obj & (~1));
16114         obj_conv.is_owned = false;
16115         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
16116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16118         CVec_u8Z_free(ret_var);
16119         return ret_arr;
16120 }
16121
16122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16123         LDKu8slice ser_ref;
16124         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16125         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16126         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
16127         *ret_conv = ChannelReestablish_read(ser_ref);
16128         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16129         return (long)ret_conv;
16130 }
16131
16132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16133         LDKClosingSigned obj_conv;
16134         obj_conv.inner = (void*)(obj & (~1));
16135         obj_conv.is_owned = false;
16136         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
16137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16139         CVec_u8Z_free(ret_var);
16140         return ret_arr;
16141 }
16142
16143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16144         LDKu8slice ser_ref;
16145         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16146         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16147         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
16148         *ret_conv = ClosingSigned_read(ser_ref);
16149         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16150         return (long)ret_conv;
16151 }
16152
16153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16154         LDKCommitmentSigned obj_conv;
16155         obj_conv.inner = (void*)(obj & (~1));
16156         obj_conv.is_owned = false;
16157         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
16158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16160         CVec_u8Z_free(ret_var);
16161         return ret_arr;
16162 }
16163
16164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16165         LDKu8slice ser_ref;
16166         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16167         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16168         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
16169         *ret_conv = CommitmentSigned_read(ser_ref);
16170         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16171         return (long)ret_conv;
16172 }
16173
16174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
16175         LDKFundingCreated obj_conv;
16176         obj_conv.inner = (void*)(obj & (~1));
16177         obj_conv.is_owned = false;
16178         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
16179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16181         CVec_u8Z_free(ret_var);
16182         return ret_arr;
16183 }
16184
16185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16186         LDKu8slice ser_ref;
16187         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16188         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16189         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
16190         *ret_conv = FundingCreated_read(ser_ref);
16191         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16192         return (long)ret_conv;
16193 }
16194
16195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
16196         LDKFundingSigned obj_conv;
16197         obj_conv.inner = (void*)(obj & (~1));
16198         obj_conv.is_owned = false;
16199         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
16200         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16201         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16202         CVec_u8Z_free(ret_var);
16203         return ret_arr;
16204 }
16205
16206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16207         LDKu8slice ser_ref;
16208         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16209         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16210         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
16211         *ret_conv = FundingSigned_read(ser_ref);
16212         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16213         return (long)ret_conv;
16214 }
16215
16216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
16217         LDKFundingLocked obj_conv;
16218         obj_conv.inner = (void*)(obj & (~1));
16219         obj_conv.is_owned = false;
16220         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
16221         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16222         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16223         CVec_u8Z_free(ret_var);
16224         return ret_arr;
16225 }
16226
16227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16228         LDKu8slice ser_ref;
16229         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16230         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16231         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
16232         *ret_conv = FundingLocked_read(ser_ref);
16233         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16234         return (long)ret_conv;
16235 }
16236
16237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
16238         LDKInit obj_conv;
16239         obj_conv.inner = (void*)(obj & (~1));
16240         obj_conv.is_owned = false;
16241         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
16242         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16243         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16244         CVec_u8Z_free(ret_var);
16245         return ret_arr;
16246 }
16247
16248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16249         LDKu8slice ser_ref;
16250         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16251         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16252         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
16253         *ret_conv = Init_read(ser_ref);
16254         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16255         return (long)ret_conv;
16256 }
16257
16258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
16259         LDKOpenChannel obj_conv;
16260         obj_conv.inner = (void*)(obj & (~1));
16261         obj_conv.is_owned = false;
16262         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
16263         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16264         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16265         CVec_u8Z_free(ret_var);
16266         return ret_arr;
16267 }
16268
16269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16270         LDKu8slice ser_ref;
16271         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16272         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16273         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
16274         *ret_conv = OpenChannel_read(ser_ref);
16275         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16276         return (long)ret_conv;
16277 }
16278
16279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
16280         LDKRevokeAndACK obj_conv;
16281         obj_conv.inner = (void*)(obj & (~1));
16282         obj_conv.is_owned = false;
16283         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
16284         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16285         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16286         CVec_u8Z_free(ret_var);
16287         return ret_arr;
16288 }
16289
16290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16291         LDKu8slice ser_ref;
16292         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16293         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16294         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
16295         *ret_conv = RevokeAndACK_read(ser_ref);
16296         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16297         return (long)ret_conv;
16298 }
16299
16300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
16301         LDKShutdown obj_conv;
16302         obj_conv.inner = (void*)(obj & (~1));
16303         obj_conv.is_owned = false;
16304         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
16305         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16306         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16307         CVec_u8Z_free(ret_var);
16308         return ret_arr;
16309 }
16310
16311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16312         LDKu8slice ser_ref;
16313         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16314         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16315         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
16316         *ret_conv = Shutdown_read(ser_ref);
16317         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16318         return (long)ret_conv;
16319 }
16320
16321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16322         LDKUpdateFailHTLC obj_conv;
16323         obj_conv.inner = (void*)(obj & (~1));
16324         obj_conv.is_owned = false;
16325         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
16326         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16327         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16328         CVec_u8Z_free(ret_var);
16329         return ret_arr;
16330 }
16331
16332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16333         LDKu8slice ser_ref;
16334         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16335         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16336         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
16337         *ret_conv = UpdateFailHTLC_read(ser_ref);
16338         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16339         return (long)ret_conv;
16340 }
16341
16342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16343         LDKUpdateFailMalformedHTLC obj_conv;
16344         obj_conv.inner = (void*)(obj & (~1));
16345         obj_conv.is_owned = false;
16346         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
16347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16349         CVec_u8Z_free(ret_var);
16350         return ret_arr;
16351 }
16352
16353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16354         LDKu8slice ser_ref;
16355         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16356         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16357         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
16358         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
16359         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16360         return (long)ret_conv;
16361 }
16362
16363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
16364         LDKUpdateFee obj_conv;
16365         obj_conv.inner = (void*)(obj & (~1));
16366         obj_conv.is_owned = false;
16367         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
16368         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16369         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16370         CVec_u8Z_free(ret_var);
16371         return ret_arr;
16372 }
16373
16374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16375         LDKu8slice ser_ref;
16376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16378         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
16379         *ret_conv = UpdateFee_read(ser_ref);
16380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16381         return (long)ret_conv;
16382 }
16383
16384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16385         LDKUpdateFulfillHTLC obj_conv;
16386         obj_conv.inner = (void*)(obj & (~1));
16387         obj_conv.is_owned = false;
16388         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
16389         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16390         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16391         CVec_u8Z_free(ret_var);
16392         return ret_arr;
16393 }
16394
16395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16396         LDKu8slice ser_ref;
16397         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16398         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16399         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
16400         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
16401         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16402         return (long)ret_conv;
16403 }
16404
16405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
16406         LDKUpdateAddHTLC obj_conv;
16407         obj_conv.inner = (void*)(obj & (~1));
16408         obj_conv.is_owned = false;
16409         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
16410         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16411         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16412         CVec_u8Z_free(ret_var);
16413         return ret_arr;
16414 }
16415
16416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16417         LDKu8slice ser_ref;
16418         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16419         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16420         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
16421         *ret_conv = UpdateAddHTLC_read(ser_ref);
16422         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16423         return (long)ret_conv;
16424 }
16425
16426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
16427         LDKPing obj_conv;
16428         obj_conv.inner = (void*)(obj & (~1));
16429         obj_conv.is_owned = false;
16430         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
16431         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16432         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16433         CVec_u8Z_free(ret_var);
16434         return ret_arr;
16435 }
16436
16437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16438         LDKu8slice ser_ref;
16439         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16440         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16441         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
16442         *ret_conv = Ping_read(ser_ref);
16443         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16444         return (long)ret_conv;
16445 }
16446
16447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
16448         LDKPong obj_conv;
16449         obj_conv.inner = (void*)(obj & (~1));
16450         obj_conv.is_owned = false;
16451         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
16452         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16453         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16454         CVec_u8Z_free(ret_var);
16455         return ret_arr;
16456 }
16457
16458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16459         LDKu8slice ser_ref;
16460         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16461         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16462         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
16463         *ret_conv = Pong_read(ser_ref);
16464         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16465         return (long)ret_conv;
16466 }
16467
16468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
16469         LDKUnsignedChannelAnnouncement obj_conv;
16470         obj_conv.inner = (void*)(obj & (~1));
16471         obj_conv.is_owned = false;
16472         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
16473         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16474         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16475         CVec_u8Z_free(ret_var);
16476         return ret_arr;
16477 }
16478
16479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16480         LDKu8slice ser_ref;
16481         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16482         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16483         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
16484         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
16485         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16486         return (long)ret_conv;
16487 }
16488
16489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
16490         LDKChannelAnnouncement obj_conv;
16491         obj_conv.inner = (void*)(obj & (~1));
16492         obj_conv.is_owned = false;
16493         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
16494         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16495         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16496         CVec_u8Z_free(ret_var);
16497         return ret_arr;
16498 }
16499
16500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16501         LDKu8slice ser_ref;
16502         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16503         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16504         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
16505         *ret_conv = ChannelAnnouncement_read(ser_ref);
16506         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16507         return (long)ret_conv;
16508 }
16509
16510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
16511         LDKUnsignedChannelUpdate obj_conv;
16512         obj_conv.inner = (void*)(obj & (~1));
16513         obj_conv.is_owned = false;
16514         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
16515         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16516         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16517         CVec_u8Z_free(ret_var);
16518         return ret_arr;
16519 }
16520
16521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16522         LDKu8slice ser_ref;
16523         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16524         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16525         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
16526         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
16527         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16528         return (long)ret_conv;
16529 }
16530
16531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
16532         LDKChannelUpdate obj_conv;
16533         obj_conv.inner = (void*)(obj & (~1));
16534         obj_conv.is_owned = false;
16535         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
16536         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16537         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16538         CVec_u8Z_free(ret_var);
16539         return ret_arr;
16540 }
16541
16542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16543         LDKu8slice ser_ref;
16544         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16545         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16546         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
16547         *ret_conv = ChannelUpdate_read(ser_ref);
16548         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16549         return (long)ret_conv;
16550 }
16551
16552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
16553         LDKErrorMessage obj_conv;
16554         obj_conv.inner = (void*)(obj & (~1));
16555         obj_conv.is_owned = false;
16556         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
16557         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16558         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16559         CVec_u8Z_free(ret_var);
16560         return ret_arr;
16561 }
16562
16563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16564         LDKu8slice ser_ref;
16565         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16566         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16567         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
16568         *ret_conv = ErrorMessage_read(ser_ref);
16569         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16570         return (long)ret_conv;
16571 }
16572
16573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
16574         LDKUnsignedNodeAnnouncement obj_conv;
16575         obj_conv.inner = (void*)(obj & (~1));
16576         obj_conv.is_owned = false;
16577         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
16578         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16579         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16580         CVec_u8Z_free(ret_var);
16581         return ret_arr;
16582 }
16583
16584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16585         LDKu8slice ser_ref;
16586         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16587         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16588         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
16589         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
16590         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16591         return (long)ret_conv;
16592 }
16593
16594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
16595         LDKNodeAnnouncement obj_conv;
16596         obj_conv.inner = (void*)(obj & (~1));
16597         obj_conv.is_owned = false;
16598         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
16599         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16600         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16601         CVec_u8Z_free(ret_var);
16602         return ret_arr;
16603 }
16604
16605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16606         LDKu8slice ser_ref;
16607         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16608         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16609         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16610         *ret_conv = NodeAnnouncement_read(ser_ref);
16611         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16612         return (long)ret_conv;
16613 }
16614
16615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16616         LDKu8slice ser_ref;
16617         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16618         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16619         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16620         *ret_conv = QueryShortChannelIds_read(ser_ref);
16621         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16622         return (long)ret_conv;
16623 }
16624
16625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
16626         LDKQueryShortChannelIds obj_conv;
16627         obj_conv.inner = (void*)(obj & (~1));
16628         obj_conv.is_owned = false;
16629         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
16630         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16631         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16632         CVec_u8Z_free(ret_var);
16633         return ret_arr;
16634 }
16635
16636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16637         LDKu8slice ser_ref;
16638         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16639         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16640         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16641         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
16642         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16643         return (long)ret_conv;
16644 }
16645
16646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
16647         LDKReplyShortChannelIdsEnd obj_conv;
16648         obj_conv.inner = (void*)(obj & (~1));
16649         obj_conv.is_owned = false;
16650         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
16651         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16652         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16653         CVec_u8Z_free(ret_var);
16654         return ret_arr;
16655 }
16656
16657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16658         LDKu8slice ser_ref;
16659         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16660         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16661         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16662         *ret_conv = QueryChannelRange_read(ser_ref);
16663         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16664         return (long)ret_conv;
16665 }
16666
16667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
16668         LDKQueryChannelRange obj_conv;
16669         obj_conv.inner = (void*)(obj & (~1));
16670         obj_conv.is_owned = false;
16671         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
16672         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16673         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16674         CVec_u8Z_free(ret_var);
16675         return ret_arr;
16676 }
16677
16678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16679         LDKu8slice ser_ref;
16680         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16681         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16682         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16683         *ret_conv = ReplyChannelRange_read(ser_ref);
16684         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16685         return (long)ret_conv;
16686 }
16687
16688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
16689         LDKReplyChannelRange obj_conv;
16690         obj_conv.inner = (void*)(obj & (~1));
16691         obj_conv.is_owned = false;
16692         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
16693         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16694         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16695         CVec_u8Z_free(ret_var);
16696         return ret_arr;
16697 }
16698
16699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16700         LDKu8slice ser_ref;
16701         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16702         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16703         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16704         *ret_conv = GossipTimestampFilter_read(ser_ref);
16705         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16706         return (long)ret_conv;
16707 }
16708
16709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
16710         LDKGossipTimestampFilter obj_conv;
16711         obj_conv.inner = (void*)(obj & (~1));
16712         obj_conv.is_owned = false;
16713         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
16714         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16715         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16716         CVec_u8Z_free(ret_var);
16717         return ret_arr;
16718 }
16719
16720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16721         LDKMessageHandler this_ptr_conv;
16722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16723         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16724         MessageHandler_free(this_ptr_conv);
16725 }
16726
16727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
16728         LDKMessageHandler this_ptr_conv;
16729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16730         this_ptr_conv.is_owned = false;
16731         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
16732         return ret_ret;
16733 }
16734
16735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16736         LDKMessageHandler this_ptr_conv;
16737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16738         this_ptr_conv.is_owned = false;
16739         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
16740         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
16741                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16742                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
16743         }
16744         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
16745 }
16746
16747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
16748         LDKMessageHandler this_ptr_conv;
16749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16750         this_ptr_conv.is_owned = false;
16751         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
16752         return ret_ret;
16753 }
16754
16755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16756         LDKMessageHandler this_ptr_conv;
16757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16758         this_ptr_conv.is_owned = false;
16759         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
16760         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
16761                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16762                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
16763         }
16764         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
16765 }
16766
16767 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) {
16768         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
16769         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
16770                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16771                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
16772         }
16773         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
16774         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
16775                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16776                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
16777         }
16778         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
16779         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16780         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16781         long ret_ref = (long)ret_var.inner;
16782         if (ret_var.is_owned) {
16783                 ret_ref |= 1;
16784         }
16785         return ret_ref;
16786 }
16787
16788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16789         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig;
16790         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
16791         *ret = SocketDescriptor_clone(orig_conv);
16792         return (long)ret;
16793 }
16794
16795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16796         if ((this_ptr & 1) != 0) return;
16797         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
16798         FREE((void*)this_ptr);
16799         SocketDescriptor_free(this_ptr_conv);
16800 }
16801
16802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16803         LDKPeerHandleError this_ptr_conv;
16804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16805         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16806         PeerHandleError_free(this_ptr_conv);
16807 }
16808
16809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
16810         LDKPeerHandleError this_ptr_conv;
16811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16812         this_ptr_conv.is_owned = false;
16813         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
16814         return ret_val;
16815 }
16816
16817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16818         LDKPeerHandleError this_ptr_conv;
16819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16820         this_ptr_conv.is_owned = false;
16821         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
16822 }
16823
16824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
16825         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
16826         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16827         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16828         long ret_ref = (long)ret_var.inner;
16829         if (ret_var.is_owned) {
16830                 ret_ref |= 1;
16831         }
16832         return ret_ref;
16833 }
16834
16835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16836         LDKPeerHandleError orig_conv;
16837         orig_conv.inner = (void*)(orig & (~1));
16838         orig_conv.is_owned = false;
16839         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
16840         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16841         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16842         long ret_ref = (long)ret_var.inner;
16843         if (ret_var.is_owned) {
16844                 ret_ref |= 1;
16845         }
16846         return ret_ref;
16847 }
16848
16849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16850         LDKPeerManager this_ptr_conv;
16851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16852         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
16853         PeerManager_free(this_ptr_conv);
16854 }
16855
16856 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) {
16857         LDKMessageHandler message_handler_conv;
16858         message_handler_conv.inner = (void*)(message_handler & (~1));
16859         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
16860         // Warning: we need a move here but no clone is available for LDKMessageHandler
16861         LDKSecretKey our_node_secret_ref;
16862         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
16863         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
16864         unsigned char ephemeral_random_data_arr[32];
16865         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
16866         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
16867         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
16868         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16869         if (logger_conv.free == LDKLogger_JCalls_free) {
16870                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16871                 LDKLogger_JCalls_clone(logger_conv.this_arg);
16872         }
16873         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
16874         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16875         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16876         long ret_ref = (long)ret_var.inner;
16877         if (ret_var.is_owned) {
16878                 ret_ref |= 1;
16879         }
16880         return ret_ref;
16881 }
16882
16883 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
16884         LDKPeerManager this_arg_conv;
16885         this_arg_conv.inner = (void*)(this_arg & (~1));
16886         this_arg_conv.is_owned = false;
16887         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
16888         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
16889         ;
16890         for (size_t i = 0; i < ret_var.datalen; i++) {
16891                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
16892                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
16893                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
16894         }
16895         FREE(ret_var.data);
16896         return ret_arr;
16897 }
16898
16899 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) {
16900         LDKPeerManager this_arg_conv;
16901         this_arg_conv.inner = (void*)(this_arg & (~1));
16902         this_arg_conv.is_owned = false;
16903         LDKPublicKey their_node_id_ref;
16904         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
16905         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
16906         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16907         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
16908                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16909                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
16910         }
16911         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16912         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
16913         return (long)ret_conv;
16914 }
16915
16916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
16917         LDKPeerManager this_arg_conv;
16918         this_arg_conv.inner = (void*)(this_arg & (~1));
16919         this_arg_conv.is_owned = false;
16920         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16921         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
16922                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16923                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
16924         }
16925         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16926         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
16927         return (long)ret_conv;
16928 }
16929
16930 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) {
16931         LDKPeerManager this_arg_conv;
16932         this_arg_conv.inner = (void*)(this_arg & (~1));
16933         this_arg_conv.is_owned = false;
16934         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
16935         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16936         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
16937         return (long)ret_conv;
16938 }
16939
16940 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) {
16941         LDKPeerManager this_arg_conv;
16942         this_arg_conv.inner = (void*)(this_arg & (~1));
16943         this_arg_conv.is_owned = false;
16944         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
16945         LDKu8slice data_ref;
16946         data_ref.datalen = (*env)->GetArrayLength(env, data);
16947         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
16948         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16949         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
16950         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
16951         return (long)ret_conv;
16952 }
16953
16954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
16955         LDKPeerManager this_arg_conv;
16956         this_arg_conv.inner = (void*)(this_arg & (~1));
16957         this_arg_conv.is_owned = false;
16958         PeerManager_process_events(&this_arg_conv);
16959 }
16960
16961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
16962         LDKPeerManager this_arg_conv;
16963         this_arg_conv.inner = (void*)(this_arg & (~1));
16964         this_arg_conv.is_owned = false;
16965         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
16966         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
16967 }
16968
16969 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) {
16970         LDKPeerManager this_arg_conv;
16971         this_arg_conv.inner = (void*)(this_arg & (~1));
16972         this_arg_conv.is_owned = false;
16973         LDKPublicKey node_id_ref;
16974         CHECK((*env)->GetArrayLength(env, node_id) == 33);
16975         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
16976         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
16977 }
16978
16979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv *env, jclass clz, int64_t this_arg) {
16980         LDKPeerManager this_arg_conv;
16981         this_arg_conv.inner = (void*)(this_arg & (~1));
16982         this_arg_conv.is_owned = false;
16983         PeerManager_timer_tick_occured(&this_arg_conv);
16984 }
16985
16986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
16987         unsigned char commitment_seed_arr[32];
16988         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
16989         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
16990         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
16991         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16992         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
16993         return ret_arr;
16994 }
16995
16996 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) {
16997         LDKPublicKey per_commitment_point_ref;
16998         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
16999         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17000         unsigned char base_secret_arr[32];
17001         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
17002         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
17003         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
17004         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
17005         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
17006         return (long)ret_conv;
17007 }
17008
17009 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) {
17010         LDKPublicKey per_commitment_point_ref;
17011         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17012         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17013         LDKPublicKey base_point_ref;
17014         CHECK((*env)->GetArrayLength(env, base_point) == 33);
17015         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
17016         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17017         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
17018         return (long)ret_conv;
17019 }
17020
17021 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) {
17022         unsigned char per_commitment_secret_arr[32];
17023         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
17024         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
17025         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
17026         unsigned char countersignatory_revocation_base_secret_arr[32];
17027         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
17028         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
17029         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
17030         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
17031         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
17032         return (long)ret_conv;
17033 }
17034
17035 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) {
17036         LDKPublicKey per_commitment_point_ref;
17037         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17038         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17039         LDKPublicKey countersignatory_revocation_base_point_ref;
17040         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
17041         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
17042         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17043         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
17044         return (long)ret_conv;
17045 }
17046
17047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17048         LDKTxCreationKeys this_ptr_conv;
17049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17050         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17051         TxCreationKeys_free(this_ptr_conv);
17052 }
17053
17054 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17055         LDKTxCreationKeys this_ptr_conv;
17056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17057         this_ptr_conv.is_owned = false;
17058         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17059         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
17060         return ret_arr;
17061 }
17062
17063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17064         LDKTxCreationKeys this_ptr_conv;
17065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17066         this_ptr_conv.is_owned = false;
17067         LDKPublicKey val_ref;
17068         CHECK((*env)->GetArrayLength(env, val) == 33);
17069         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17070         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
17071 }
17072
17073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17074         LDKTxCreationKeys this_ptr_conv;
17075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17076         this_ptr_conv.is_owned = false;
17077         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17078         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
17079         return ret_arr;
17080 }
17081
17082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17083         LDKTxCreationKeys this_ptr_conv;
17084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17085         this_ptr_conv.is_owned = false;
17086         LDKPublicKey val_ref;
17087         CHECK((*env)->GetArrayLength(env, val) == 33);
17088         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17089         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
17090 }
17091
17092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17093         LDKTxCreationKeys this_ptr_conv;
17094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17095         this_ptr_conv.is_owned = false;
17096         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17097         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
17098         return ret_arr;
17099 }
17100
17101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17102         LDKTxCreationKeys this_ptr_conv;
17103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17104         this_ptr_conv.is_owned = false;
17105         LDKPublicKey val_ref;
17106         CHECK((*env)->GetArrayLength(env, val) == 33);
17107         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17108         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
17109 }
17110
17111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17112         LDKTxCreationKeys this_ptr_conv;
17113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17114         this_ptr_conv.is_owned = false;
17115         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
17117         return ret_arr;
17118 }
17119
17120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17121         LDKTxCreationKeys this_ptr_conv;
17122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17123         this_ptr_conv.is_owned = false;
17124         LDKPublicKey val_ref;
17125         CHECK((*env)->GetArrayLength(env, val) == 33);
17126         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17127         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
17128 }
17129
17130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
17131         LDKTxCreationKeys this_ptr_conv;
17132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17133         this_ptr_conv.is_owned = false;
17134         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17135         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
17136         return ret_arr;
17137 }
17138
17139 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) {
17140         LDKTxCreationKeys this_ptr_conv;
17141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17142         this_ptr_conv.is_owned = false;
17143         LDKPublicKey val_ref;
17144         CHECK((*env)->GetArrayLength(env, val) == 33);
17145         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17146         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
17147 }
17148
17149 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) {
17150         LDKPublicKey per_commitment_point_arg_ref;
17151         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
17152         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
17153         LDKPublicKey revocation_key_arg_ref;
17154         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
17155         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
17156         LDKPublicKey broadcaster_htlc_key_arg_ref;
17157         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
17158         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
17159         LDKPublicKey countersignatory_htlc_key_arg_ref;
17160         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
17161         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
17162         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
17163         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
17164         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
17165         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);
17166         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17167         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17168         long ret_ref = (long)ret_var.inner;
17169         if (ret_var.is_owned) {
17170                 ret_ref |= 1;
17171         }
17172         return ret_ref;
17173 }
17174
17175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17176         LDKTxCreationKeys orig_conv;
17177         orig_conv.inner = (void*)(orig & (~1));
17178         orig_conv.is_owned = false;
17179         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
17180         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17181         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17182         long ret_ref = (long)ret_var.inner;
17183         if (ret_var.is_owned) {
17184                 ret_ref |= 1;
17185         }
17186         return ret_ref;
17187 }
17188
17189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
17190         LDKTxCreationKeys obj_conv;
17191         obj_conv.inner = (void*)(obj & (~1));
17192         obj_conv.is_owned = false;
17193         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
17194         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17195         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17196         CVec_u8Z_free(ret_var);
17197         return ret_arr;
17198 }
17199
17200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17201         LDKu8slice ser_ref;
17202         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17203         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17204         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
17205         *ret_conv = TxCreationKeys_read(ser_ref);
17206         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17207         return (long)ret_conv;
17208 }
17209
17210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17211         LDKChannelPublicKeys this_ptr_conv;
17212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17213         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17214         ChannelPublicKeys_free(this_ptr_conv);
17215 }
17216
17217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17218         LDKChannelPublicKeys this_ptr_conv;
17219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17220         this_ptr_conv.is_owned = false;
17221         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17222         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
17223         return ret_arr;
17224 }
17225
17226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17227         LDKChannelPublicKeys this_ptr_conv;
17228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17229         this_ptr_conv.is_owned = false;
17230         LDKPublicKey val_ref;
17231         CHECK((*env)->GetArrayLength(env, val) == 33);
17232         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17233         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
17234 }
17235
17236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17237         LDKChannelPublicKeys this_ptr_conv;
17238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17239         this_ptr_conv.is_owned = false;
17240         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17241         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17242         return ret_arr;
17243 }
17244
17245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17246         LDKChannelPublicKeys this_ptr_conv;
17247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17248         this_ptr_conv.is_owned = false;
17249         LDKPublicKey val_ref;
17250         CHECK((*env)->GetArrayLength(env, val) == 33);
17251         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17252         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
17253 }
17254
17255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17256         LDKChannelPublicKeys this_ptr_conv;
17257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17258         this_ptr_conv.is_owned = false;
17259         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
17261         return ret_arr;
17262 }
17263
17264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17265         LDKChannelPublicKeys this_ptr_conv;
17266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17267         this_ptr_conv.is_owned = false;
17268         LDKPublicKey val_ref;
17269         CHECK((*env)->GetArrayLength(env, val) == 33);
17270         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17271         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
17272 }
17273
17274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17275         LDKChannelPublicKeys this_ptr_conv;
17276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17277         this_ptr_conv.is_owned = false;
17278         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17280         return ret_arr;
17281 }
17282
17283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17284         LDKChannelPublicKeys this_ptr_conv;
17285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17286         this_ptr_conv.is_owned = false;
17287         LDKPublicKey val_ref;
17288         CHECK((*env)->GetArrayLength(env, val) == 33);
17289         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17290         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17291 }
17292
17293 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17294         LDKChannelPublicKeys this_ptr_conv;
17295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17296         this_ptr_conv.is_owned = false;
17297         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17298         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17299         return ret_arr;
17300 }
17301
17302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17303         LDKChannelPublicKeys this_ptr_conv;
17304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17305         this_ptr_conv.is_owned = false;
17306         LDKPublicKey val_ref;
17307         CHECK((*env)->GetArrayLength(env, val) == 33);
17308         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17309         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
17310 }
17311
17312 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) {
17313         LDKPublicKey funding_pubkey_arg_ref;
17314         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
17315         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
17316         LDKPublicKey revocation_basepoint_arg_ref;
17317         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
17318         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
17319         LDKPublicKey payment_point_arg_ref;
17320         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
17321         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
17322         LDKPublicKey delayed_payment_basepoint_arg_ref;
17323         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
17324         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
17325         LDKPublicKey htlc_basepoint_arg_ref;
17326         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
17327         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
17328         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);
17329         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17330         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17331         long ret_ref = (long)ret_var.inner;
17332         if (ret_var.is_owned) {
17333                 ret_ref |= 1;
17334         }
17335         return ret_ref;
17336 }
17337
17338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17339         LDKChannelPublicKeys orig_conv;
17340         orig_conv.inner = (void*)(orig & (~1));
17341         orig_conv.is_owned = false;
17342         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
17343         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17344         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17345         long ret_ref = (long)ret_var.inner;
17346         if (ret_var.is_owned) {
17347                 ret_ref |= 1;
17348         }
17349         return ret_ref;
17350 }
17351
17352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
17353         LDKChannelPublicKeys obj_conv;
17354         obj_conv.inner = (void*)(obj & (~1));
17355         obj_conv.is_owned = false;
17356         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
17357         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17358         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17359         CVec_u8Z_free(ret_var);
17360         return ret_arr;
17361 }
17362
17363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17364         LDKu8slice ser_ref;
17365         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17366         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17367         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
17368         *ret_conv = ChannelPublicKeys_read(ser_ref);
17369         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17370         return (long)ret_conv;
17371 }
17372
17373 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) {
17374         LDKPublicKey per_commitment_point_ref;
17375         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17376         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17377         LDKPublicKey broadcaster_delayed_payment_base_ref;
17378         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
17379         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
17380         LDKPublicKey broadcaster_htlc_base_ref;
17381         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
17382         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
17383         LDKPublicKey countersignatory_revocation_base_ref;
17384         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
17385         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
17386         LDKPublicKey countersignatory_htlc_base_ref;
17387         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
17388         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
17389         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
17390         *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);
17391         return (long)ret_conv;
17392 }
17393
17394 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) {
17395         LDKPublicKey per_commitment_point_ref;
17396         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
17397         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
17398         LDKChannelPublicKeys broadcaster_keys_conv;
17399         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
17400         broadcaster_keys_conv.is_owned = false;
17401         LDKChannelPublicKeys countersignatory_keys_conv;
17402         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
17403         countersignatory_keys_conv.is_owned = false;
17404         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
17405         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
17406         return (long)ret_conv;
17407 }
17408
17409 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) {
17410         LDKPublicKey revocation_key_ref;
17411         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
17412         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
17413         LDKPublicKey broadcaster_delayed_payment_key_ref;
17414         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
17415         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
17416         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
17417         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17418         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17419         CVec_u8Z_free(ret_var);
17420         return ret_arr;
17421 }
17422
17423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17424         LDKHTLCOutputInCommitment this_ptr_conv;
17425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17426         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17427         HTLCOutputInCommitment_free(this_ptr_conv);
17428 }
17429
17430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
17431         LDKHTLCOutputInCommitment this_ptr_conv;
17432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17433         this_ptr_conv.is_owned = false;
17434         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
17435         return ret_val;
17436 }
17437
17438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
17439         LDKHTLCOutputInCommitment this_ptr_conv;
17440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17441         this_ptr_conv.is_owned = false;
17442         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
17443 }
17444
17445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17446         LDKHTLCOutputInCommitment this_ptr_conv;
17447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17448         this_ptr_conv.is_owned = false;
17449         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
17450         return ret_val;
17451 }
17452
17453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17454         LDKHTLCOutputInCommitment this_ptr_conv;
17455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17456         this_ptr_conv.is_owned = false;
17457         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
17458 }
17459
17460 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
17461         LDKHTLCOutputInCommitment this_ptr_conv;
17462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17463         this_ptr_conv.is_owned = false;
17464         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
17465         return ret_val;
17466 }
17467
17468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17469         LDKHTLCOutputInCommitment this_ptr_conv;
17470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17471         this_ptr_conv.is_owned = false;
17472         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
17473 }
17474
17475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17476         LDKHTLCOutputInCommitment this_ptr_conv;
17477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17478         this_ptr_conv.is_owned = false;
17479         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17480         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
17481         return ret_arr;
17482 }
17483
17484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17485         LDKHTLCOutputInCommitment this_ptr_conv;
17486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17487         this_ptr_conv.is_owned = false;
17488         LDKThirtyTwoBytes val_ref;
17489         CHECK((*env)->GetArrayLength(env, val) == 32);
17490         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17491         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
17492 }
17493
17494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17495         LDKHTLCOutputInCommitment orig_conv;
17496         orig_conv.inner = (void*)(orig & (~1));
17497         orig_conv.is_owned = false;
17498         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
17499         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17500         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17501         long ret_ref = (long)ret_var.inner;
17502         if (ret_var.is_owned) {
17503                 ret_ref |= 1;
17504         }
17505         return ret_ref;
17506 }
17507
17508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
17509         LDKHTLCOutputInCommitment obj_conv;
17510         obj_conv.inner = (void*)(obj & (~1));
17511         obj_conv.is_owned = false;
17512         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
17513         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17514         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17515         CVec_u8Z_free(ret_var);
17516         return ret_arr;
17517 }
17518
17519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17520         LDKu8slice ser_ref;
17521         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17522         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17523         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
17524         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
17525         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17526         return (long)ret_conv;
17527 }
17528
17529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
17530         LDKHTLCOutputInCommitment htlc_conv;
17531         htlc_conv.inner = (void*)(htlc & (~1));
17532         htlc_conv.is_owned = false;
17533         LDKTxCreationKeys keys_conv;
17534         keys_conv.inner = (void*)(keys & (~1));
17535         keys_conv.is_owned = false;
17536         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
17537         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17538         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17539         CVec_u8Z_free(ret_var);
17540         return ret_arr;
17541 }
17542
17543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
17544         LDKPublicKey broadcaster_ref;
17545         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
17546         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
17547         LDKPublicKey countersignatory_ref;
17548         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
17549         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
17550         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
17551         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17552         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17553         CVec_u8Z_free(ret_var);
17554         return ret_arr;
17555 }
17556
17557 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1htlc_1transaction(JNIEnv *env, jclass clz, int8_tArray prev_hash, int32_t feerate_per_kw, int16_t contest_delay, int64_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
17558         unsigned char prev_hash_arr[32];
17559         CHECK((*env)->GetArrayLength(env, prev_hash) == 32);
17560         (*env)->GetByteArrayRegion(env, prev_hash, 0, 32, prev_hash_arr);
17561         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
17562         LDKHTLCOutputInCommitment htlc_conv;
17563         htlc_conv.inner = (void*)(htlc & (~1));
17564         htlc_conv.is_owned = false;
17565         LDKPublicKey broadcaster_delayed_payment_key_ref;
17566         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
17567         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
17568         LDKPublicKey revocation_key_ref;
17569         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
17570         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
17571         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
17572         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17573         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17574         Transaction_free(ret_var);
17575         return ret_arr;
17576 }
17577
17578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17579         LDKChannelTransactionParameters this_ptr_conv;
17580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17581         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17582         ChannelTransactionParameters_free(this_ptr_conv);
17583 }
17584
17585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
17586         LDKChannelTransactionParameters this_ptr_conv;
17587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17588         this_ptr_conv.is_owned = false;
17589         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
17590         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17591         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17592         long ret_ref = (long)ret_var.inner;
17593         if (ret_var.is_owned) {
17594                 ret_ref |= 1;
17595         }
17596         return ret_ref;
17597 }
17598
17599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17600         LDKChannelTransactionParameters this_ptr_conv;
17601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17602         this_ptr_conv.is_owned = false;
17603         LDKChannelPublicKeys val_conv;
17604         val_conv.inner = (void*)(val & (~1));
17605         val_conv.is_owned = (val & 1) || (val == 0);
17606         val_conv = ChannelPublicKeys_clone(&val_conv);
17607         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
17608 }
17609
17610 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17611         LDKChannelTransactionParameters this_ptr_conv;
17612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17613         this_ptr_conv.is_owned = false;
17614         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
17615         return ret_val;
17616 }
17617
17618 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) {
17619         LDKChannelTransactionParameters this_ptr_conv;
17620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17621         this_ptr_conv.is_owned = false;
17622         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
17623 }
17624
17625 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
17626         LDKChannelTransactionParameters this_ptr_conv;
17627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17628         this_ptr_conv.is_owned = false;
17629         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
17630         return ret_val;
17631 }
17632
17633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
17634         LDKChannelTransactionParameters this_ptr_conv;
17635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17636         this_ptr_conv.is_owned = false;
17637         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
17638 }
17639
17640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
17641         LDKChannelTransactionParameters this_ptr_conv;
17642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17643         this_ptr_conv.is_owned = false;
17644         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
17645         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17646         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17647         long ret_ref = (long)ret_var.inner;
17648         if (ret_var.is_owned) {
17649                 ret_ref |= 1;
17650         }
17651         return ret_ref;
17652 }
17653
17654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17655         LDKChannelTransactionParameters this_ptr_conv;
17656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17657         this_ptr_conv.is_owned = false;
17658         LDKCounterpartyChannelTransactionParameters val_conv;
17659         val_conv.inner = (void*)(val & (~1));
17660         val_conv.is_owned = (val & 1) || (val == 0);
17661         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
17662         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
17663 }
17664
17665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17666         LDKChannelTransactionParameters this_ptr_conv;
17667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17668         this_ptr_conv.is_owned = false;
17669         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
17670         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17671         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17672         long ret_ref = (long)ret_var.inner;
17673         if (ret_var.is_owned) {
17674                 ret_ref |= 1;
17675         }
17676         return ret_ref;
17677 }
17678
17679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17680         LDKChannelTransactionParameters this_ptr_conv;
17681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17682         this_ptr_conv.is_owned = false;
17683         LDKOutPoint val_conv;
17684         val_conv.inner = (void*)(val & (~1));
17685         val_conv.is_owned = (val & 1) || (val == 0);
17686         val_conv = OutPoint_clone(&val_conv);
17687         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
17688 }
17689
17690 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) {
17691         LDKChannelPublicKeys holder_pubkeys_arg_conv;
17692         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
17693         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
17694         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
17695         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
17696         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
17697         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
17698         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
17699         LDKOutPoint funding_outpoint_arg_conv;
17700         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
17701         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
17702         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
17703         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);
17704         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17705         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17706         long ret_ref = (long)ret_var.inner;
17707         if (ret_var.is_owned) {
17708                 ret_ref |= 1;
17709         }
17710         return ret_ref;
17711 }
17712
17713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17714         LDKChannelTransactionParameters orig_conv;
17715         orig_conv.inner = (void*)(orig & (~1));
17716         orig_conv.is_owned = false;
17717         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
17718         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17719         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17720         long ret_ref = (long)ret_var.inner;
17721         if (ret_var.is_owned) {
17722                 ret_ref |= 1;
17723         }
17724         return ret_ref;
17725 }
17726
17727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17728         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17730         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17731         CounterpartyChannelTransactionParameters_free(this_ptr_conv);
17732 }
17733
17734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
17735         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17737         this_ptr_conv.is_owned = false;
17738         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
17739         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17740         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17741         long ret_ref = (long)ret_var.inner;
17742         if (ret_var.is_owned) {
17743                 ret_ref |= 1;
17744         }
17745         return ret_ref;
17746 }
17747
17748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17749         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17751         this_ptr_conv.is_owned = false;
17752         LDKChannelPublicKeys val_conv;
17753         val_conv.inner = (void*)(val & (~1));
17754         val_conv.is_owned = (val & 1) || (val == 0);
17755         val_conv = ChannelPublicKeys_clone(&val_conv);
17756         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
17757 }
17758
17759 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17760         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17762         this_ptr_conv.is_owned = false;
17763         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
17764         return ret_val;
17765 }
17766
17767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17768         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17770         this_ptr_conv.is_owned = false;
17771         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
17772 }
17773
17774 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) {
17775         LDKChannelPublicKeys pubkeys_arg_conv;
17776         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
17777         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
17778         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
17779         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
17780         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17781         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17782         long ret_ref = (long)ret_var.inner;
17783         if (ret_var.is_owned) {
17784                 ret_ref |= 1;
17785         }
17786         return ret_ref;
17787 }
17788
17789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17790         LDKCounterpartyChannelTransactionParameters orig_conv;
17791         orig_conv.inner = (void*)(orig & (~1));
17792         orig_conv.is_owned = false;
17793         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
17794         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17795         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17796         long ret_ref = (long)ret_var.inner;
17797         if (ret_var.is_owned) {
17798                 ret_ref |= 1;
17799         }
17800         return ret_ref;
17801 }
17802
17803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
17804         LDKChannelTransactionParameters this_arg_conv;
17805         this_arg_conv.inner = (void*)(this_arg & (~1));
17806         this_arg_conv.is_owned = false;
17807         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
17808         return ret_val;
17809 }
17810
17811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
17812         LDKChannelTransactionParameters this_arg_conv;
17813         this_arg_conv.inner = (void*)(this_arg & (~1));
17814         this_arg_conv.is_owned = false;
17815         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
17816         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17817         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17818         long ret_ref = (long)ret_var.inner;
17819         if (ret_var.is_owned) {
17820                 ret_ref |= 1;
17821         }
17822         return ret_ref;
17823 }
17824
17825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
17826         LDKChannelTransactionParameters this_arg_conv;
17827         this_arg_conv.inner = (void*)(this_arg & (~1));
17828         this_arg_conv.is_owned = false;
17829         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
17830         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17831         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17832         long ret_ref = (long)ret_var.inner;
17833         if (ret_var.is_owned) {
17834                 ret_ref |= 1;
17835         }
17836         return ret_ref;
17837 }
17838
17839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
17840         LDKCounterpartyChannelTransactionParameters obj_conv;
17841         obj_conv.inner = (void*)(obj & (~1));
17842         obj_conv.is_owned = false;
17843         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
17844         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17845         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17846         CVec_u8Z_free(ret_var);
17847         return ret_arr;
17848 }
17849
17850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17851         LDKu8slice ser_ref;
17852         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17853         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17854         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
17855         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
17856         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17857         return (long)ret_conv;
17858 }
17859
17860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
17861         LDKChannelTransactionParameters obj_conv;
17862         obj_conv.inner = (void*)(obj & (~1));
17863         obj_conv.is_owned = false;
17864         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
17865         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17866         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17867         CVec_u8Z_free(ret_var);
17868         return ret_arr;
17869 }
17870
17871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
17872         LDKu8slice ser_ref;
17873         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17874         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17875         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
17876         *ret_conv = ChannelTransactionParameters_read(ser_ref);
17877         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17878         return (long)ret_conv;
17879 }
17880
17881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17882         LDKDirectedChannelTransactionParameters this_ptr_conv;
17883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17884         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17885         DirectedChannelTransactionParameters_free(this_ptr_conv);
17886 }
17887
17888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
17889         LDKDirectedChannelTransactionParameters this_arg_conv;
17890         this_arg_conv.inner = (void*)(this_arg & (~1));
17891         this_arg_conv.is_owned = false;
17892         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
17893         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17894         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17895         long ret_ref = (long)ret_var.inner;
17896         if (ret_var.is_owned) {
17897                 ret_ref |= 1;
17898         }
17899         return ret_ref;
17900 }
17901
17902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
17903         LDKDirectedChannelTransactionParameters this_arg_conv;
17904         this_arg_conv.inner = (void*)(this_arg & (~1));
17905         this_arg_conv.is_owned = false;
17906         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
17907         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17908         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17909         long ret_ref = (long)ret_var.inner;
17910         if (ret_var.is_owned) {
17911                 ret_ref |= 1;
17912         }
17913         return ret_ref;
17914 }
17915
17916 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
17917         LDKDirectedChannelTransactionParameters this_arg_conv;
17918         this_arg_conv.inner = (void*)(this_arg & (~1));
17919         this_arg_conv.is_owned = false;
17920         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
17921         return ret_val;
17922 }
17923
17924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
17925         LDKDirectedChannelTransactionParameters this_arg_conv;
17926         this_arg_conv.inner = (void*)(this_arg & (~1));
17927         this_arg_conv.is_owned = false;
17928         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
17929         return ret_val;
17930 }
17931
17932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
17933         LDKDirectedChannelTransactionParameters this_arg_conv;
17934         this_arg_conv.inner = (void*)(this_arg & (~1));
17935         this_arg_conv.is_owned = false;
17936         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
17937         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17938         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17939         long ret_ref = (long)ret_var.inner;
17940         if (ret_var.is_owned) {
17941                 ret_ref |= 1;
17942         }
17943         return ret_ref;
17944 }
17945
17946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17947         LDKHolderCommitmentTransaction this_ptr_conv;
17948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17949         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
17950         HolderCommitmentTransaction_free(this_ptr_conv);
17951 }
17952
17953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
17954         LDKHolderCommitmentTransaction this_ptr_conv;
17955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17956         this_ptr_conv.is_owned = false;
17957         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17958         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
17959         return ret_arr;
17960 }
17961
17962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17963         LDKHolderCommitmentTransaction this_ptr_conv;
17964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17965         this_ptr_conv.is_owned = false;
17966         LDKSignature val_ref;
17967         CHECK((*env)->GetArrayLength(env, val) == 64);
17968         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17969         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
17970 }
17971
17972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
17973         LDKHolderCommitmentTransaction this_ptr_conv;
17974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17975         this_ptr_conv.is_owned = false;
17976         LDKCVec_SignatureZ val_constr;
17977         val_constr.datalen = (*env)->GetArrayLength(env, val);
17978         if (val_constr.datalen > 0)
17979                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17980         else
17981                 val_constr.data = NULL;
17982         for (size_t i = 0; i < val_constr.datalen; i++) {
17983                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
17984                 LDKSignature val_conv_8_ref;
17985                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
17986                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
17987                 val_constr.data[i] = val_conv_8_ref;
17988         }
17989         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
17990 }
17991
17992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17993         LDKHolderCommitmentTransaction orig_conv;
17994         orig_conv.inner = (void*)(orig & (~1));
17995         orig_conv.is_owned = false;
17996         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
17997         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17998         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17999         long ret_ref = (long)ret_var.inner;
18000         if (ret_var.is_owned) {
18001                 ret_ref |= 1;
18002         }
18003         return ret_ref;
18004 }
18005
18006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18007         LDKHolderCommitmentTransaction obj_conv;
18008         obj_conv.inner = (void*)(obj & (~1));
18009         obj_conv.is_owned = false;
18010         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
18011         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18012         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18013         CVec_u8Z_free(ret_var);
18014         return ret_arr;
18015 }
18016
18017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18018         LDKu8slice ser_ref;
18019         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18020         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18021         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
18022         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
18023         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18024         return (long)ret_conv;
18025 }
18026
18027 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) {
18028         LDKCommitmentTransaction commitment_tx_conv;
18029         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
18030         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
18031         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
18032         LDKSignature counterparty_sig_ref;
18033         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
18034         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
18035         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
18036         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
18037         if (counterparty_htlc_sigs_constr.datalen > 0)
18038                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18039         else
18040                 counterparty_htlc_sigs_constr.data = NULL;
18041         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
18042                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
18043                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
18044                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
18045                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
18046                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
18047         }
18048         LDKPublicKey holder_funding_key_ref;
18049         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
18050         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
18051         LDKPublicKey counterparty_funding_key_ref;
18052         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
18053         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
18054         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
18055         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18056         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18057         long ret_ref = (long)ret_var.inner;
18058         if (ret_var.is_owned) {
18059                 ret_ref |= 1;
18060         }
18061         return ret_ref;
18062 }
18063
18064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18065         LDKBuiltCommitmentTransaction this_ptr_conv;
18066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18067         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18068         BuiltCommitmentTransaction_free(this_ptr_conv);
18069 }
18070
18071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
18072         LDKBuiltCommitmentTransaction this_ptr_conv;
18073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18074         this_ptr_conv.is_owned = false;
18075         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
18076         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18077         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18078         Transaction_free(ret_var);
18079         return ret_arr;
18080 }
18081
18082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18083         LDKBuiltCommitmentTransaction this_ptr_conv;
18084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18085         this_ptr_conv.is_owned = false;
18086         LDKTransaction val_ref;
18087         val_ref.datalen = (*env)->GetArrayLength(env, val);
18088         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
18089         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18090         val_ref.data_is_owned = true;
18091         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
18092 }
18093
18094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18095         LDKBuiltCommitmentTransaction this_ptr_conv;
18096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18097         this_ptr_conv.is_owned = false;
18098         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18099         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
18100         return ret_arr;
18101 }
18102
18103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18104         LDKBuiltCommitmentTransaction this_ptr_conv;
18105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18106         this_ptr_conv.is_owned = false;
18107         LDKThirtyTwoBytes val_ref;
18108         CHECK((*env)->GetArrayLength(env, val) == 32);
18109         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18110         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
18111 }
18112
18113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
18114         LDKTransaction transaction_arg_ref;
18115         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
18116         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
18117         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
18118         transaction_arg_ref.data_is_owned = true;
18119         LDKThirtyTwoBytes txid_arg_ref;
18120         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
18121         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
18122         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
18123         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18124         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18125         long ret_ref = (long)ret_var.inner;
18126         if (ret_var.is_owned) {
18127                 ret_ref |= 1;
18128         }
18129         return ret_ref;
18130 }
18131
18132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18133         LDKBuiltCommitmentTransaction orig_conv;
18134         orig_conv.inner = (void*)(orig & (~1));
18135         orig_conv.is_owned = false;
18136         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
18137         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18138         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18139         long ret_ref = (long)ret_var.inner;
18140         if (ret_var.is_owned) {
18141                 ret_ref |= 1;
18142         }
18143         return ret_ref;
18144 }
18145
18146 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18147         LDKBuiltCommitmentTransaction obj_conv;
18148         obj_conv.inner = (void*)(obj & (~1));
18149         obj_conv.is_owned = false;
18150         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
18151         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18152         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18153         CVec_u8Z_free(ret_var);
18154         return ret_arr;
18155 }
18156
18157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18158         LDKu8slice ser_ref;
18159         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18160         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18161         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
18162         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
18163         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18164         return (long)ret_conv;
18165 }
18166
18167 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) {
18168         LDKBuiltCommitmentTransaction this_arg_conv;
18169         this_arg_conv.inner = (void*)(this_arg & (~1));
18170         this_arg_conv.is_owned = false;
18171         LDKu8slice funding_redeemscript_ref;
18172         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
18173         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
18174         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18175         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
18176         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
18177         return ret_arr;
18178 }
18179
18180 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) {
18181         LDKBuiltCommitmentTransaction this_arg_conv;
18182         this_arg_conv.inner = (void*)(this_arg & (~1));
18183         this_arg_conv.is_owned = false;
18184         unsigned char funding_key_arr[32];
18185         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
18186         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
18187         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
18188         LDKu8slice funding_redeemscript_ref;
18189         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
18190         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
18191         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18192         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
18193         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
18194         return ret_arr;
18195 }
18196
18197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18198         LDKCommitmentTransaction this_ptr_conv;
18199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18200         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18201         CommitmentTransaction_free(this_ptr_conv);
18202 }
18203
18204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18205         LDKCommitmentTransaction orig_conv;
18206         orig_conv.inner = (void*)(orig & (~1));
18207         orig_conv.is_owned = false;
18208         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
18209         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18210         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18211         long ret_ref = (long)ret_var.inner;
18212         if (ret_var.is_owned) {
18213                 ret_ref |= 1;
18214         }
18215         return ret_ref;
18216 }
18217
18218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
18219         LDKCommitmentTransaction obj_conv;
18220         obj_conv.inner = (void*)(obj & (~1));
18221         obj_conv.is_owned = false;
18222         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
18223         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18224         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18225         CVec_u8Z_free(ret_var);
18226         return ret_arr;
18227 }
18228
18229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18230         LDKu8slice ser_ref;
18231         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18232         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18233         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
18234         *ret_conv = CommitmentTransaction_read(ser_ref);
18235         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18236         return (long)ret_conv;
18237 }
18238
18239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
18240         LDKCommitmentTransaction this_arg_conv;
18241         this_arg_conv.inner = (void*)(this_arg & (~1));
18242         this_arg_conv.is_owned = false;
18243         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
18244         return ret_val;
18245 }
18246
18247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
18248         LDKCommitmentTransaction this_arg_conv;
18249         this_arg_conv.inner = (void*)(this_arg & (~1));
18250         this_arg_conv.is_owned = false;
18251         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
18252         return ret_val;
18253 }
18254
18255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
18256         LDKCommitmentTransaction this_arg_conv;
18257         this_arg_conv.inner = (void*)(this_arg & (~1));
18258         this_arg_conv.is_owned = false;
18259         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
18260         return ret_val;
18261 }
18262
18263 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
18264         LDKCommitmentTransaction this_arg_conv;
18265         this_arg_conv.inner = (void*)(this_arg & (~1));
18266         this_arg_conv.is_owned = false;
18267         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
18268         return ret_val;
18269 }
18270
18271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
18272         LDKCommitmentTransaction this_arg_conv;
18273         this_arg_conv.inner = (void*)(this_arg & (~1));
18274         this_arg_conv.is_owned = false;
18275         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
18276         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18277         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18278         long ret_ref = (long)ret_var.inner;
18279         if (ret_var.is_owned) {
18280                 ret_ref |= 1;
18281         }
18282         return ret_ref;
18283 }
18284
18285 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) {
18286         LDKCommitmentTransaction this_arg_conv;
18287         this_arg_conv.inner = (void*)(this_arg & (~1));
18288         this_arg_conv.is_owned = false;
18289         LDKDirectedChannelTransactionParameters channel_parameters_conv;
18290         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
18291         channel_parameters_conv.is_owned = false;
18292         LDKChannelPublicKeys broadcaster_keys_conv;
18293         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18294         broadcaster_keys_conv.is_owned = false;
18295         LDKChannelPublicKeys countersignatory_keys_conv;
18296         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18297         countersignatory_keys_conv.is_owned = false;
18298         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
18299         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
18300         return (long)ret_conv;
18301 }
18302
18303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18304         LDKTrustedCommitmentTransaction this_ptr_conv;
18305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18306         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18307         TrustedCommitmentTransaction_free(this_ptr_conv);
18308 }
18309
18310 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
18311         LDKTrustedCommitmentTransaction this_arg_conv;
18312         this_arg_conv.inner = (void*)(this_arg & (~1));
18313         this_arg_conv.is_owned = false;
18314         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18315         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
18316         return ret_arr;
18317 }
18318
18319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
18320         LDKTrustedCommitmentTransaction this_arg_conv;
18321         this_arg_conv.inner = (void*)(this_arg & (~1));
18322         this_arg_conv.is_owned = false;
18323         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
18324         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18325         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18326         long ret_ref = (long)ret_var.inner;
18327         if (ret_var.is_owned) {
18328                 ret_ref |= 1;
18329         }
18330         return ret_ref;
18331 }
18332
18333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
18334         LDKTrustedCommitmentTransaction this_arg_conv;
18335         this_arg_conv.inner = (void*)(this_arg & (~1));
18336         this_arg_conv.is_owned = false;
18337         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
18338         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18339         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18340         long ret_ref = (long)ret_var.inner;
18341         if (ret_var.is_owned) {
18342                 ret_ref |= 1;
18343         }
18344         return ret_ref;
18345 }
18346
18347 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) {
18348         LDKTrustedCommitmentTransaction this_arg_conv;
18349         this_arg_conv.inner = (void*)(this_arg & (~1));
18350         this_arg_conv.is_owned = false;
18351         unsigned char htlc_base_key_arr[32];
18352         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
18353         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
18354         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
18355         LDKDirectedChannelTransactionParameters channel_parameters_conv;
18356         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
18357         channel_parameters_conv.is_owned = false;
18358         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
18359         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
18360         return (long)ret_conv;
18361 }
18362
18363 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) {
18364         LDKPublicKey broadcaster_payment_basepoint_ref;
18365         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
18366         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
18367         LDKPublicKey countersignatory_payment_basepoint_ref;
18368         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
18369         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
18370         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
18371         return ret_val;
18372 }
18373
18374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18375         LDKInitFeatures orig_conv;
18376         orig_conv.inner = (void*)(orig & (~1));
18377         orig_conv.is_owned = false;
18378         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
18379         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18380         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18381         long ret_ref = (long)ret_var.inner;
18382         if (ret_var.is_owned) {
18383                 ret_ref |= 1;
18384         }
18385         return ret_ref;
18386 }
18387
18388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18389         LDKNodeFeatures orig_conv;
18390         orig_conv.inner = (void*)(orig & (~1));
18391         orig_conv.is_owned = false;
18392         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
18393         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18394         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18395         long ret_ref = (long)ret_var.inner;
18396         if (ret_var.is_owned) {
18397                 ret_ref |= 1;
18398         }
18399         return ret_ref;
18400 }
18401
18402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18403         LDKChannelFeatures orig_conv;
18404         orig_conv.inner = (void*)(orig & (~1));
18405         orig_conv.is_owned = false;
18406         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
18407         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18408         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18409         long ret_ref = (long)ret_var.inner;
18410         if (ret_var.is_owned) {
18411                 ret_ref |= 1;
18412         }
18413         return ret_ref;
18414 }
18415
18416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18417         LDKInitFeatures this_ptr_conv;
18418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18419         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18420         InitFeatures_free(this_ptr_conv);
18421 }
18422
18423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18424         LDKNodeFeatures this_ptr_conv;
18425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18426         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18427         NodeFeatures_free(this_ptr_conv);
18428 }
18429
18430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18431         LDKChannelFeatures this_ptr_conv;
18432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18433         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18434         ChannelFeatures_free(this_ptr_conv);
18435 }
18436
18437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
18438         LDKInitFeatures ret_var = InitFeatures_empty();
18439         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18440         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18441         long ret_ref = (long)ret_var.inner;
18442         if (ret_var.is_owned) {
18443                 ret_ref |= 1;
18444         }
18445         return ret_ref;
18446 }
18447
18448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
18449         LDKInitFeatures ret_var = InitFeatures_known();
18450         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18451         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18452         long ret_ref = (long)ret_var.inner;
18453         if (ret_var.is_owned) {
18454                 ret_ref |= 1;
18455         }
18456         return ret_ref;
18457 }
18458
18459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
18460         LDKNodeFeatures ret_var = NodeFeatures_empty();
18461         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18462         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18463         long ret_ref = (long)ret_var.inner;
18464         if (ret_var.is_owned) {
18465                 ret_ref |= 1;
18466         }
18467         return ret_ref;
18468 }
18469
18470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
18471         LDKNodeFeatures ret_var = NodeFeatures_known();
18472         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18473         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18474         long ret_ref = (long)ret_var.inner;
18475         if (ret_var.is_owned) {
18476                 ret_ref |= 1;
18477         }
18478         return ret_ref;
18479 }
18480
18481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
18482         LDKChannelFeatures ret_var = ChannelFeatures_empty();
18483         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18484         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18485         long ret_ref = (long)ret_var.inner;
18486         if (ret_var.is_owned) {
18487                 ret_ref |= 1;
18488         }
18489         return ret_ref;
18490 }
18491
18492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
18493         LDKChannelFeatures ret_var = ChannelFeatures_known();
18494         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18495         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18496         long ret_ref = (long)ret_var.inner;
18497         if (ret_var.is_owned) {
18498                 ret_ref |= 1;
18499         }
18500         return ret_ref;
18501 }
18502
18503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
18504         LDKInitFeatures obj_conv;
18505         obj_conv.inner = (void*)(obj & (~1));
18506         obj_conv.is_owned = false;
18507         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
18508         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18509         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18510         CVec_u8Z_free(ret_var);
18511         return ret_arr;
18512 }
18513
18514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
18515         LDKNodeFeatures obj_conv;
18516         obj_conv.inner = (void*)(obj & (~1));
18517         obj_conv.is_owned = false;
18518         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
18519         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18520         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18521         CVec_u8Z_free(ret_var);
18522         return ret_arr;
18523 }
18524
18525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
18526         LDKChannelFeatures obj_conv;
18527         obj_conv.inner = (void*)(obj & (~1));
18528         obj_conv.is_owned = false;
18529         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
18530         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18531         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18532         CVec_u8Z_free(ret_var);
18533         return ret_arr;
18534 }
18535
18536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18537         LDKu8slice ser_ref;
18538         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18539         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18540         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18541         *ret_conv = InitFeatures_read(ser_ref);
18542         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18543         return (long)ret_conv;
18544 }
18545
18546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18547         LDKu8slice ser_ref;
18548         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18549         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18550         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18551         *ret_conv = NodeFeatures_read(ser_ref);
18552         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18553         return (long)ret_conv;
18554 }
18555
18556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18557         LDKu8slice ser_ref;
18558         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18559         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18560         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18561         *ret_conv = ChannelFeatures_read(ser_ref);
18562         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18563         return (long)ret_conv;
18564 }
18565
18566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18567         LDKRouteHop this_ptr_conv;
18568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18569         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18570         RouteHop_free(this_ptr_conv);
18571 }
18572
18573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18574         LDKRouteHop this_ptr_conv;
18575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18576         this_ptr_conv.is_owned = false;
18577         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
18579         return ret_arr;
18580 }
18581
18582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18583         LDKRouteHop this_ptr_conv;
18584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18585         this_ptr_conv.is_owned = false;
18586         LDKPublicKey val_ref;
18587         CHECK((*env)->GetArrayLength(env, val) == 33);
18588         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18589         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
18590 }
18591
18592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18593         LDKRouteHop this_ptr_conv;
18594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18595         this_ptr_conv.is_owned = false;
18596         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
18597         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18598         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18599         long ret_ref = (long)ret_var.inner;
18600         if (ret_var.is_owned) {
18601                 ret_ref |= 1;
18602         }
18603         return ret_ref;
18604 }
18605
18606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18607         LDKRouteHop this_ptr_conv;
18608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18609         this_ptr_conv.is_owned = false;
18610         LDKNodeFeatures val_conv;
18611         val_conv.inner = (void*)(val & (~1));
18612         val_conv.is_owned = (val & 1) || (val == 0);
18613         val_conv = NodeFeatures_clone(&val_conv);
18614         RouteHop_set_node_features(&this_ptr_conv, val_conv);
18615 }
18616
18617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18618         LDKRouteHop this_ptr_conv;
18619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18620         this_ptr_conv.is_owned = false;
18621         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
18622         return ret_val;
18623 }
18624
18625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18626         LDKRouteHop this_ptr_conv;
18627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18628         this_ptr_conv.is_owned = false;
18629         RouteHop_set_short_channel_id(&this_ptr_conv, val);
18630 }
18631
18632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18633         LDKRouteHop this_ptr_conv;
18634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18635         this_ptr_conv.is_owned = false;
18636         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
18637         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18638         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18639         long ret_ref = (long)ret_var.inner;
18640         if (ret_var.is_owned) {
18641                 ret_ref |= 1;
18642         }
18643         return ret_ref;
18644 }
18645
18646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18647         LDKRouteHop this_ptr_conv;
18648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18649         this_ptr_conv.is_owned = false;
18650         LDKChannelFeatures val_conv;
18651         val_conv.inner = (void*)(val & (~1));
18652         val_conv.is_owned = (val & 1) || (val == 0);
18653         val_conv = ChannelFeatures_clone(&val_conv);
18654         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
18655 }
18656
18657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18658         LDKRouteHop this_ptr_conv;
18659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18660         this_ptr_conv.is_owned = false;
18661         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
18662         return ret_val;
18663 }
18664
18665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18666         LDKRouteHop this_ptr_conv;
18667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18668         this_ptr_conv.is_owned = false;
18669         RouteHop_set_fee_msat(&this_ptr_conv, val);
18670 }
18671
18672 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18673         LDKRouteHop this_ptr_conv;
18674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18675         this_ptr_conv.is_owned = false;
18676         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
18677         return ret_val;
18678 }
18679
18680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18681         LDKRouteHop this_ptr_conv;
18682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18683         this_ptr_conv.is_owned = false;
18684         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
18685 }
18686
18687 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) {
18688         LDKPublicKey pubkey_arg_ref;
18689         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
18690         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
18691         LDKNodeFeatures node_features_arg_conv;
18692         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
18693         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
18694         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
18695         LDKChannelFeatures channel_features_arg_conv;
18696         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
18697         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
18698         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
18699         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);
18700         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18701         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18702         long ret_ref = (long)ret_var.inner;
18703         if (ret_var.is_owned) {
18704                 ret_ref |= 1;
18705         }
18706         return ret_ref;
18707 }
18708
18709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18710         LDKRouteHop orig_conv;
18711         orig_conv.inner = (void*)(orig & (~1));
18712         orig_conv.is_owned = false;
18713         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
18714         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18715         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18716         long ret_ref = (long)ret_var.inner;
18717         if (ret_var.is_owned) {
18718                 ret_ref |= 1;
18719         }
18720         return ret_ref;
18721 }
18722
18723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18724         LDKRoute this_ptr_conv;
18725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18726         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18727         Route_free(this_ptr_conv);
18728 }
18729
18730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18731         LDKRoute this_ptr_conv;
18732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18733         this_ptr_conv.is_owned = false;
18734         LDKCVec_CVec_RouteHopZZ val_constr;
18735         val_constr.datalen = (*env)->GetArrayLength(env, val);
18736         if (val_constr.datalen > 0)
18737                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
18738         else
18739                 val_constr.data = NULL;
18740         for (size_t m = 0; m < val_constr.datalen; m++) {
18741                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
18742                 LDKCVec_RouteHopZ val_conv_12_constr;
18743                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
18744                 if (val_conv_12_constr.datalen > 0)
18745                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
18746                 else
18747                         val_conv_12_constr.data = NULL;
18748                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
18749                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
18750                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
18751                         LDKRouteHop val_conv_12_conv_10_conv;
18752                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
18753                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
18754                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
18755                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
18756                 }
18757                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
18758                 val_constr.data[m] = val_conv_12_constr;
18759         }
18760         Route_set_paths(&this_ptr_conv, val_constr);
18761 }
18762
18763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
18764         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
18765         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
18766         if (paths_arg_constr.datalen > 0)
18767                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
18768         else
18769                 paths_arg_constr.data = NULL;
18770         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
18771                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
18772                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
18773                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
18774                 if (paths_arg_conv_12_constr.datalen > 0)
18775                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
18776                 else
18777                         paths_arg_conv_12_constr.data = NULL;
18778                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
18779                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
18780                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
18781                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
18782                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
18783                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
18784                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
18785                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
18786                 }
18787                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
18788                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
18789         }
18790         LDKRoute ret_var = Route_new(paths_arg_constr);
18791         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18792         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18793         long ret_ref = (long)ret_var.inner;
18794         if (ret_var.is_owned) {
18795                 ret_ref |= 1;
18796         }
18797         return ret_ref;
18798 }
18799
18800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18801         LDKRoute orig_conv;
18802         orig_conv.inner = (void*)(orig & (~1));
18803         orig_conv.is_owned = false;
18804         LDKRoute ret_var = Route_clone(&orig_conv);
18805         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18806         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18807         long ret_ref = (long)ret_var.inner;
18808         if (ret_var.is_owned) {
18809                 ret_ref |= 1;
18810         }
18811         return ret_ref;
18812 }
18813
18814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
18815         LDKRoute obj_conv;
18816         obj_conv.inner = (void*)(obj & (~1));
18817         obj_conv.is_owned = false;
18818         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
18819         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18820         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18821         CVec_u8Z_free(ret_var);
18822         return ret_arr;
18823 }
18824
18825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18826         LDKu8slice ser_ref;
18827         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18828         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18829         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
18830         *ret_conv = Route_read(ser_ref);
18831         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18832         return (long)ret_conv;
18833 }
18834
18835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18836         LDKRouteHint this_ptr_conv;
18837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
18839         RouteHint_free(this_ptr_conv);
18840 }
18841
18842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18843         LDKRouteHint this_ptr_conv;
18844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18845         this_ptr_conv.is_owned = false;
18846         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
18848         return ret_arr;
18849 }
18850
18851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18852         LDKRouteHint this_ptr_conv;
18853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18854         this_ptr_conv.is_owned = false;
18855         LDKPublicKey val_ref;
18856         CHECK((*env)->GetArrayLength(env, val) == 33);
18857         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18858         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
18859 }
18860
18861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18862         LDKRouteHint this_ptr_conv;
18863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18864         this_ptr_conv.is_owned = false;
18865         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
18866         return ret_val;
18867 }
18868
18869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18870         LDKRouteHint this_ptr_conv;
18871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18872         this_ptr_conv.is_owned = false;
18873         RouteHint_set_short_channel_id(&this_ptr_conv, val);
18874 }
18875
18876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
18877         LDKRouteHint this_ptr_conv;
18878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18879         this_ptr_conv.is_owned = false;
18880         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
18881         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18882         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18883         long ret_ref = (long)ret_var.inner;
18884         if (ret_var.is_owned) {
18885                 ret_ref |= 1;
18886         }
18887         return ret_ref;
18888 }
18889
18890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18891         LDKRouteHint this_ptr_conv;
18892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18893         this_ptr_conv.is_owned = false;
18894         LDKRoutingFees val_conv;
18895         val_conv.inner = (void*)(val & (~1));
18896         val_conv.is_owned = (val & 1) || (val == 0);
18897         val_conv = RoutingFees_clone(&val_conv);
18898         RouteHint_set_fees(&this_ptr_conv, val_conv);
18899 }
18900
18901 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18902         LDKRouteHint this_ptr_conv;
18903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18904         this_ptr_conv.is_owned = false;
18905         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
18906         return ret_val;
18907 }
18908
18909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18910         LDKRouteHint this_ptr_conv;
18911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18912         this_ptr_conv.is_owned = false;
18913         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
18914 }
18915
18916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18917         LDKRouteHint this_ptr_conv;
18918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18919         this_ptr_conv.is_owned = false;
18920         int64_t ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
18921         return ret_val;
18922 }
18923
18924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18925         LDKRouteHint this_ptr_conv;
18926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18927         this_ptr_conv.is_owned = false;
18928         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
18929 }
18930
18931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_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) {
18932         LDKPublicKey src_node_id_arg_ref;
18933         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
18934         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
18935         LDKRoutingFees fees_arg_conv;
18936         fees_arg_conv.inner = (void*)(fees_arg & (~1));
18937         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
18938         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
18939         LDKRouteHint ret_var = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
18940         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18941         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18942         long ret_ref = (long)ret_var.inner;
18943         if (ret_var.is_owned) {
18944                 ret_ref |= 1;
18945         }
18946         return ret_ref;
18947 }
18948
18949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18950         LDKRouteHint orig_conv;
18951         orig_conv.inner = (void*)(orig & (~1));
18952         orig_conv.is_owned = false;
18953         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
18954         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18955         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18956         long ret_ref = (long)ret_var.inner;
18957         if (ret_var.is_owned) {
18958                 ret_ref |= 1;
18959         }
18960         return ret_ref;
18961 }
18962
18963 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 target, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
18964         LDKPublicKey our_node_id_ref;
18965         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
18966         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
18967         LDKNetworkGraph network_conv;
18968         network_conv.inner = (void*)(network & (~1));
18969         network_conv.is_owned = false;
18970         LDKPublicKey target_ref;
18971         CHECK((*env)->GetArrayLength(env, target) == 33);
18972         (*env)->GetByteArrayRegion(env, target, 0, 33, target_ref.compressed_form);
18973         LDKCVec_ChannelDetailsZ first_hops_constr;
18974         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
18975         if (first_hops_constr.datalen > 0)
18976                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18977         else
18978                 first_hops_constr.data = NULL;
18979         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
18980         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
18981                 int64_t first_hops_conv_16 = first_hops_vals[q];
18982                 LDKChannelDetails first_hops_conv_16_conv;
18983                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
18984                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
18985                 first_hops_constr.data[q] = first_hops_conv_16_conv;
18986         }
18987         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
18988         LDKCVec_RouteHintZ last_hops_constr;
18989         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
18990         if (last_hops_constr.datalen > 0)
18991                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
18992         else
18993                 last_hops_constr.data = NULL;
18994         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
18995         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
18996                 int64_t last_hops_conv_11 = last_hops_vals[l];
18997                 LDKRouteHint last_hops_conv_11_conv;
18998                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
18999                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
19000                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
19001                 last_hops_constr.data[l] = last_hops_conv_11_conv;
19002         }
19003         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
19004         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19005         if (logger_conv.free == LDKLogger_JCalls_free) {
19006                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19007                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19008         }
19009         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
19010         *ret_conv = get_route(our_node_id_ref, &network_conv, target_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
19011         FREE(first_hops_constr.data);
19012         return (long)ret_conv;
19013 }
19014
19015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19016         LDKNetworkGraph this_ptr_conv;
19017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19018         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
19019         NetworkGraph_free(this_ptr_conv);
19020 }
19021
19022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19023         LDKNetworkGraph orig_conv;
19024         orig_conv.inner = (void*)(orig & (~1));
19025         orig_conv.is_owned = false;
19026         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
19027         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19028         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19029         long ret_ref = (long)ret_var.inner;
19030         if (ret_var.is_owned) {
19031                 ret_ref |= 1;
19032         }
19033         return ret_ref;
19034 }
19035
19036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19037         LDKLockedNetworkGraph this_ptr_conv;
19038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19039         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
19040         LockedNetworkGraph_free(this_ptr_conv);
19041 }
19042
19043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19044         LDKNetGraphMsgHandler this_ptr_conv;
19045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19046         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
19047         NetGraphMsgHandler_free(this_ptr_conv);
19048 }
19049
19050 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) {
19051         LDKThirtyTwoBytes genesis_hash_ref;
19052         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
19053         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
19054         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
19055         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19056         if (logger_conv.free == LDKLogger_JCalls_free) {
19057                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19058                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19059         }
19060         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv, logger_conv);
19061         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19062         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19063         long ret_ref = (long)ret_var.inner;
19064         if (ret_var.is_owned) {
19065                 ret_ref |= 1;
19066         }
19067         return ret_ref;
19068 }
19069
19070 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) {
19071         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
19072         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19073         if (logger_conv.free == LDKLogger_JCalls_free) {
19074                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19075                 LDKLogger_JCalls_clone(logger_conv.this_arg);
19076         }
19077         LDKNetworkGraph network_graph_conv;
19078         network_graph_conv.inner = (void*)(network_graph & (~1));
19079         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
19080         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
19081         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
19082         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19083         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19084         long ret_ref = (long)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_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
19092         LDKNetGraphMsgHandler this_arg_conv;
19093         this_arg_conv.inner = (void*)(this_arg & (~1));
19094         this_arg_conv.is_owned = false;
19095         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
19096         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19097         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19098         long ret_ref = (long)ret_var.inner;
19099         if (ret_var.is_owned) {
19100                 ret_ref |= 1;
19101         }
19102         return ret_ref;
19103 }
19104
19105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
19106         LDKLockedNetworkGraph this_arg_conv;
19107         this_arg_conv.inner = (void*)(this_arg & (~1));
19108         this_arg_conv.is_owned = false;
19109         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
19110         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19111         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19112         long ret_ref = (long)ret_var.inner;
19113         if (ret_var.is_owned) {
19114                 ret_ref |= 1;
19115         }
19116         return ret_ref;
19117 }
19118
19119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
19120         LDKNetGraphMsgHandler this_arg_conv;
19121         this_arg_conv.inner = (void*)(this_arg & (~1));
19122         this_arg_conv.is_owned = false;
19123         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
19124         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
19125         return (long)ret;
19126 }
19127
19128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
19129         LDKNetGraphMsgHandler this_arg_conv;
19130         this_arg_conv.inner = (void*)(this_arg & (~1));
19131         this_arg_conv.is_owned = false;
19132         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
19133         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
19134         return (long)ret;
19135 }
19136
19137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19138         LDKDirectionalChannelInfo this_ptr_conv;
19139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19140         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
19141         DirectionalChannelInfo_free(this_ptr_conv);
19142 }
19143
19144 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
19145         LDKDirectionalChannelInfo this_ptr_conv;
19146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19147         this_ptr_conv.is_owned = false;
19148         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
19149         return ret_val;
19150 }
19151
19152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19153         LDKDirectionalChannelInfo this_ptr_conv;
19154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19155         this_ptr_conv.is_owned = false;
19156         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
19157 }
19158
19159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
19160         LDKDirectionalChannelInfo this_ptr_conv;
19161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19162         this_ptr_conv.is_owned = false;
19163         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
19164         return ret_val;
19165 }
19166
19167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19168         LDKDirectionalChannelInfo this_ptr_conv;
19169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19170         this_ptr_conv.is_owned = false;
19171         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
19172 }
19173
19174 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19175         LDKDirectionalChannelInfo this_ptr_conv;
19176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19177         this_ptr_conv.is_owned = false;
19178         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
19179         return ret_val;
19180 }
19181
19182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19183         LDKDirectionalChannelInfo this_ptr_conv;
19184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19185         this_ptr_conv.is_owned = false;
19186         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
19187 }
19188
19189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19190         LDKDirectionalChannelInfo this_ptr_conv;
19191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19192         this_ptr_conv.is_owned = false;
19193         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
19194         return ret_val;
19195 }
19196
19197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19198         LDKDirectionalChannelInfo this_ptr_conv;
19199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19200         this_ptr_conv.is_owned = false;
19201         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
19202 }
19203
19204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
19205         LDKDirectionalChannelInfo this_ptr_conv;
19206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19207         this_ptr_conv.is_owned = false;
19208         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
19209         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19210         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19211         long ret_ref = (long)ret_var.inner;
19212         if (ret_var.is_owned) {
19213                 ret_ref |= 1;
19214         }
19215         return ret_ref;
19216 }
19217
19218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19219         LDKDirectionalChannelInfo this_ptr_conv;
19220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19221         this_ptr_conv.is_owned = false;
19222         LDKRoutingFees val_conv;
19223         val_conv.inner = (void*)(val & (~1));
19224         val_conv.is_owned = (val & 1) || (val == 0);
19225         val_conv = RoutingFees_clone(&val_conv);
19226         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
19227 }
19228
19229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
19230         LDKDirectionalChannelInfo this_ptr_conv;
19231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19232         this_ptr_conv.is_owned = false;
19233         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
19234         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19235         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19236         long ret_ref = (long)ret_var.inner;
19237         if (ret_var.is_owned) {
19238                 ret_ref |= 1;
19239         }
19240         return ret_ref;
19241 }
19242
19243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19244         LDKDirectionalChannelInfo this_ptr_conv;
19245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19246         this_ptr_conv.is_owned = false;
19247         LDKChannelUpdate val_conv;
19248         val_conv.inner = (void*)(val & (~1));
19249         val_conv.is_owned = (val & 1) || (val == 0);
19250         val_conv = ChannelUpdate_clone(&val_conv);
19251         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
19252 }
19253
19254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19255         LDKDirectionalChannelInfo orig_conv;
19256         orig_conv.inner = (void*)(orig & (~1));
19257         orig_conv.is_owned = false;
19258         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
19259         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19260         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19261         long ret_ref = (long)ret_var.inner;
19262         if (ret_var.is_owned) {
19263                 ret_ref |= 1;
19264         }
19265         return ret_ref;
19266 }
19267
19268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
19269         LDKDirectionalChannelInfo obj_conv;
19270         obj_conv.inner = (void*)(obj & (~1));
19271         obj_conv.is_owned = false;
19272         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
19273         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19274         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19275         CVec_u8Z_free(ret_var);
19276         return ret_arr;
19277 }
19278
19279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19280         LDKu8slice ser_ref;
19281         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19282         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19283         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
19284         *ret_conv = DirectionalChannelInfo_read(ser_ref);
19285         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19286         return (long)ret_conv;
19287 }
19288
19289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19290         LDKChannelInfo this_ptr_conv;
19291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19292         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
19293         ChannelInfo_free(this_ptr_conv);
19294 }
19295
19296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19297         LDKChannelInfo this_ptr_conv;
19298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19299         this_ptr_conv.is_owned = false;
19300         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
19301         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19302         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19303         long ret_ref = (long)ret_var.inner;
19304         if (ret_var.is_owned) {
19305                 ret_ref |= 1;
19306         }
19307         return ret_ref;
19308 }
19309
19310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19311         LDKChannelInfo this_ptr_conv;
19312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19313         this_ptr_conv.is_owned = false;
19314         LDKChannelFeatures val_conv;
19315         val_conv.inner = (void*)(val & (~1));
19316         val_conv.is_owned = (val & 1) || (val == 0);
19317         val_conv = ChannelFeatures_clone(&val_conv);
19318         ChannelInfo_set_features(&this_ptr_conv, val_conv);
19319 }
19320
19321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
19322         LDKChannelInfo this_ptr_conv;
19323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19324         this_ptr_conv.is_owned = false;
19325         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19326         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
19327         return ret_arr;
19328 }
19329
19330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19331         LDKChannelInfo this_ptr_conv;
19332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19333         this_ptr_conv.is_owned = false;
19334         LDKPublicKey val_ref;
19335         CHECK((*env)->GetArrayLength(env, val) == 33);
19336         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19337         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
19338 }
19339
19340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
19341         LDKChannelInfo this_ptr_conv;
19342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19343         this_ptr_conv.is_owned = false;
19344         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
19345         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19346         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19347         long ret_ref = (long)ret_var.inner;
19348         if (ret_var.is_owned) {
19349                 ret_ref |= 1;
19350         }
19351         return ret_ref;
19352 }
19353
19354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19355         LDKChannelInfo this_ptr_conv;
19356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19357         this_ptr_conv.is_owned = false;
19358         LDKDirectionalChannelInfo val_conv;
19359         val_conv.inner = (void*)(val & (~1));
19360         val_conv.is_owned = (val & 1) || (val == 0);
19361         val_conv = DirectionalChannelInfo_clone(&val_conv);
19362         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
19363 }
19364
19365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
19366         LDKChannelInfo this_ptr_conv;
19367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19368         this_ptr_conv.is_owned = false;
19369         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19370         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
19371         return ret_arr;
19372 }
19373
19374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19375         LDKChannelInfo this_ptr_conv;
19376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19377         this_ptr_conv.is_owned = false;
19378         LDKPublicKey val_ref;
19379         CHECK((*env)->GetArrayLength(env, val) == 33);
19380         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19381         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
19382 }
19383
19384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
19385         LDKChannelInfo this_ptr_conv;
19386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19387         this_ptr_conv.is_owned = false;
19388         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
19389         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19390         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19391         long ret_ref = (long)ret_var.inner;
19392         if (ret_var.is_owned) {
19393                 ret_ref |= 1;
19394         }
19395         return ret_ref;
19396 }
19397
19398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19399         LDKChannelInfo this_ptr_conv;
19400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19401         this_ptr_conv.is_owned = false;
19402         LDKDirectionalChannelInfo val_conv;
19403         val_conv.inner = (void*)(val & (~1));
19404         val_conv.is_owned = (val & 1) || (val == 0);
19405         val_conv = DirectionalChannelInfo_clone(&val_conv);
19406         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
19407 }
19408
19409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
19410         LDKChannelInfo this_ptr_conv;
19411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19412         this_ptr_conv.is_owned = false;
19413         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
19414         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19415         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19416         long ret_ref = (long)ret_var.inner;
19417         if (ret_var.is_owned) {
19418                 ret_ref |= 1;
19419         }
19420         return ret_ref;
19421 }
19422
19423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19424         LDKChannelInfo this_ptr_conv;
19425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19426         this_ptr_conv.is_owned = false;
19427         LDKChannelAnnouncement val_conv;
19428         val_conv.inner = (void*)(val & (~1));
19429         val_conv.is_owned = (val & 1) || (val == 0);
19430         val_conv = ChannelAnnouncement_clone(&val_conv);
19431         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
19432 }
19433
19434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19435         LDKChannelInfo orig_conv;
19436         orig_conv.inner = (void*)(orig & (~1));
19437         orig_conv.is_owned = false;
19438         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
19439         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19440         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19441         long ret_ref = (long)ret_var.inner;
19442         if (ret_var.is_owned) {
19443                 ret_ref |= 1;
19444         }
19445         return ret_ref;
19446 }
19447
19448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
19449         LDKChannelInfo obj_conv;
19450         obj_conv.inner = (void*)(obj & (~1));
19451         obj_conv.is_owned = false;
19452         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
19453         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19454         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19455         CVec_u8Z_free(ret_var);
19456         return ret_arr;
19457 }
19458
19459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19460         LDKu8slice ser_ref;
19461         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19462         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19463         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19464         *ret_conv = ChannelInfo_read(ser_ref);
19465         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19466         return (long)ret_conv;
19467 }
19468
19469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19470         LDKRoutingFees this_ptr_conv;
19471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19472         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
19473         RoutingFees_free(this_ptr_conv);
19474 }
19475
19476 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19477         LDKRoutingFees this_ptr_conv;
19478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19479         this_ptr_conv.is_owned = false;
19480         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
19481         return ret_val;
19482 }
19483
19484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19485         LDKRoutingFees this_ptr_conv;
19486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19487         this_ptr_conv.is_owned = false;
19488         RoutingFees_set_base_msat(&this_ptr_conv, val);
19489 }
19490
19491 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
19492         LDKRoutingFees this_ptr_conv;
19493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19494         this_ptr_conv.is_owned = false;
19495         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
19496         return ret_val;
19497 }
19498
19499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19500         LDKRoutingFees this_ptr_conv;
19501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19502         this_ptr_conv.is_owned = false;
19503         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
19504 }
19505
19506 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) {
19507         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
19508         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19509         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19510         long ret_ref = (long)ret_var.inner;
19511         if (ret_var.is_owned) {
19512                 ret_ref |= 1;
19513         }
19514         return ret_ref;
19515 }
19516
19517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19518         LDKRoutingFees orig_conv;
19519         orig_conv.inner = (void*)(orig & (~1));
19520         orig_conv.is_owned = false;
19521         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
19522         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19523         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19524         long ret_ref = (long)ret_var.inner;
19525         if (ret_var.is_owned) {
19526                 ret_ref |= 1;
19527         }
19528         return ret_ref;
19529 }
19530
19531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19532         LDKu8slice ser_ref;
19533         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19534         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19535         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19536         *ret_conv = RoutingFees_read(ser_ref);
19537         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19538         return (long)ret_conv;
19539 }
19540
19541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
19542         LDKRoutingFees obj_conv;
19543         obj_conv.inner = (void*)(obj & (~1));
19544         obj_conv.is_owned = false;
19545         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
19546         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19547         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19548         CVec_u8Z_free(ret_var);
19549         return ret_arr;
19550 }
19551
19552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19553         LDKNodeAnnouncementInfo this_ptr_conv;
19554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19555         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
19556         NodeAnnouncementInfo_free(this_ptr_conv);
19557 }
19558
19559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19560         LDKNodeAnnouncementInfo this_ptr_conv;
19561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19562         this_ptr_conv.is_owned = false;
19563         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
19564         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19565         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19566         long ret_ref = (long)ret_var.inner;
19567         if (ret_var.is_owned) {
19568                 ret_ref |= 1;
19569         }
19570         return ret_ref;
19571 }
19572
19573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19574         LDKNodeAnnouncementInfo this_ptr_conv;
19575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19576         this_ptr_conv.is_owned = false;
19577         LDKNodeFeatures val_conv;
19578         val_conv.inner = (void*)(val & (~1));
19579         val_conv.is_owned = (val & 1) || (val == 0);
19580         val_conv = NodeFeatures_clone(&val_conv);
19581         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
19582 }
19583
19584 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
19585         LDKNodeAnnouncementInfo this_ptr_conv;
19586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19587         this_ptr_conv.is_owned = false;
19588         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
19589         return ret_val;
19590 }
19591
19592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19593         LDKNodeAnnouncementInfo this_ptr_conv;
19594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19595         this_ptr_conv.is_owned = false;
19596         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
19597 }
19598
19599 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
19600         LDKNodeAnnouncementInfo this_ptr_conv;
19601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19602         this_ptr_conv.is_owned = false;
19603         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
19604         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
19605         return ret_arr;
19606 }
19607
19608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19609         LDKNodeAnnouncementInfo this_ptr_conv;
19610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19611         this_ptr_conv.is_owned = false;
19612         LDKThreeBytes val_ref;
19613         CHECK((*env)->GetArrayLength(env, val) == 3);
19614         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
19615         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
19616 }
19617
19618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
19619         LDKNodeAnnouncementInfo this_ptr_conv;
19620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19621         this_ptr_conv.is_owned = false;
19622         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19623         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
19624         return ret_arr;
19625 }
19626
19627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19628         LDKNodeAnnouncementInfo this_ptr_conv;
19629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19630         this_ptr_conv.is_owned = false;
19631         LDKThirtyTwoBytes val_ref;
19632         CHECK((*env)->GetArrayLength(env, val) == 32);
19633         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19634         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
19635 }
19636
19637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19638         LDKNodeAnnouncementInfo this_ptr_conv;
19639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19640         this_ptr_conv.is_owned = false;
19641         LDKCVec_NetAddressZ val_constr;
19642         val_constr.datalen = (*env)->GetArrayLength(env, val);
19643         if (val_constr.datalen > 0)
19644                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19645         else
19646                 val_constr.data = NULL;
19647         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19648         for (size_t m = 0; m < val_constr.datalen; m++) {
19649                 int64_t val_conv_12 = val_vals[m];
19650                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19651                 FREE((void*)val_conv_12);
19652                 val_constr.data[m] = val_conv_12_conv;
19653         }
19654         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19655         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
19656 }
19657
19658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
19659         LDKNodeAnnouncementInfo this_ptr_conv;
19660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19661         this_ptr_conv.is_owned = false;
19662         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
19663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19665         long ret_ref = (long)ret_var.inner;
19666         if (ret_var.is_owned) {
19667                 ret_ref |= 1;
19668         }
19669         return ret_ref;
19670 }
19671
19672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19673         LDKNodeAnnouncementInfo this_ptr_conv;
19674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19675         this_ptr_conv.is_owned = false;
19676         LDKNodeAnnouncement val_conv;
19677         val_conv.inner = (void*)(val & (~1));
19678         val_conv.is_owned = (val & 1) || (val == 0);
19679         val_conv = NodeAnnouncement_clone(&val_conv);
19680         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
19681 }
19682
19683 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) {
19684         LDKNodeFeatures features_arg_conv;
19685         features_arg_conv.inner = (void*)(features_arg & (~1));
19686         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
19687         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
19688         LDKThreeBytes rgb_arg_ref;
19689         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
19690         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
19691         LDKThirtyTwoBytes alias_arg_ref;
19692         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
19693         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
19694         LDKCVec_NetAddressZ addresses_arg_constr;
19695         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
19696         if (addresses_arg_constr.datalen > 0)
19697                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19698         else
19699                 addresses_arg_constr.data = NULL;
19700         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
19701         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
19702                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
19703                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
19704                 FREE((void*)addresses_arg_conv_12);
19705                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
19706         }
19707         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
19708         LDKNodeAnnouncement announcement_message_arg_conv;
19709         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
19710         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
19711         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
19712         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
19713         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19714         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19715         long ret_ref = (long)ret_var.inner;
19716         if (ret_var.is_owned) {
19717                 ret_ref |= 1;
19718         }
19719         return ret_ref;
19720 }
19721
19722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19723         LDKNodeAnnouncementInfo orig_conv;
19724         orig_conv.inner = (void*)(orig & (~1));
19725         orig_conv.is_owned = false;
19726         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
19727         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19728         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19729         long ret_ref = (long)ret_var.inner;
19730         if (ret_var.is_owned) {
19731                 ret_ref |= 1;
19732         }
19733         return ret_ref;
19734 }
19735
19736 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
19737         LDKNodeAnnouncementInfo obj_conv;
19738         obj_conv.inner = (void*)(obj & (~1));
19739         obj_conv.is_owned = false;
19740         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
19741         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19742         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19743         CVec_u8Z_free(ret_var);
19744         return ret_arr;
19745 }
19746
19747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19748         LDKu8slice ser_ref;
19749         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19750         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19751         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19752         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
19753         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19754         return (long)ret_conv;
19755 }
19756
19757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19758         LDKNodeInfo this_ptr_conv;
19759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19760         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
19761         NodeInfo_free(this_ptr_conv);
19762 }
19763
19764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19765         LDKNodeInfo this_ptr_conv;
19766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19767         this_ptr_conv.is_owned = false;
19768         LDKCVec_u64Z val_constr;
19769         val_constr.datalen = (*env)->GetArrayLength(env, val);
19770         if (val_constr.datalen > 0)
19771                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19772         else
19773                 val_constr.data = NULL;
19774         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19775         for (size_t g = 0; g < val_constr.datalen; g++) {
19776                 int64_t val_conv_6 = val_vals[g];
19777                 val_constr.data[g] = val_conv_6;
19778         }
19779         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19780         NodeInfo_set_channels(&this_ptr_conv, val_constr);
19781 }
19782
19783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
19784         LDKNodeInfo this_ptr_conv;
19785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19786         this_ptr_conv.is_owned = false;
19787         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
19788         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19789         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19790         long ret_ref = (long)ret_var.inner;
19791         if (ret_var.is_owned) {
19792                 ret_ref |= 1;
19793         }
19794         return ret_ref;
19795 }
19796
19797 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) {
19798         LDKNodeInfo this_ptr_conv;
19799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19800         this_ptr_conv.is_owned = false;
19801         LDKRoutingFees val_conv;
19802         val_conv.inner = (void*)(val & (~1));
19803         val_conv.is_owned = (val & 1) || (val == 0);
19804         val_conv = RoutingFees_clone(&val_conv);
19805         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
19806 }
19807
19808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
19809         LDKNodeInfo this_ptr_conv;
19810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19811         this_ptr_conv.is_owned = false;
19812         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
19813         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19814         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19815         long ret_ref = (long)ret_var.inner;
19816         if (ret_var.is_owned) {
19817                 ret_ref |= 1;
19818         }
19819         return ret_ref;
19820 }
19821
19822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19823         LDKNodeInfo this_ptr_conv;
19824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19825         this_ptr_conv.is_owned = false;
19826         LDKNodeAnnouncementInfo val_conv;
19827         val_conv.inner = (void*)(val & (~1));
19828         val_conv.is_owned = (val & 1) || (val == 0);
19829         val_conv = NodeAnnouncementInfo_clone(&val_conv);
19830         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
19831 }
19832
19833 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) {
19834         LDKCVec_u64Z channels_arg_constr;
19835         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
19836         if (channels_arg_constr.datalen > 0)
19837                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19838         else
19839                 channels_arg_constr.data = NULL;
19840         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
19841         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
19842                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
19843                 channels_arg_constr.data[g] = channels_arg_conv_6;
19844         }
19845         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
19846         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
19847         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
19848         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
19849         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
19850         LDKNodeAnnouncementInfo announcement_info_arg_conv;
19851         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
19852         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
19853         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
19854         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
19855         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19856         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19857         long ret_ref = (long)ret_var.inner;
19858         if (ret_var.is_owned) {
19859                 ret_ref |= 1;
19860         }
19861         return ret_ref;
19862 }
19863
19864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19865         LDKNodeInfo orig_conv;
19866         orig_conv.inner = (void*)(orig & (~1));
19867         orig_conv.is_owned = false;
19868         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
19869         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19870         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19871         long ret_ref = (long)ret_var.inner;
19872         if (ret_var.is_owned) {
19873                 ret_ref |= 1;
19874         }
19875         return ret_ref;
19876 }
19877
19878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
19879         LDKNodeInfo obj_conv;
19880         obj_conv.inner = (void*)(obj & (~1));
19881         obj_conv.is_owned = false;
19882         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
19883         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19884         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19885         CVec_u8Z_free(ret_var);
19886         return ret_arr;
19887 }
19888
19889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19890         LDKu8slice ser_ref;
19891         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19892         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19893         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19894         *ret_conv = NodeInfo_read(ser_ref);
19895         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19896         return (long)ret_conv;
19897 }
19898
19899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
19900         LDKNetworkGraph obj_conv;
19901         obj_conv.inner = (void*)(obj & (~1));
19902         obj_conv.is_owned = false;
19903         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
19904         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19905         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19906         CVec_u8Z_free(ret_var);
19907         return ret_arr;
19908 }
19909
19910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19911         LDKu8slice ser_ref;
19912         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19913         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19914         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19915         *ret_conv = NetworkGraph_read(ser_ref);
19916         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19917         return (long)ret_conv;
19918 }
19919
19920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
19921         LDKThirtyTwoBytes genesis_hash_ref;
19922         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
19923         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
19924         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
19925         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19926         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19927         long ret_ref = (long)ret_var.inner;
19928         if (ret_var.is_owned) {
19929                 ret_ref |= 1;
19930         }
19931         return ret_ref;
19932 }
19933
19934 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) {
19935         LDKNetworkGraph this_arg_conv;
19936         this_arg_conv.inner = (void*)(this_arg & (~1));
19937         this_arg_conv.is_owned = false;
19938         LDKNodeAnnouncement msg_conv;
19939         msg_conv.inner = (void*)(msg & (~1));
19940         msg_conv.is_owned = false;
19941         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19942         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
19943         return (long)ret_conv;
19944 }
19945
19946 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) {
19947         LDKNetworkGraph this_arg_conv;
19948         this_arg_conv.inner = (void*)(this_arg & (~1));
19949         this_arg_conv.is_owned = false;
19950         LDKUnsignedNodeAnnouncement msg_conv;
19951         msg_conv.inner = (void*)(msg & (~1));
19952         msg_conv.is_owned = false;
19953         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19954         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
19955         return (long)ret_conv;
19956 }
19957
19958 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) {
19959         LDKNetworkGraph this_arg_conv;
19960         this_arg_conv.inner = (void*)(this_arg & (~1));
19961         this_arg_conv.is_owned = false;
19962         LDKChannelAnnouncement msg_conv;
19963         msg_conv.inner = (void*)(msg & (~1));
19964         msg_conv.is_owned = false;
19965         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
19966         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19967         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
19968         return (long)ret_conv;
19969 }
19970
19971 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) {
19972         LDKNetworkGraph this_arg_conv;
19973         this_arg_conv.inner = (void*)(this_arg & (~1));
19974         this_arg_conv.is_owned = false;
19975         LDKUnsignedChannelAnnouncement msg_conv;
19976         msg_conv.inner = (void*)(msg & (~1));
19977         msg_conv.is_owned = false;
19978         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
19979         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19980         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
19981         return (long)ret_conv;
19982 }
19983
19984 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) {
19985         LDKNetworkGraph this_arg_conv;
19986         this_arg_conv.inner = (void*)(this_arg & (~1));
19987         this_arg_conv.is_owned = false;
19988         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
19989 }
19990
19991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
19992         LDKNetworkGraph this_arg_conv;
19993         this_arg_conv.inner = (void*)(this_arg & (~1));
19994         this_arg_conv.is_owned = false;
19995         LDKChannelUpdate msg_conv;
19996         msg_conv.inner = (void*)(msg & (~1));
19997         msg_conv.is_owned = false;
19998         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19999         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
20000         return (long)ret_conv;
20001 }
20002
20003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
20004         LDKNetworkGraph this_arg_conv;
20005         this_arg_conv.inner = (void*)(this_arg & (~1));
20006         this_arg_conv.is_owned = false;
20007         LDKUnsignedChannelUpdate msg_conv;
20008         msg_conv.inner = (void*)(msg & (~1));
20009         msg_conv.is_owned = false;
20010         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20011         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
20012         return (long)ret_conv;
20013 }
20014