Compact giant type-conversion-strings if tree somewhat
[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 <assert.h>
7 // Always run a, then assert it is true:
8 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
9 // Assert a is true or do nothing
10 #define CHECK(a) DO_ASSERT(a)
11
12 // Running a leak check across all the allocations and frees of the JDK is a mess,
13 // so instead we implement our own naive leak checker here, relying on the -wrap
14 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
15 // and free'd in Rust or C across the generated bindings shared library.
16 #include <threads.h>
17 #include <execinfo.h>
18 #include <unistd.h>
19 static mtx_t allocation_mtx;
20
21 void __attribute__((constructor)) init_mtx() {
22         DO_ASSERT(mtx_init(&allocation_mtx, mtx_plain) == thrd_success);
23 }
24
25 #define BT_MAX 128
26 typedef struct allocation {
27         struct allocation* next;
28         void* ptr;
29         const char* struct_name;
30         void* bt[BT_MAX];
31         int bt_len;
32 } allocation;
33 static allocation* allocation_ll = NULL;
34
35 void* __real_malloc(size_t len);
36 void* __real_calloc(size_t nmemb, size_t len);
37 static void new_allocation(void* res, const char* struct_name) {
38         allocation* new_alloc = __real_malloc(sizeof(allocation));
39         new_alloc->ptr = res;
40         new_alloc->struct_name = struct_name;
41         new_alloc->bt_len = backtrace(new_alloc->bt, BT_MAX);
42         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
43         new_alloc->next = allocation_ll;
44         allocation_ll = new_alloc;
45         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
46 }
47 static void* MALLOC(size_t len, const char* struct_name) {
48         void* res = __real_malloc(len);
49         new_allocation(res, struct_name);
50         return res;
51 }
52 void __real_free(void* ptr);
53 static void alloc_freed(void* ptr) {
54         allocation* p = NULL;
55         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
56         allocation* it = allocation_ll;
57         while (it->ptr != ptr) {
58                 p = it; it = it->next;
59                 if (it == NULL) {
60                         fprintf(stderr, "Tried to free unknown pointer %p at:\n", ptr);
61                         void* bt[BT_MAX];
62                         int bt_len = backtrace(bt, BT_MAX);
63                         backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
64                         fprintf(stderr, "\n\n");
65                         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
66                         return; // addrsan should catch malloc-unknown and print more info than we have
67                 }
68         }
69         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
70         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
71         DO_ASSERT(it->ptr == ptr);
72         __real_free(it);
73 }
74 static void FREE(void* ptr) {
75         if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
76         alloc_freed(ptr);
77         __real_free(ptr);
78 }
79
80 void* __wrap_malloc(size_t len) {
81         void* res = __real_malloc(len);
82         new_allocation(res, "malloc call");
83         return res;
84 }
85 void* __wrap_calloc(size_t nmemb, size_t len) {
86         void* res = __real_calloc(nmemb, len);
87         new_allocation(res, "calloc call");
88         return res;
89 }
90 void __wrap_free(void* ptr) {
91         alloc_freed(ptr);
92         __real_free(ptr);
93 }
94
95 void* __real_realloc(void* ptr, size_t newlen);
96 void* __wrap_realloc(void* ptr, size_t len) {
97         alloc_freed(ptr);
98         void* res = __real_realloc(ptr, len);
99         new_allocation(res, "realloc call");
100         return res;
101 }
102 void __wrap_reallocarray(void* ptr, size_t new_sz) {
103         // Rust doesn't seem to use reallocarray currently
104         assert(false);
105 }
106
107 void __attribute__((destructor)) check_leaks() {
108         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
109                 fprintf(stderr, "%s %p remains:\n", a->struct_name, a->ptr);
110                 backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
111                 fprintf(stderr, "\n\n");
112         }
113         DO_ASSERT(allocation_ll == NULL);
114 }
115
116 static jmethodID ordinal_meth = NULL;
117 static jmethodID slicedef_meth = NULL;
118 static jclass slicedef_cls = NULL;
119 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
120         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
121         CHECK(ordinal_meth != NULL);
122         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
123         CHECK(slicedef_meth != NULL);
124         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
125         CHECK(slicedef_cls != NULL);
126 }
127
128 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
129         return *((bool*)ptr);
130 }
131 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
132         return *((long*)ptr);
133 }
134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
135         FREE((void*)ptr);
136 }
137 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * _env, jclass _b, jlong ptr, jlong len) {
138         jbyteArray ret_arr = (*_env)->NewByteArray(_env, len);
139         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, len, (unsigned char*)ptr);
140         return ret_arr;
141 }
142 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * _env, jclass _b, jlong slice_ptr) {
143         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
144         jbyteArray ret_arr = (*_env)->NewByteArray(_env, slice->datalen);
145         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, slice->datalen, slice->data);
146         return ret_arr;
147 }
148 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_bytes_1to_1u8_1vec (JNIEnv * _env, jclass _b, jbyteArray bytes) {
149         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
150         vec->datalen = (*_env)->GetArrayLength(_env, bytes);
151         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
152         (*_env)->GetByteArrayRegion (_env, bytes, 0, vec->datalen, vec->data);
153         return (long)vec;
154 }
155 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
156         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
157         txdata->datalen = (*env)->GetArrayLength(env, bytes);
158         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
159         txdata->data_is_owned = false;
160         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
161         return (long)txdata;
162 }
163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
164         LDKTransaction *tx = (LDKTransaction*)ptr;
165         tx->data_is_owned = true;
166         Transaction_free(*tx);
167         FREE((void*)ptr);
168 }
169 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
170         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
171         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
172         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
173         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
174         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
175         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
176         return (long)vec->datalen;
177 }
178 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * _env, jclass _b) {
179         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
180         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
181         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
182         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
183         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
184         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
185         vec->data = NULL;
186         vec->datalen = 0;
187         return (long)vec;
188 }
189
190 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
191 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
192 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
193 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
194
195 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass val) {
196         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
197                 case 0: return LDKAccessError_UnknownChain;
198                 case 1: return LDKAccessError_UnknownTx;
199         }
200         abort();
201 }
202 static jclass LDKAccessError_class = NULL;
203 static jfieldID LDKAccessError_LDKAccessError_UnknownChain = NULL;
204 static jfieldID LDKAccessError_LDKAccessError_UnknownTx = NULL;
205 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKAccessError_init (JNIEnv * env, jclass clz) {
206         LDKAccessError_class = (*env)->NewGlobalRef(env, clz);
207         CHECK(LDKAccessError_class != NULL);
208         LDKAccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/LDKAccessError;");
209         CHECK(LDKAccessError_LDKAccessError_UnknownChain != NULL);
210         LDKAccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/LDKAccessError;");
211         CHECK(LDKAccessError_LDKAccessError_UnknownTx != NULL);
212 }
213 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
214         switch (val) {
215                 case LDKAccessError_UnknownChain:
216                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownChain);
217                 case LDKAccessError_UnknownTx:
218                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownTx);
219                 default: abort();
220         }
221 }
222
223 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass val) {
224         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
225                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
226                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
227         }
228         abort();
229 }
230 static jclass LDKChannelMonitorUpdateErr_class = NULL;
231 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
232 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
233 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKChannelMonitorUpdateErr_init (JNIEnv * env, jclass clz) {
234         LDKChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
235         CHECK(LDKChannelMonitorUpdateErr_class != NULL);
236         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
237         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
238         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
239         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
240 }
241 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
242         switch (val) {
243                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
244                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
245                 case LDKChannelMonitorUpdateErr_PermanentFailure:
246                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
247                 default: abort();
248         }
249 }
250
251 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass val) {
252         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
253                 case 0: return LDKConfirmationTarget_Background;
254                 case 1: return LDKConfirmationTarget_Normal;
255                 case 2: return LDKConfirmationTarget_HighPriority;
256         }
257         abort();
258 }
259 static jclass LDKConfirmationTarget_class = NULL;
260 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Background = NULL;
261 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
262 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
263 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKConfirmationTarget_init (JNIEnv * env, jclass clz) {
264         LDKConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
265         CHECK(LDKConfirmationTarget_class != NULL);
266         LDKConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/LDKConfirmationTarget;");
267         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Background != NULL);
268         LDKConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/LDKConfirmationTarget;");
269         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
270         LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/LDKConfirmationTarget;");
271         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
272 }
273 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
274         switch (val) {
275                 case LDKConfirmationTarget_Background:
276                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Background);
277                 case LDKConfirmationTarget_Normal:
278                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Normal);
279                 case LDKConfirmationTarget_HighPriority:
280                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_HighPriority);
281                 default: abort();
282         }
283 }
284
285 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass val) {
286         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
287                 case 0: return LDKLevel_Off;
288                 case 1: return LDKLevel_Error;
289                 case 2: return LDKLevel_Warn;
290                 case 3: return LDKLevel_Info;
291                 case 4: return LDKLevel_Debug;
292                 case 5: return LDKLevel_Trace;
293         }
294         abort();
295 }
296 static jclass LDKLevel_class = NULL;
297 static jfieldID LDKLevel_LDKLevel_Off = NULL;
298 static jfieldID LDKLevel_LDKLevel_Error = NULL;
299 static jfieldID LDKLevel_LDKLevel_Warn = NULL;
300 static jfieldID LDKLevel_LDKLevel_Info = NULL;
301 static jfieldID LDKLevel_LDKLevel_Debug = NULL;
302 static jfieldID LDKLevel_LDKLevel_Trace = NULL;
303 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKLevel_init (JNIEnv * env, jclass clz) {
304         LDKLevel_class = (*env)->NewGlobalRef(env, clz);
305         CHECK(LDKLevel_class != NULL);
306         LDKLevel_LDKLevel_Off = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
307         CHECK(LDKLevel_LDKLevel_Off != NULL);
308         LDKLevel_LDKLevel_Error = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
309         CHECK(LDKLevel_LDKLevel_Error != NULL);
310         LDKLevel_LDKLevel_Warn = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
311         CHECK(LDKLevel_LDKLevel_Warn != NULL);
312         LDKLevel_LDKLevel_Info = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
313         CHECK(LDKLevel_LDKLevel_Info != NULL);
314         LDKLevel_LDKLevel_Debug = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
315         CHECK(LDKLevel_LDKLevel_Debug != NULL);
316         LDKLevel_LDKLevel_Trace = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
317         CHECK(LDKLevel_LDKLevel_Trace != NULL);
318 }
319 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
320         switch (val) {
321                 case LDKLevel_Off:
322                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Off);
323                 case LDKLevel_Error:
324                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Error);
325                 case LDKLevel_Warn:
326                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Warn);
327                 case LDKLevel_Info:
328                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Info);
329                 case LDKLevel_Debug:
330                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Debug);
331                 case LDKLevel_Trace:
332                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Trace);
333                 default: abort();
334         }
335 }
336
337 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass val) {
338         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
339                 case 0: return LDKNetwork_Bitcoin;
340                 case 1: return LDKNetwork_Testnet;
341                 case 2: return LDKNetwork_Regtest;
342         }
343         abort();
344 }
345 static jclass LDKNetwork_class = NULL;
346 static jfieldID LDKNetwork_LDKNetwork_Bitcoin = NULL;
347 static jfieldID LDKNetwork_LDKNetwork_Testnet = NULL;
348 static jfieldID LDKNetwork_LDKNetwork_Regtest = NULL;
349 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKNetwork_init (JNIEnv * env, jclass clz) {
350         LDKNetwork_class = (*env)->NewGlobalRef(env, clz);
351         CHECK(LDKNetwork_class != NULL);
352         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
353         CHECK(LDKNetwork_LDKNetwork_Bitcoin != NULL);
354         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
355         CHECK(LDKNetwork_LDKNetwork_Testnet != NULL);
356         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
357         CHECK(LDKNetwork_LDKNetwork_Regtest != NULL);
358 }
359 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
360         switch (val) {
361                 case LDKNetwork_Bitcoin:
362                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Bitcoin);
363                 case LDKNetwork_Testnet:
364                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Testnet);
365                 case LDKNetwork_Regtest:
366                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Regtest);
367                 default: abort();
368         }
369 }
370
371 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass val) {
372         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
373                 case 0: return LDKSecp256k1Error_IncorrectSignature;
374                 case 1: return LDKSecp256k1Error_InvalidMessage;
375                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
376                 case 3: return LDKSecp256k1Error_InvalidSignature;
377                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
378                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
379                 case 6: return LDKSecp256k1Error_InvalidTweak;
380                 case 7: return LDKSecp256k1Error_NotEnoughMemory;
381                 case 8: return LDKSecp256k1Error_CallbackPanicked;
382         }
383         abort();
384 }
385 static jclass LDKSecp256k1Error_class = NULL;
386 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
387 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
388 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
389 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
390 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
391 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
392 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
393 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
394 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = NULL;
395 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKSecp256k1Error_init (JNIEnv * env, jclass clz) {
396         LDKSecp256k1Error_class = (*env)->NewGlobalRef(env, clz);
397         CHECK(LDKSecp256k1Error_class != NULL);
398         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
399         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
400         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
401         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
402         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
403         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
404         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
405         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
406         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
407         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
408         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
409         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
410         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
411         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
412         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
413         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
414         LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_CallbackPanicked", "Lorg/ldk/enums/LDKSecp256k1Error;");
415         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked != NULL);
416 }
417 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
418         switch (val) {
419                 case LDKSecp256k1Error_IncorrectSignature:
420                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature);
421                 case LDKSecp256k1Error_InvalidMessage:
422                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage);
423                 case LDKSecp256k1Error_InvalidPublicKey:
424                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
425                 case LDKSecp256k1Error_InvalidSignature:
426                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature);
427                 case LDKSecp256k1Error_InvalidSecretKey:
428                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
429                 case LDKSecp256k1Error_InvalidRecoveryId:
430                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
431                 case LDKSecp256k1Error_InvalidTweak:
432                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak);
433                 case LDKSecp256k1Error_NotEnoughMemory:
434                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
435                 case LDKSecp256k1Error_CallbackPanicked:
436                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked);
437                 default: abort();
438         }
439 }
440
441 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u8_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
442         LDKCVecTempl_u8 *vec = (LDKCVecTempl_u8*)ptr;
443         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint8_t));
444 }
445 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u8_1new(JNIEnv *env, jclass _b, jbyteArray elems){
446         LDKCVecTempl_u8 *ret = MALLOC(sizeof(LDKCVecTempl_u8), "LDKCVecTempl_u8");
447         ret->datalen = (*env)->GetArrayLength(env, elems);
448         if (ret->datalen == 0) {
449                 ret->data = NULL;
450         } else {
451                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVecTempl_u8 Data");
452                 jbyte *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
453                 for (size_t i = 0; i < ret->datalen; i++) {
454                         ret->data[i] = java_elems[i];
455                 }
456                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
457         }
458         return (long)ret;
459 }
460 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
461         LDKC2TupleTempl_usize__Transaction* ret = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction), "LDKC2TupleTempl_usize__Transaction");
462         ret->a = a;
463         LDKTransaction b_conv = *(LDKTransaction*)b;
464         ret->b = b_conv;
465         return (long)ret;
466 }
467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
468         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
469 }
470 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
471         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
472         CHECK(val->result_ok);
473         return *val->contents.result;
474 }
475 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
476         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
477         CHECK(!val->result_ok);
478         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(_env, (*val->contents.err));
479         return err_conv;
480 }
481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
482         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
483 }
484 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
485         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
486         CHECK(val->result_ok);
487         return *val->contents.result;
488 }
489 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
490         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
491         CHECK(!val->result_ok);
492         LDKMonitorUpdateError err_var = (*val->contents.err);
493         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
494         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
495         long err_ref = (long)err_var.inner & ~1;
496         return err_ref;
497 }
498 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) {
499         LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z");
500         LDKOutPoint a_conv;
501         a_conv.inner = (void*)(a & (~1));
502         a_conv.is_owned = (a & 1) || (a == 0);
503         if (a_conv.inner != NULL)
504                 a_conv = OutPoint_clone(&a_conv);
505         ret->a = a_conv;
506         LDKCVec_u8Z b_ref;
507         b_ref.data = (*_env)->GetByteArrayElements (_env, b, NULL);
508         b_ref.datalen = (*_env)->GetArrayLength (_env, b);
509         ret->b = b_ref;
510         //TODO: Really need to call (*_env)->ReleaseByteArrayElements(_env, b, (int8_t*)b_ref.data, 0); here
511         return (long)ret;
512 }
513 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
514         LDKCVecTempl_TxOut *vec = (LDKCVecTempl_TxOut*)ptr;
515         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTxOut));
516 }
517 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
518         LDKCVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_TxOut), "LDKCVecTempl_TxOut");
519         ret->datalen = (*env)->GetArrayLength(env, elems);
520         if (ret->datalen == 0) {
521                 ret->data = NULL;
522         } else {
523                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVecTempl_TxOut Data");
524                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
525                 for (size_t i = 0; i < ret->datalen; i++) {
526                         jlong arr_elem = java_elems[i];
527                         LDKTxOut arr_elem_conv = *(LDKTxOut*)arr_elem;
528                         FREE((void*)arr_elem);
529                         ret->data[i] = arr_elem_conv;
530                 }
531                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
532         }
533         return (long)ret;
534 }
535 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlongArray b) {
536         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut* ret = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
537         LDKThirtyTwoBytes a_ref;
538         CHECK((*_env)->GetArrayLength (_env, a) == 32);
539         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
540         ret->a = a_ref;
541         LDKCVecTempl_TxOut b_constr;
542         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
543         if (b_constr.datalen > 0)
544                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKTxOut), "LDKCVecTempl_TxOut Elements");
545         else
546                 b_constr.data = NULL;
547         long* b_vals = (*_env)->GetLongArrayElements (_env, b, NULL);
548         for (size_t h = 0; h < b_constr.datalen; h++) {
549                 long arr_conv_7 = b_vals[h];
550                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
551                 FREE((void*)arr_conv_7);
552                 b_constr.data[h] = arr_conv_7_conv;
553         }
554         (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0);
555         ret->b = b_constr;
556         return (long)ret;
557 }
558 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
559         LDKC2TupleTempl_u64__u64* ret = MALLOC(sizeof(LDKC2TupleTempl_u64__u64), "LDKC2TupleTempl_u64__u64");
560         ret->a = a;
561         ret->b = b;
562         return (long)ret;
563 }
564 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
565         LDKCVecTempl_Signature *vec = (LDKCVecTempl_Signature*)ptr;
566         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSignature));
567 }
568 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jbyteArray a, jobjectArray b) {
569         LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature");
570         LDKSignature a_ref;
571         CHECK((*_env)->GetArrayLength (_env, a) == 64);
572         (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form);
573         ret->a = a_ref;
574         LDKCVecTempl_Signature b_constr;
575         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
576         if (b_constr.datalen > 0)
577                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVecTempl_Signature Elements");
578         else
579                 b_constr.data = NULL;
580         for (size_t i = 0; i < b_constr.datalen; i++) {
581                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, b, i);
582                 LDKSignature arr_conv_8_ref;
583                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
584                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
585                 b_constr.data[i] = arr_conv_8_ref;
586         }
587         ret->b = b_constr;
588         return (long)ret;
589 }
590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
591         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
592 }
593 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
594         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
595         CHECK(val->result_ok);
596         long res_ref = (long)&(*val->contents.result);
597         return res_ref;
598 }
599 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
600         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
601         CHECK(!val->result_ok);
602         return *val->contents.err;
603 }
604 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
605         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
606 }
607 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
608         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
609         CHECK(val->result_ok);
610         jbyteArray res_arr = (*_env)->NewByteArray(_env, 64);
611         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 64, (*val->contents.result).compact_form);
612         return res_arr;
613 }
614 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
615         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
616         CHECK(!val->result_ok);
617         return *val->contents.err;
618 }
619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
620         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
621 }
622 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
623         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
624         CHECK(val->result_ok);
625         LDKCVecTempl_Signature res_var = (*val->contents.result);
626         jobjectArray res_arr = (*_env)->NewObjectArray(_env, res_var.datalen, NULL, NULL);
627         for (size_t i = 0; i < res_var.datalen; i++) {
628                 jbyteArray arr_conv_8_arr = (*_env)->NewByteArray(_env, 64);
629                 (*_env)->SetByteArrayRegion(_env, arr_conv_8_arr, 0, 64, res_var.data[i].compact_form);
630                 (*_env)->SetObjectArrayElement(_env, res_arr, i, arr_conv_8_arr);
631         }
632         return res_arr;
633 }
634 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
635         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
636         CHECK(!val->result_ok);
637         return *val->contents.err;
638 }
639 static jclass LDKAPIError_APIMisuseError_class = NULL;
640 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
641 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
642 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
643 static jclass LDKAPIError_RouteError_class = NULL;
644 static jmethodID LDKAPIError_RouteError_meth = NULL;
645 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
646 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
647 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
648 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv * env, jclass _a) {
650         LDKAPIError_APIMisuseError_class =
651                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
652         CHECK(LDKAPIError_APIMisuseError_class != NULL);
653         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
654         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
655         LDKAPIError_FeeRateTooHigh_class =
656                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
657         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
658         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
659         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
660         LDKAPIError_RouteError_class =
661                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
662         CHECK(LDKAPIError_RouteError_class != NULL);
663         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
664         CHECK(LDKAPIError_RouteError_meth != NULL);
665         LDKAPIError_ChannelUnavailable_class =
666                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
667         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
668         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
669         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
670         LDKAPIError_MonitorUpdateFailed_class =
671                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
672         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
673         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
674         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
675 }
676 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
677         LDKAPIError *obj = (LDKAPIError*)ptr;
678         switch(obj->tag) {
679                 case LDKAPIError_APIMisuseError: {
680                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
681                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
682                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
683                         return (*_env)->NewObject(_env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
684                 }
685                 case LDKAPIError_FeeRateTooHigh: {
686                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
687                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
688                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
689                         return (*_env)->NewObject(_env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
690                 }
691                 case LDKAPIError_RouteError: {
692                         LDKStr err_str = obj->route_error.err;
693                         char* err_buf = MALLOC(err_str.len + 1, "str conv buf");
694                         memcpy(err_buf, err_str.chars, err_str.len);
695                         err_buf[err_str.len] = 0;
696                         jstring err_conv = (*_env)->NewStringUTF(_env, err_str.chars);
697                         FREE(err_buf);
698                         return (*_env)->NewObject(_env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
699                 }
700                 case LDKAPIError_ChannelUnavailable: {
701                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
702                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
703                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
704                         return (*_env)->NewObject(_env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
705                 }
706                 case LDKAPIError_MonitorUpdateFailed: {
707                         return (*_env)->NewObject(_env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
708                 }
709                 default: abort();
710         }
711 }
712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
713         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
714 }
715 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
716         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
717         CHECK(val->result_ok);
718         return *val->contents.result;
719 }
720 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
721         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
722         CHECK(!val->result_ok);
723         long err_ref = (long)&(*val->contents.err);
724         return err_ref;
725 }
726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
727         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
728 }
729 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
730         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
731         CHECK(val->result_ok);
732         return *val->contents.result;
733 }
734 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
735         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
736         CHECK(!val->result_ok);
737         LDKPaymentSendFailure err_var = (*val->contents.err);
738         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
739         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
740         long err_ref = (long)err_var.inner & ~1;
741         return err_ref;
742 }
743 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *_env, jclass _b, jlong a, jlong b, jlong c) {
744         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate* ret = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
745         LDKChannelAnnouncement a_conv;
746         a_conv.inner = (void*)(a & (~1));
747         a_conv.is_owned = (a & 1) || (a == 0);
748         if (a_conv.inner != NULL)
749                 a_conv = ChannelAnnouncement_clone(&a_conv);
750         ret->a = a_conv;
751         LDKChannelUpdate b_conv;
752         b_conv.inner = (void*)(b & (~1));
753         b_conv.is_owned = (b & 1) || (b == 0);
754         if (b_conv.inner != NULL)
755                 b_conv = ChannelUpdate_clone(&b_conv);
756         ret->b = b_conv;
757         LDKChannelUpdate c_conv;
758         c_conv.inner = (void*)(c & (~1));
759         c_conv.is_owned = (c & 1) || (c == 0);
760         if (c_conv.inner != NULL)
761                 c_conv = ChannelUpdate_clone(&c_conv);
762         ret->c = c_conv;
763         return (long)ret;
764 }
765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
766         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
767 }
768 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
769         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
770         CHECK(val->result_ok);
771         return *val->contents.result;
772 }
773 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
774         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
775         CHECK(!val->result_ok);
776         LDKPeerHandleError err_var = (*val->contents.err);
777         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
778         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
779         long err_ref = (long)err_var.inner & ~1;
780         return err_ref;
781 }
782 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) {
783         LDKC2TupleTempl_HTLCOutputInCommitment__Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature), "LDKC2TupleTempl_HTLCOutputInCommitment__Signature");
784         LDKHTLCOutputInCommitment a_conv;
785         a_conv.inner = (void*)(a & (~1));
786         a_conv.is_owned = (a & 1) || (a == 0);
787         if (a_conv.inner != NULL)
788                 a_conv = HTLCOutputInCommitment_clone(&a_conv);
789         ret->a = a_conv;
790         LDKSignature b_ref;
791         CHECK((*_env)->GetArrayLength (_env, b) == 64);
792         (*_env)->GetByteArrayRegion (_env, b, 0, 64, b_ref.compact_form);
793         ret->b = b_ref;
794         return (long)ret;
795 }
796 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
797 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
798 static jclass LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class = NULL;
799 static jmethodID LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = NULL;
800 static jclass LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class = NULL;
801 static jmethodID LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = NULL;
802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv * env, jclass _a) {
803         LDKSpendableOutputDescriptor_StaticOutput_class =
804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
805         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
806         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
807         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
808         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class =
809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DynamicOutputP2WSH;"));
810         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class != NULL);
811         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, "<init>", "(J[BSJJ[B)V");
812         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth != NULL);
813         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class =
814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutputCounterpartyPayment;"));
815         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class != NULL);
816         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, "<init>", "(JJJ)V");
817         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth != NULL);
818 }
819 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
820         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
821         switch(obj->tag) {
822                 case LDKSpendableOutputDescriptor_StaticOutput: {
823                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
824                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
825                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
826                         long outpoint_ref = (long)outpoint_var.inner & ~1;
827                         long output_ref = (long)&obj->static_output.output;
828                         return (*_env)->NewObject(_env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, output_ref);
829                 }
830                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
831                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
832                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
833                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
834                         long outpoint_ref = (long)outpoint_var.inner & ~1;
835                         jbyteArray per_commitment_point_arr = (*_env)->NewByteArray(_env, 33);
836                         (*_env)->SetByteArrayRegion(_env, per_commitment_point_arr, 0, 33, obj->dynamic_output_p2wsh.per_commitment_point.compressed_form);
837                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
838                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
839                         jbyteArray revocation_pubkey_arr = (*_env)->NewByteArray(_env, 33);
840                         (*_env)->SetByteArrayRegion(_env, revocation_pubkey_arr, 0, 33, obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form);
841                         return (*_env)->NewObject(_env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth, outpoint_ref, per_commitment_point_arr, obj->dynamic_output_p2wsh.to_self_delay, output_ref, key_derivation_params_ref, revocation_pubkey_arr);
842                 }
843                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
844                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
845                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
846                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
847                         long outpoint_ref = (long)outpoint_var.inner & ~1;
848                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
849                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
850                         return (*_env)->NewObject(_env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth, outpoint_ref, output_ref, key_derivation_params_ref);
851                 }
852                 default: abort();
853         }
854 }
855 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
856         LDKCVecTempl_SpendableOutputDescriptor *vec = (LDKCVecTempl_SpendableOutputDescriptor*)ptr;
857         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSpendableOutputDescriptor));
858 }
859 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1new(JNIEnv *env, jclass _b, jlongArray elems){
860         LDKCVecTempl_SpendableOutputDescriptor *ret = MALLOC(sizeof(LDKCVecTempl_SpendableOutputDescriptor), "LDKCVecTempl_SpendableOutputDescriptor");
861         ret->datalen = (*env)->GetArrayLength(env, elems);
862         if (ret->datalen == 0) {
863                 ret->data = NULL;
864         } else {
865                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVecTempl_SpendableOutputDescriptor Data");
866                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
867                 for (size_t i = 0; i < ret->datalen; i++) {
868                         jlong arr_elem = java_elems[i];
869                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
870                         FREE((void*)arr_elem);
871                         ret->data[i] = arr_elem_conv;
872                 }
873                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
874         }
875         return (long)ret;
876 }
877 static jclass LDKEvent_FundingGenerationReady_class = NULL;
878 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
879 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
880 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
881 static jclass LDKEvent_PaymentReceived_class = NULL;
882 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
883 static jclass LDKEvent_PaymentSent_class = NULL;
884 static jmethodID LDKEvent_PaymentSent_meth = NULL;
885 static jclass LDKEvent_PaymentFailed_class = NULL;
886 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
887 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
888 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
889 static jclass LDKEvent_SpendableOutputs_class = NULL;
890 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv * env, jclass _a) {
892         LDKEvent_FundingGenerationReady_class =
893                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
894         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
895         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
896         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
897         LDKEvent_FundingBroadcastSafe_class =
898                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
899         CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
900         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
901         CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
902         LDKEvent_PaymentReceived_class =
903                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
904         CHECK(LDKEvent_PaymentReceived_class != NULL);
905         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
906         CHECK(LDKEvent_PaymentReceived_meth != NULL);
907         LDKEvent_PaymentSent_class =
908                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
909         CHECK(LDKEvent_PaymentSent_class != NULL);
910         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
911         CHECK(LDKEvent_PaymentSent_meth != NULL);
912         LDKEvent_PaymentFailed_class =
913                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
914         CHECK(LDKEvent_PaymentFailed_class != NULL);
915         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
916         CHECK(LDKEvent_PaymentFailed_meth != NULL);
917         LDKEvent_PendingHTLCsForwardable_class =
918                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
919         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
920         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
921         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
922         LDKEvent_SpendableOutputs_class =
923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
924         CHECK(LDKEvent_SpendableOutputs_class != NULL);
925         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
926         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
927 }
928 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
929         LDKEvent *obj = (LDKEvent*)ptr;
930         switch(obj->tag) {
931                 case LDKEvent_FundingGenerationReady: {
932                         jbyteArray temporary_channel_id_arr = (*_env)->NewByteArray(_env, 32);
933                         (*_env)->SetByteArrayRegion(_env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
934                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
935                         jbyteArray output_script_arr = (*_env)->NewByteArray(_env, output_script_var.datalen);
936                         (*_env)->SetByteArrayRegion(_env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
937                         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);
938                 }
939                 case LDKEvent_FundingBroadcastSafe: {
940                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
941                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
942                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
943                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
944                         return (*_env)->NewObject(_env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
945                 }
946                 case LDKEvent_PaymentReceived: {
947                         jbyteArray payment_hash_arr = (*_env)->NewByteArray(_env, 32);
948                         (*_env)->SetByteArrayRegion(_env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
949                         jbyteArray payment_secret_arr = (*_env)->NewByteArray(_env, 32);
950                         (*_env)->SetByteArrayRegion(_env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
951                         return (*_env)->NewObject(_env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
952                 }
953                 case LDKEvent_PaymentSent: {
954                         jbyteArray payment_preimage_arr = (*_env)->NewByteArray(_env, 32);
955                         (*_env)->SetByteArrayRegion(_env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
956                         return (*_env)->NewObject(_env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
957                 }
958                 case LDKEvent_PaymentFailed: {
959                         jbyteArray payment_hash_arr = (*_env)->NewByteArray(_env, 32);
960                         (*_env)->SetByteArrayRegion(_env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
961                         return (*_env)->NewObject(_env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
962                 }
963                 case LDKEvent_PendingHTLCsForwardable: {
964                         return (*_env)->NewObject(_env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
965                 }
966                 case LDKEvent_SpendableOutputs: {
967                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
968                         jlongArray outputs_arr = (*_env)->NewLongArray(_env, outputs_var.datalen);
969                         jlong *outputs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, outputs_arr, NULL);
970                         for (size_t b = 0; b < outputs_var.datalen; b++) {
971                                 long arr_conv_27_ref = (long)&outputs_var.data[b];
972                                 outputs_arr_ptr[b] = arr_conv_27_ref;
973                         }
974                         (*_env)->ReleasePrimitiveArrayCritical(_env, outputs_arr, outputs_arr_ptr, 0);
975                         return (*_env)->NewObject(_env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
976                 }
977                 default: abort();
978         }
979 }
980 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
981 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
982 static jclass LDKErrorAction_IgnoreError_class = NULL;
983 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
984 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
985 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv * env, jclass _a) {
987         LDKErrorAction_DisconnectPeer_class =
988                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
989         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
990         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
991         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
992         LDKErrorAction_IgnoreError_class =
993                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
994         CHECK(LDKErrorAction_IgnoreError_class != NULL);
995         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
996         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
997         LDKErrorAction_SendErrorMessage_class =
998                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
999         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1000         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1001         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1002 }
1003 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
1004         LDKErrorAction *obj = (LDKErrorAction*)ptr;
1005         switch(obj->tag) {
1006                 case LDKErrorAction_DisconnectPeer: {
1007                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1008                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1009                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1010                         long msg_ref = (long)msg_var.inner & ~1;
1011                         return (*_env)->NewObject(_env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1012                 }
1013                 case LDKErrorAction_IgnoreError: {
1014                         return (*_env)->NewObject(_env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1015                 }
1016                 case LDKErrorAction_SendErrorMessage: {
1017                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1018                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020                         long msg_ref = (long)msg_var.inner & ~1;
1021                         return (*_env)->NewObject(_env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1022                 }
1023                 default: abort();
1024         }
1025 }
1026 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1027 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1028 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1029 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1030 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1031 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv * env, jclass _a) {
1033         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1034                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1035         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1036         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1037         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1038         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1039                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1040         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1041         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1042         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1043         LDKHTLCFailChannelUpdate_NodeFailure_class =
1044                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1045         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1046         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1047         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1048 }
1049 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
1050         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
1051         switch(obj->tag) {
1052                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1053                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1054                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1055                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1056                         long msg_ref = (long)msg_var.inner & ~1;
1057                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1058                 }
1059                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1060                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1061                 }
1062                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1063                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1064                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1065                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1066                 }
1067                 default: abort();
1068         }
1069 }
1070 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1071 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1072 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1073 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1074 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1075 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1076 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1077 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1078 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1079 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1080 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1081 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1082 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1083 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1084 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1085 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1086 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1087 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1088 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1089 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1090 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1091 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1092 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1093 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1094 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1095 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1096 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1097 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1098 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1099 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1100 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1101 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv * env, jclass _a) {
1103         LDKMessageSendEvent_SendAcceptChannel_class =
1104                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1105         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1106         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1107         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1108         LDKMessageSendEvent_SendOpenChannel_class =
1109                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1110         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1111         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1112         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1113         LDKMessageSendEvent_SendFundingCreated_class =
1114                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1115         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1116         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1117         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1118         LDKMessageSendEvent_SendFundingSigned_class =
1119                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1120         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1121         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1122         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1123         LDKMessageSendEvent_SendFundingLocked_class =
1124                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1125         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1126         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1127         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1128         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1129                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1130         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1131         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1132         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1133         LDKMessageSendEvent_UpdateHTLCs_class =
1134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1135         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1136         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1137         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1138         LDKMessageSendEvent_SendRevokeAndACK_class =
1139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1140         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1141         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1142         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1143         LDKMessageSendEvent_SendClosingSigned_class =
1144                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1145         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1146         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1147         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1148         LDKMessageSendEvent_SendShutdown_class =
1149                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1150         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1151         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1152         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1153         LDKMessageSendEvent_SendChannelReestablish_class =
1154                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1155         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1156         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1157         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1158         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1159                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1160         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1161         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1162         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1163         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1164                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1165         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1166         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1167         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1168         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1169                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1170         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1171         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1172         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1173         LDKMessageSendEvent_HandleError_class =
1174                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1175         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1176         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1177         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1178         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1179                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1180         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1181         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1182         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1183 }
1184 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
1185         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1186         switch(obj->tag) {
1187                 case LDKMessageSendEvent_SendAcceptChannel: {
1188                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1189                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1190                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1191                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1192                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1193                         long msg_ref = (long)msg_var.inner & ~1;
1194                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1195                 }
1196                 case LDKMessageSendEvent_SendOpenChannel: {
1197                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1198                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1199                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1200                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1201                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1202                         long msg_ref = (long)msg_var.inner & ~1;
1203                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1204                 }
1205                 case LDKMessageSendEvent_SendFundingCreated: {
1206                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1207                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1208                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1209                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1210                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1211                         long msg_ref = (long)msg_var.inner & ~1;
1212                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1213                 }
1214                 case LDKMessageSendEvent_SendFundingSigned: {
1215                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1216                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1217                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1218                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1219                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1220                         long msg_ref = (long)msg_var.inner & ~1;
1221                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1222                 }
1223                 case LDKMessageSendEvent_SendFundingLocked: {
1224                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1225                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1226                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1227                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1228                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1229                         long msg_ref = (long)msg_var.inner & ~1;
1230                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1231                 }
1232                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1233                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1234                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1235                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1236                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1237                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1238                         long msg_ref = (long)msg_var.inner & ~1;
1239                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1240                 }
1241                 case LDKMessageSendEvent_UpdateHTLCs: {
1242                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1243                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1244                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1245                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1246                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1247                         long updates_ref = (long)updates_var.inner & ~1;
1248                         return (*_env)->NewObject(_env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1249                 }
1250                 case LDKMessageSendEvent_SendRevokeAndACK: {
1251                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1252                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1253                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1254                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1255                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1256                         long msg_ref = (long)msg_var.inner & ~1;
1257                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1258                 }
1259                 case LDKMessageSendEvent_SendClosingSigned: {
1260                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1261                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1262                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1263                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1264                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1265                         long msg_ref = (long)msg_var.inner & ~1;
1266                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1267                 }
1268                 case LDKMessageSendEvent_SendShutdown: {
1269                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1270                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1271                         LDKShutdown msg_var = obj->send_shutdown.msg;
1272                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1273                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1274                         long msg_ref = (long)msg_var.inner & ~1;
1275                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1276                 }
1277                 case LDKMessageSendEvent_SendChannelReestablish: {
1278                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1279                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1280                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1281                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1282                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1283                         long msg_ref = (long)msg_var.inner & ~1;
1284                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1285                 }
1286                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1287                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1288                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1289                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1290                         long msg_ref = (long)msg_var.inner & ~1;
1291                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1292                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1293                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1294                         long update_msg_ref = (long)update_msg_var.inner & ~1;
1295                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1296                 }
1297                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1298                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1299                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1300                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1301                         long msg_ref = (long)msg_var.inner & ~1;
1302                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1303                 }
1304                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1305                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1306                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1307                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1308                         long msg_ref = (long)msg_var.inner & ~1;
1309                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1310                 }
1311                 case LDKMessageSendEvent_HandleError: {
1312                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1313                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1314                         long action_ref = (long)&obj->handle_error.action;
1315                         return (*_env)->NewObject(_env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1316                 }
1317                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1318                         long update_ref = (long)&obj->payment_failure_network_update.update;
1319                         return (*_env)->NewObject(_env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1320                 }
1321                 default: abort();
1322         }
1323 }
1324 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1325         LDKCVecTempl_MessageSendEvent *vec = (LDKCVecTempl_MessageSendEvent*)ptr;
1326         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKMessageSendEvent));
1327 }
1328 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1329         LDKCVecTempl_MessageSendEvent *ret = MALLOC(sizeof(LDKCVecTempl_MessageSendEvent), "LDKCVecTempl_MessageSendEvent");
1330         ret->datalen = (*env)->GetArrayLength(env, elems);
1331         if (ret->datalen == 0) {
1332                 ret->data = NULL;
1333         } else {
1334                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVecTempl_MessageSendEvent Data");
1335                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1336                 for (size_t i = 0; i < ret->datalen; i++) {
1337                         jlong arr_elem = java_elems[i];
1338                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
1339                         FREE((void*)arr_elem);
1340                         ret->data[i] = arr_elem_conv;
1341                 }
1342                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1343         }
1344         return (long)ret;
1345 }
1346 typedef struct LDKMessageSendEventsProvider_JCalls {
1347         atomic_size_t refcnt;
1348         JavaVM *vm;
1349         jweak o;
1350         jmethodID get_and_clear_pending_msg_events_meth;
1351 } LDKMessageSendEventsProvider_JCalls;
1352 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
1353         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1354         JNIEnv *_env;
1355         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1356         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1357         CHECK(obj != NULL);
1358         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_and_clear_pending_msg_events_meth);
1359         LDKCVec_MessageSendEventZ ret_constr;
1360         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
1361         if (ret_constr.datalen > 0)
1362                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
1363         else
1364                 ret_constr.data = NULL;
1365         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
1366         for (size_t s = 0; s < ret_constr.datalen; s++) {
1367                 long arr_conv_18 = ret_vals[s];
1368                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
1369                 FREE((void*)arr_conv_18);
1370                 ret_constr.data[s] = arr_conv_18_conv;
1371         }
1372         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
1373         return ret_constr;
1374 }
1375 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
1376         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1377         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1378                 JNIEnv *env;
1379                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1380                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1381                 FREE(j_calls);
1382         }
1383 }
1384 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
1385         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1386         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1387         return (void*) this_arg;
1388 }
1389 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1390         jclass c = (*env)->GetObjectClass(env, o);
1391         CHECK(c != NULL);
1392         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
1393         atomic_init(&calls->refcnt, 1);
1394         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1395         calls->o = (*env)->NewWeakGlobalRef(env, o);
1396         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
1397         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
1398
1399         LDKMessageSendEventsProvider ret = {
1400                 .this_arg = (void*) calls,
1401                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
1402                 .free = LDKMessageSendEventsProvider_JCalls_free,
1403         };
1404         return ret;
1405 }
1406 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1407         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
1408         *res_ptr = LDKMessageSendEventsProvider_init(env, _a, o);
1409         return (long)res_ptr;
1410 }
1411 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1412         jobject ret = (*env)->NewLocalRef(env, ((LDKMessageSendEventsProvider_JCalls*)val)->o);
1413         CHECK(ret != NULL);
1414         return ret;
1415 }
1416 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
1417         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
1418         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
1419         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
1420         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
1421         for (size_t s = 0; s < ret_var.datalen; s++) {
1422                 LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
1423                 *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
1424                 long arr_conv_18_ref = (long)arr_conv_18_copy;
1425                 ret_arr_ptr[s] = arr_conv_18_ref;
1426         }
1427         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
1428         CVec_MessageSendEventZ_free(ret_var);
1429         return ret_arr;
1430 }
1431
1432 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1433         LDKCVecTempl_Event *vec = (LDKCVecTempl_Event*)ptr;
1434         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKEvent));
1435 }
1436 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1new(JNIEnv *env, jclass _b, jlongArray elems){
1437         LDKCVecTempl_Event *ret = MALLOC(sizeof(LDKCVecTempl_Event), "LDKCVecTempl_Event");
1438         ret->datalen = (*env)->GetArrayLength(env, elems);
1439         if (ret->datalen == 0) {
1440                 ret->data = NULL;
1441         } else {
1442                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVecTempl_Event Data");
1443                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1444                 for (size_t i = 0; i < ret->datalen; i++) {
1445                         jlong arr_elem = java_elems[i];
1446                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
1447                         FREE((void*)arr_elem);
1448                         ret->data[i] = arr_elem_conv;
1449                 }
1450                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1451         }
1452         return (long)ret;
1453 }
1454 typedef struct LDKEventsProvider_JCalls {
1455         atomic_size_t refcnt;
1456         JavaVM *vm;
1457         jweak o;
1458         jmethodID get_and_clear_pending_events_meth;
1459 } LDKEventsProvider_JCalls;
1460 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
1461         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1462         JNIEnv *_env;
1463         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1464         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1465         CHECK(obj != NULL);
1466         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_and_clear_pending_events_meth);
1467         LDKCVec_EventZ ret_constr;
1468         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
1469         if (ret_constr.datalen > 0)
1470                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
1471         else
1472                 ret_constr.data = NULL;
1473         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
1474         for (size_t h = 0; h < ret_constr.datalen; h++) {
1475                 long arr_conv_7 = ret_vals[h];
1476                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
1477                 FREE((void*)arr_conv_7);
1478                 ret_constr.data[h] = arr_conv_7_conv;
1479         }
1480         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
1481         return ret_constr;
1482 }
1483 static void LDKEventsProvider_JCalls_free(void* this_arg) {
1484         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1485         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1486                 JNIEnv *env;
1487                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1488                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1489                 FREE(j_calls);
1490         }
1491 }
1492 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
1493         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1494         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1495         return (void*) this_arg;
1496 }
1497 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1498         jclass c = (*env)->GetObjectClass(env, o);
1499         CHECK(c != NULL);
1500         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
1501         atomic_init(&calls->refcnt, 1);
1502         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1503         calls->o = (*env)->NewWeakGlobalRef(env, o);
1504         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
1505         CHECK(calls->get_and_clear_pending_events_meth != NULL);
1506
1507         LDKEventsProvider ret = {
1508                 .this_arg = (void*) calls,
1509                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
1510                 .free = LDKEventsProvider_JCalls_free,
1511         };
1512         return ret;
1513 }
1514 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1515         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
1516         *res_ptr = LDKEventsProvider_init(env, _a, o);
1517         return (long)res_ptr;
1518 }
1519 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1520         jobject ret = (*env)->NewLocalRef(env, ((LDKEventsProvider_JCalls*)val)->o);
1521         CHECK(ret != NULL);
1522         return ret;
1523 }
1524 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
1525         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
1526         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
1527         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
1528         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
1529         for (size_t h = 0; h < ret_var.datalen; h++) {
1530                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
1531                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
1532                 long arr_conv_7_ref = (long)arr_conv_7_copy;
1533                 ret_arr_ptr[h] = arr_conv_7_ref;
1534         }
1535         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
1536         CVec_EventZ_free(ret_var);
1537         return ret_arr;
1538 }
1539
1540 typedef struct LDKLogger_JCalls {
1541         atomic_size_t refcnt;
1542         JavaVM *vm;
1543         jweak o;
1544         jmethodID log_meth;
1545 } LDKLogger_JCalls;
1546 void log_jcall(const void* this_arg, const char *record) {
1547         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1548         JNIEnv *_env;
1549         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1550         jstring record_conv = (*_env)->NewStringUTF(_env, record);
1551         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1552         CHECK(obj != NULL);
1553         return (*_env)->CallVoidMethod(_env, obj, j_calls->log_meth, record_conv);
1554 }
1555 static void LDKLogger_JCalls_free(void* this_arg) {
1556         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1557         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1558                 JNIEnv *env;
1559                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1560                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1561                 FREE(j_calls);
1562         }
1563 }
1564 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1565         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1566         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1567         return (void*) this_arg;
1568 }
1569 static inline LDKLogger LDKLogger_init (JNIEnv * env, jclass _a, jobject o) {
1570         jclass c = (*env)->GetObjectClass(env, o);
1571         CHECK(c != NULL);
1572         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1573         atomic_init(&calls->refcnt, 1);
1574         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1575         calls->o = (*env)->NewWeakGlobalRef(env, o);
1576         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
1577         CHECK(calls->log_meth != NULL);
1578
1579         LDKLogger ret = {
1580                 .this_arg = (void*) calls,
1581                 .log = log_jcall,
1582                 .free = LDKLogger_JCalls_free,
1583         };
1584         return ret;
1585 }
1586 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new (JNIEnv * env, jclass _a, jobject o) {
1587         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1588         *res_ptr = LDKLogger_init(env, _a, o);
1589         return (long)res_ptr;
1590 }
1591 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1592         jobject ret = (*env)->NewLocalRef(env, ((LDKLogger_JCalls*)val)->o);
1593         CHECK(ret != NULL);
1594         return ret;
1595 }
1596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
1597         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1598 }
1599 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
1600         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1601         CHECK(val->result_ok);
1602         long res_ref = (long)&(*val->contents.result);
1603         return res_ref;
1604 }
1605 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
1606         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1607         CHECK(!val->result_ok);
1608         jclass err_conv = LDKAccessError_to_java(_env, (*val->contents.err));
1609         return err_conv;
1610 }
1611 typedef struct LDKAccess_JCalls {
1612         atomic_size_t refcnt;
1613         JavaVM *vm;
1614         jweak o;
1615         jmethodID get_utxo_meth;
1616 } LDKAccess_JCalls;
1617 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) {
1618         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1619         JNIEnv *_env;
1620         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1621         jbyteArray genesis_hash_arr = (*_env)->NewByteArray(_env, 32);
1622         (*_env)->SetByteArrayRegion(_env, genesis_hash_arr, 0, 32, *genesis_hash);
1623         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1624         CHECK(obj != NULL);
1625         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
1626         LDKCResult_TxOutAccessErrorZ res = *ret;
1627         FREE(ret);
1628         return res;
1629 }
1630 static void LDKAccess_JCalls_free(void* this_arg) {
1631         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1632         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1633                 JNIEnv *env;
1634                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1635                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1636                 FREE(j_calls);
1637         }
1638 }
1639 static void* LDKAccess_JCalls_clone(const void* this_arg) {
1640         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1641         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1642         return (void*) this_arg;
1643 }
1644 static inline LDKAccess LDKAccess_init (JNIEnv * env, jclass _a, jobject o) {
1645         jclass c = (*env)->GetObjectClass(env, o);
1646         CHECK(c != NULL);
1647         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
1648         atomic_init(&calls->refcnt, 1);
1649         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1650         calls->o = (*env)->NewWeakGlobalRef(env, o);
1651         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
1652         CHECK(calls->get_utxo_meth != NULL);
1653
1654         LDKAccess ret = {
1655                 .this_arg = (void*) calls,
1656                 .get_utxo = get_utxo_jcall,
1657                 .free = LDKAccess_JCalls_free,
1658         };
1659         return ret;
1660 }
1661 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new (JNIEnv * env, jclass _a, jobject o) {
1662         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
1663         *res_ptr = LDKAccess_init(env, _a, o);
1664         return (long)res_ptr;
1665 }
1666 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAccess_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1667         jobject ret = (*env)->NewLocalRef(env, ((LDKAccess_JCalls*)val)->o);
1668         CHECK(ret != NULL);
1669         return ret;
1670 }
1671 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray genesis_hash, jlong short_channel_id) {
1672         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
1673         unsigned char genesis_hash_arr[32];
1674         CHECK((*_env)->GetArrayLength (_env, genesis_hash) == 32);
1675         (*_env)->GetByteArrayRegion (_env, genesis_hash, 0, 32, genesis_hash_arr);
1676         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
1677         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
1678         *ret = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
1679         return (long)ret;
1680 }
1681
1682 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1683         LDKCVecTempl_HTLCOutputInCommitment *vec = (LDKCVecTempl_HTLCOutputInCommitment*)ptr;
1684         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
1685         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
1686         for (size_t i = 0; i < vec->datalen; i++) {
1687                 CHECK((((long)vec->data[i].inner) & 1) == 0);
1688                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
1689         }
1690         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
1691         return ret;
1692 }
1693 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1new(JNIEnv *env, jclass _b, jlongArray elems){
1694         LDKCVecTempl_HTLCOutputInCommitment *ret = MALLOC(sizeof(LDKCVecTempl_HTLCOutputInCommitment), "LDKCVecTempl_HTLCOutputInCommitment");
1695         ret->datalen = (*env)->GetArrayLength(env, elems);
1696         if (ret->datalen == 0) {
1697                 ret->data = NULL;
1698         } else {
1699                 ret->data = MALLOC(sizeof(LDKHTLCOutputInCommitment) * ret->datalen, "LDKCVecTempl_HTLCOutputInCommitment Data");
1700                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1701                 for (size_t i = 0; i < ret->datalen; i++) {
1702                         jlong arr_elem = java_elems[i];
1703                         LDKHTLCOutputInCommitment arr_elem_conv;
1704                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1705                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1706                         if (arr_elem_conv.inner != NULL)
1707                                 arr_elem_conv = HTLCOutputInCommitment_clone(&arr_elem_conv);
1708                         ret->data[i] = arr_elem_conv;
1709                 }
1710                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1711         }
1712         return (long)ret;
1713 }
1714 typedef struct LDKChannelKeys_JCalls {
1715         atomic_size_t refcnt;
1716         JavaVM *vm;
1717         jweak o;
1718         jmethodID get_per_commitment_point_meth;
1719         jmethodID release_commitment_secret_meth;
1720         jmethodID key_derivation_params_meth;
1721         jmethodID sign_counterparty_commitment_meth;
1722         jmethodID sign_holder_commitment_meth;
1723         jmethodID sign_holder_commitment_htlc_transactions_meth;
1724         jmethodID sign_justice_transaction_meth;
1725         jmethodID sign_counterparty_htlc_transaction_meth;
1726         jmethodID sign_closing_transaction_meth;
1727         jmethodID sign_channel_announcement_meth;
1728         jmethodID on_accept_meth;
1729 } LDKChannelKeys_JCalls;
1730 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1731         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1732         JNIEnv *_env;
1733         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1734         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1735         CHECK(obj != NULL);
1736         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_per_commitment_point_meth, idx);
1737         LDKPublicKey ret_ref;
1738         CHECK((*_env)->GetArrayLength (_env, ret) == 33);
1739         (*_env)->GetByteArrayRegion (_env, ret, 0, 33, ret_ref.compressed_form);
1740         return ret_ref;
1741 }
1742 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1743         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1744         JNIEnv *_env;
1745         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1746         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1747         CHECK(obj != NULL);
1748         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->release_commitment_secret_meth, idx);
1749         LDKThirtyTwoBytes ret_ref;
1750         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
1751         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.data);
1752         return ret_ref;
1753 }
1754 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1755         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1756         JNIEnv *_env;
1757         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1758         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1759         CHECK(obj != NULL);
1760         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*_env)->CallLongMethod(_env, obj, j_calls->key_derivation_params_meth);
1761         LDKC2Tuple_u64u64Z res = *ret;
1762         FREE(ret);
1763         return res;
1764 }
1765 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, uint32_t feerate_per_kw, LDKTransaction commitment_tx, const LDKPreCalculatedTxCreationKeys *keys, LDKCVec_HTLCOutputInCommitmentZ htlcs) {
1766         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1767         JNIEnv *_env;
1768         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1769         LDKTransaction *commitment_tx_copy = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
1770         *commitment_tx_copy = commitment_tx;
1771         long commitment_tx_ref = (long)commitment_tx_copy;
1772         long ret_keys = (long)keys;
1773         LDKCVec_HTLCOutputInCommitmentZ htlcs_var = htlcs;
1774         jlongArray htlcs_arr = (*_env)->NewLongArray(_env, htlcs_var.datalen);
1775         jlong *htlcs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, htlcs_arr, NULL);
1776         for (size_t y = 0; y < htlcs_var.datalen; y++) {
1777                 LDKHTLCOutputInCommitment arr_conv_24_var = htlcs_var.data[y];
1778                 CHECK((((long)arr_conv_24_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1779                 CHECK((((long)&arr_conv_24_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1780                 long arr_conv_24_ref;
1781                 if (arr_conv_24_var.is_owned) {
1782                         arr_conv_24_ref = (long)arr_conv_24_var.inner | 1;
1783                 } else {
1784                         arr_conv_24_ref = (long)arr_conv_24_var.inner & ~1;
1785                 }
1786                 htlcs_arr_ptr[y] = arr_conv_24_ref;
1787         }
1788         (*_env)->ReleasePrimitiveArrayCritical(_env, htlcs_arr, htlcs_arr_ptr, 0);
1789         FREE(htlcs_var.data);
1790         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1791         CHECK(obj != NULL);
1792         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx_ref, ret_keys, htlcs_arr);
1793         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret;
1794         FREE(ret);
1795         return res;
1796 }
1797 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1798         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1799         JNIEnv *_env;
1800         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1801         long ret_holder_commitment_tx = (long)holder_commitment_tx;
1802         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1803         CHECK(obj != NULL);
1804         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_meth, ret_holder_commitment_tx);
1805         LDKCResult_SignatureNoneZ res = *ret;
1806         FREE(ret);
1807         return res;
1808 }
1809 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1810         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1811         JNIEnv *_env;
1812         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1813         long ret_holder_commitment_tx = (long)holder_commitment_tx;
1814         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1815         CHECK(obj != NULL);
1816         LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, ret_holder_commitment_tx);
1817         LDKCResult_CVec_SignatureZNoneZ res = *ret;
1818         FREE(ret);
1819         return res;
1820 }
1821 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) {
1822         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1823         JNIEnv *_env;
1824         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1825         LDKTransaction *justice_tx_copy = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
1826         *justice_tx_copy = justice_tx;
1827         long justice_tx_ref = (long)justice_tx_copy;
1828         jbyteArray per_commitment_key_arr = (*_env)->NewByteArray(_env, 32);
1829         (*_env)->SetByteArrayRegion(_env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1830         long ret_htlc = (long)htlc;
1831         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1832         CHECK(obj != NULL);
1833         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_justice_transaction_meth, justice_tx_ref, input, amount, per_commitment_key_arr, ret_htlc);
1834         LDKCResult_SignatureNoneZ res = *ret;
1835         FREE(ret);
1836         return res;
1837 }
1838 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) {
1839         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1840         JNIEnv *_env;
1841         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1842         LDKTransaction *htlc_tx_copy = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
1843         *htlc_tx_copy = htlc_tx;
1844         long htlc_tx_ref = (long)htlc_tx_copy;
1845         jbyteArray per_commitment_point_arr = (*_env)->NewByteArray(_env, 33);
1846         (*_env)->SetByteArrayRegion(_env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
1847         long ret_htlc = (long)htlc;
1848         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1849         CHECK(obj != NULL);
1850         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_ref, input, amount, per_commitment_point_arr, ret_htlc);
1851         LDKCResult_SignatureNoneZ res = *ret;
1852         FREE(ret);
1853         return res;
1854 }
1855 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1856         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1857         JNIEnv *_env;
1858         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1859         LDKTransaction *closing_tx_copy = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
1860         *closing_tx_copy = closing_tx;
1861         long closing_tx_ref = (long)closing_tx_copy;
1862         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1863         CHECK(obj != NULL);
1864         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
1865         LDKCResult_SignatureNoneZ res = *ret;
1866         FREE(ret);
1867         return res;
1868 }
1869 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement *msg) {
1870         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1871         JNIEnv *_env;
1872         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1873         long ret_msg = (long)msg;
1874         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1875         CHECK(obj != NULL);
1876         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_channel_announcement_meth, ret_msg);
1877         LDKCResult_SignatureNoneZ res = *ret;
1878         FREE(ret);
1879         return res;
1880 }
1881 void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay) {
1882         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1883         JNIEnv *_env;
1884         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1885         long ret_channel_points = (long)channel_points;
1886         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1887         CHECK(obj != NULL);
1888         return (*_env)->CallVoidMethod(_env, obj, j_calls->on_accept_meth, ret_channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay);
1889 }
1890 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1891         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1892         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1893                 JNIEnv *env;
1894                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1895                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1896                 FREE(j_calls);
1897         }
1898 }
1899 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1900         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1901         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1902         return (void*) this_arg;
1903 }
1904 static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o, jlong pubkeys) {
1905         jclass c = (*env)->GetObjectClass(env, o);
1906         CHECK(c != NULL);
1907         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1908         atomic_init(&calls->refcnt, 1);
1909         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1910         calls->o = (*env)->NewWeakGlobalRef(env, o);
1911         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
1912         CHECK(calls->get_per_commitment_point_meth != NULL);
1913         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
1914         CHECK(calls->release_commitment_secret_meth != NULL);
1915         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
1916         CHECK(calls->key_derivation_params_meth != NULL);
1917         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJ[J)J");
1918         CHECK(calls->sign_counterparty_commitment_meth != NULL);
1919         calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
1920         CHECK(calls->sign_holder_commitment_meth != NULL);
1921         calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
1922         CHECK(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
1923         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "(JJJ[BJ)J");
1924         CHECK(calls->sign_justice_transaction_meth != NULL);
1925         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "(JJJ[BJ)J");
1926         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
1927         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
1928         CHECK(calls->sign_closing_transaction_meth != NULL);
1929         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1930         CHECK(calls->sign_channel_announcement_meth != NULL);
1931         calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V");
1932         CHECK(calls->on_accept_meth != NULL);
1933
1934         LDKChannelPublicKeys pubkeys_conv;
1935         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1936         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1937         if (pubkeys_conv.inner != NULL)
1938                 pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1939
1940         LDKChannelKeys ret = {
1941                 .this_arg = (void*) calls,
1942                 .get_per_commitment_point = get_per_commitment_point_jcall,
1943                 .release_commitment_secret = release_commitment_secret_jcall,
1944                 .key_derivation_params = key_derivation_params_jcall,
1945                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1946                 .sign_holder_commitment = sign_holder_commitment_jcall,
1947                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1948                 .sign_justice_transaction = sign_justice_transaction_jcall,
1949                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1950                 .sign_closing_transaction = sign_closing_transaction_jcall,
1951                 .sign_channel_announcement = sign_channel_announcement_jcall,
1952                 .on_accept = on_accept_jcall,
1953                 .clone = LDKChannelKeys_JCalls_clone,
1954                 .free = LDKChannelKeys_JCalls_free,
1955                 .pubkeys = pubkeys_conv,
1956                 .set_pubkeys = NULL,
1957         };
1958         return ret;
1959 }
1960 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o, jlong pubkeys) {
1961         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1962         *res_ptr = LDKChannelKeys_init(env, _a, o, pubkeys);
1963         return (long)res_ptr;
1964 }
1965 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1966         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelKeys_JCalls*)val)->o);
1967         CHECK(ret != NULL);
1968         return ret;
1969 }
1970 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg, jlong idx) {
1971         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1972         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
1973         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
1974         return arg_arr;
1975 }
1976
1977 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1release_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_arg, jlong idx) {
1978         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1979         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
1980         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
1981         return arg_arr;
1982 }
1983
1984 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1key_1derivation_1params(JNIEnv * _env, jclass _b, jlong this_arg) {
1985         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1986         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1987         *ret = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
1988         return (long)ret;
1989 }
1990
1991 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1counterparty_1commitment(JNIEnv * _env, jclass _b, jlong this_arg, jint feerate_per_kw, jlong commitment_tx, jlong keys, jlongArray htlcs) {
1992         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1993         LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx;
1994         LDKPreCalculatedTxCreationKeys keys_conv;
1995         keys_conv.inner = (void*)(keys & (~1));
1996         keys_conv.is_owned = (keys & 1) || (keys == 0);
1997         LDKCVec_HTLCOutputInCommitmentZ htlcs_constr;
1998         htlcs_constr.datalen = (*_env)->GetArrayLength (_env, htlcs);
1999         if (htlcs_constr.datalen > 0)
2000                 htlcs_constr.data = MALLOC(htlcs_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
2001         else
2002                 htlcs_constr.data = NULL;
2003         long* htlcs_vals = (*_env)->GetLongArrayElements (_env, htlcs, NULL);
2004         for (size_t y = 0; y < htlcs_constr.datalen; y++) {
2005                 long arr_conv_24 = htlcs_vals[y];
2006                 LDKHTLCOutputInCommitment arr_conv_24_conv;
2007                 arr_conv_24_conv.inner = (void*)(arr_conv_24 & (~1));
2008                 arr_conv_24_conv.is_owned = (arr_conv_24 & 1) || (arr_conv_24 == 0);
2009                 if (arr_conv_24_conv.inner != NULL)
2010                         arr_conv_24_conv = HTLCOutputInCommitment_clone(&arr_conv_24_conv);
2011                 htlcs_constr.data[y] = arr_conv_24_conv;
2012         }
2013         (*_env)->ReleaseLongArrayElements (_env, htlcs, htlcs_vals, 0);
2014         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2015         *ret = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, &keys_conv, htlcs_constr);
2016         return (long)ret;
2017 }
2018
2019 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1holder_1commitment(JNIEnv * _env, jclass _b, jlong this_arg, jlong holder_commitment_tx) {
2020         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2021         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
2022         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
2023         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
2024         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2025         *ret = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &holder_commitment_tx_conv);
2026         return (long)ret;
2027 }
2028
2029 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1holder_1commitment_1htlc_1transactions(JNIEnv * _env, jclass _b, jlong this_arg, jlong holder_commitment_tx) {
2030         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2031         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
2032         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
2033         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
2034         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
2035         *ret = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &holder_commitment_tx_conv);
2036         return (long)ret;
2037 }
2038
2039 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1justice_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong justice_tx, jlong input, jlong amount, jbyteArray per_commitment_key, jlong htlc) {
2040         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2041         LDKTransaction justice_tx_conv = *(LDKTransaction*)justice_tx;
2042         unsigned char per_commitment_key_arr[32];
2043         CHECK((*_env)->GetArrayLength (_env, per_commitment_key) == 32);
2044         (*_env)->GetByteArrayRegion (_env, per_commitment_key, 0, 32, per_commitment_key_arr);
2045         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2046         LDKHTLCOutputInCommitment htlc_conv;
2047         htlc_conv.inner = (void*)(htlc & (~1));
2048         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
2049         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2050         *ret = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_conv, input, amount, per_commitment_key_ref, &htlc_conv);
2051         return (long)ret;
2052 }
2053
2054 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1counterparty_1htlc_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong htlc_tx, jlong input, jlong amount, jbyteArray per_commitment_point, jlong htlc) {
2055         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2056         LDKTransaction htlc_tx_conv = *(LDKTransaction*)htlc_tx;
2057         LDKPublicKey per_commitment_point_ref;
2058         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
2059         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2060         LDKHTLCOutputInCommitment htlc_conv;
2061         htlc_conv.inner = (void*)(htlc & (~1));
2062         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
2063         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2064         *ret = (this_arg_conv->sign_counterparty_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_conv, input, amount, per_commitment_point_ref, &htlc_conv);
2065         return (long)ret;
2066 }
2067
2068 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1closing_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong closing_tx) {
2069         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2070         LDKTransaction closing_tx_conv = *(LDKTransaction*)closing_tx;
2071         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2072         *ret = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_conv);
2073         return (long)ret;
2074 }
2075
2076 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1channel_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
2077         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2078         LDKUnsignedChannelAnnouncement msg_conv;
2079         msg_conv.inner = (void*)(msg & (~1));
2080         msg_conv.is_owned = (msg & 1) || (msg == 0);
2081         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2082         *ret = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2083         return (long)ret;
2084 }
2085
2086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1on_1accept(JNIEnv * _env, jclass _b, jlong this_arg, jlong channel_points, jshort counterparty_selected_contest_delay, jshort holder_selected_contest_delay) {
2087         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2088         LDKChannelPublicKeys channel_points_conv;
2089         channel_points_conv.inner = (void*)(channel_points & (~1));
2090         channel_points_conv.is_owned = (channel_points & 1) || (channel_points == 0);
2091         (this_arg_conv->on_accept)(this_arg_conv->this_arg, &channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
2092 }
2093
2094 LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* this_arg) {
2095         if (this_arg->set_pubkeys != NULL)
2096                 this_arg->set_pubkeys(this_arg);
2097         return this_arg->pubkeys;
2098 }
2099 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
2100         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2101         LDKChannelPublicKeys ret = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
2102         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
2103 }
2104
2105 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2106         LDKCVecTempl_MonitorEvent *vec = (LDKCVecTempl_MonitorEvent*)ptr;
2107         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2108         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2109         for (size_t i = 0; i < vec->datalen; i++) {
2110                 CHECK((((long)vec->data[i].inner) & 1) == 0);
2111                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2112         }
2113         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2114         return ret;
2115 }
2116 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
2117         LDKCVecTempl_MonitorEvent *ret = MALLOC(sizeof(LDKCVecTempl_MonitorEvent), "LDKCVecTempl_MonitorEvent");
2118         ret->datalen = (*env)->GetArrayLength(env, elems);
2119         if (ret->datalen == 0) {
2120                 ret->data = NULL;
2121         } else {
2122                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVecTempl_MonitorEvent Data");
2123                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2124                 for (size_t i = 0; i < ret->datalen; i++) {
2125                         jlong arr_elem = java_elems[i];
2126                         LDKMonitorEvent arr_elem_conv;
2127                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2128                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2129                         // Warning: we may need a move here but can't clone!
2130                         ret->data[i] = arr_elem_conv;
2131                 }
2132                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2133         }
2134         return (long)ret;
2135 }
2136 typedef struct LDKWatch_JCalls {
2137         atomic_size_t refcnt;
2138         JavaVM *vm;
2139         jweak o;
2140         jmethodID watch_channel_meth;
2141         jmethodID update_channel_meth;
2142         jmethodID release_pending_monitor_events_meth;
2143 } LDKWatch_JCalls;
2144 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2145         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2146         JNIEnv *_env;
2147         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2148         LDKOutPoint funding_txo_var = funding_txo;
2149         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2150         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2151         long funding_txo_ref;
2152         if (funding_txo_var.is_owned) {
2153                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2154         } else {
2155                 funding_txo_ref = (long)funding_txo_var.inner & ~1;
2156         }
2157         LDKChannelMonitor monitor_var = monitor;
2158         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2159         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2160         long monitor_ref;
2161         if (monitor_var.is_owned) {
2162                 monitor_ref = (long)monitor_var.inner | 1;
2163         } else {
2164                 monitor_ref = (long)monitor_var.inner & ~1;
2165         }
2166         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2167         CHECK(obj != NULL);
2168         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*_env)->CallLongMethod(_env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2169         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2170         FREE(ret);
2171         return res;
2172 }
2173 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2174         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2175         JNIEnv *_env;
2176         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2177         LDKOutPoint funding_txo_var = funding_txo;
2178         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2179         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2180         long funding_txo_ref;
2181         if (funding_txo_var.is_owned) {
2182                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2183         } else {
2184                 funding_txo_ref = (long)funding_txo_var.inner & ~1;
2185         }
2186         LDKChannelMonitorUpdate update_var = update;
2187         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2188         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2189         long update_ref;
2190         if (update_var.is_owned) {
2191                 update_ref = (long)update_var.inner | 1;
2192         } else {
2193                 update_ref = (long)update_var.inner & ~1;
2194         }
2195         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2196         CHECK(obj != NULL);
2197         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*_env)->CallLongMethod(_env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
2198         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2199         FREE(ret);
2200         return res;
2201 }
2202 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2203         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2204         JNIEnv *_env;
2205         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2206         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2207         CHECK(obj != NULL);
2208         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->release_pending_monitor_events_meth);
2209         LDKCVec_MonitorEventZ ret_constr;
2210         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
2211         if (ret_constr.datalen > 0)
2212                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2213         else
2214                 ret_constr.data = NULL;
2215         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
2216         for (size_t o = 0; o < ret_constr.datalen; o++) {
2217                 long arr_conv_14 = ret_vals[o];
2218                 LDKMonitorEvent arr_conv_14_conv;
2219                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
2220                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
2221                 // Warning: we may need a move here but can't clone!
2222                 ret_constr.data[o] = arr_conv_14_conv;
2223         }
2224         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
2225         return ret_constr;
2226 }
2227 static void LDKWatch_JCalls_free(void* this_arg) {
2228         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2229         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2230                 JNIEnv *env;
2231                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2232                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2233                 FREE(j_calls);
2234         }
2235 }
2236 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2237         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2238         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2239         return (void*) this_arg;
2240 }
2241 static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) {
2242         jclass c = (*env)->GetObjectClass(env, o);
2243         CHECK(c != NULL);
2244         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2245         atomic_init(&calls->refcnt, 1);
2246         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2247         calls->o = (*env)->NewWeakGlobalRef(env, o);
2248         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
2249         CHECK(calls->watch_channel_meth != NULL);
2250         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
2251         CHECK(calls->update_channel_meth != NULL);
2252         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
2253         CHECK(calls->release_pending_monitor_events_meth != NULL);
2254
2255         LDKWatch ret = {
2256                 .this_arg = (void*) calls,
2257                 .watch_channel = watch_channel_jcall,
2258                 .update_channel = update_channel_jcall,
2259                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2260                 .free = LDKWatch_JCalls_free,
2261         };
2262         return ret;
2263 }
2264 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new (JNIEnv * env, jclass _a, jobject o) {
2265         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2266         *res_ptr = LDKWatch_init(env, _a, o);
2267         return (long)res_ptr;
2268 }
2269 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2270         jobject ret = (*env)->NewLocalRef(env, ((LDKWatch_JCalls*)val)->o);
2271         CHECK(ret != NULL);
2272         return ret;
2273 }
2274 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong monitor) {
2275         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2276         LDKOutPoint funding_txo_conv;
2277         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2278         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2279         if (funding_txo_conv.inner != NULL)
2280                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2281         LDKChannelMonitor monitor_conv;
2282         monitor_conv.inner = (void*)(monitor & (~1));
2283         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2284         // Warning: we may need a move here but can't clone!
2285         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2286         *ret = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2287         return (long)ret;
2288 }
2289
2290 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong update) {
2291         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2292         LDKOutPoint funding_txo_conv;
2293         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2294         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2295         if (funding_txo_conv.inner != NULL)
2296                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2297         LDKChannelMonitorUpdate update_conv;
2298         update_conv.inner = (void*)(update & (~1));
2299         update_conv.is_owned = (update & 1) || (update == 0);
2300         if (update_conv.inner != NULL)
2301                 update_conv = ChannelMonitorUpdate_clone(&update_conv);
2302         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2303         *ret = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2304         return (long)ret;
2305 }
2306
2307 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
2308         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2309         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2310         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
2311         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
2312         for (size_t o = 0; o < ret_var.datalen; o++) {
2313                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
2314                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2315                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2316                 long arr_conv_14_ref;
2317                 if (arr_conv_14_var.is_owned) {
2318                         arr_conv_14_ref = (long)arr_conv_14_var.inner | 1;
2319                 } else {
2320                         arr_conv_14_ref = (long)arr_conv_14_var.inner & ~1;
2321                 }
2322                 ret_arr_ptr[o] = arr_conv_14_ref;
2323         }
2324         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
2325         FREE(ret_var.data);
2326         return ret_arr;
2327 }
2328
2329 typedef struct LDKFilter_JCalls {
2330         atomic_size_t refcnt;
2331         JavaVM *vm;
2332         jweak o;
2333         jmethodID register_tx_meth;
2334         jmethodID register_output_meth;
2335 } LDKFilter_JCalls;
2336 void register_tx_jcall(const void* this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey) {
2337         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2338         JNIEnv *_env;
2339         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2340         jbyteArray txid_arr = (*_env)->NewByteArray(_env, 32);
2341         (*_env)->SetByteArrayRegion(_env, txid_arr, 0, 32, *txid);
2342         LDKu8slice script_pubkey_var = script_pubkey;
2343         jbyteArray script_pubkey_arr = (*_env)->NewByteArray(_env, script_pubkey_var.datalen);
2344         (*_env)->SetByteArrayRegion(_env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
2345         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2346         CHECK(obj != NULL);
2347         return (*_env)->CallVoidMethod(_env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
2348 }
2349 void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey) {
2350         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2351         JNIEnv *_env;
2352         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2353         long ret_outpoint = (long)outpoint;
2354         LDKu8slice script_pubkey_var = script_pubkey;
2355         jbyteArray script_pubkey_arr = (*_env)->NewByteArray(_env, script_pubkey_var.datalen);
2356         (*_env)->SetByteArrayRegion(_env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
2357         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2358         CHECK(obj != NULL);
2359         return (*_env)->CallVoidMethod(_env, obj, j_calls->register_output_meth, ret_outpoint, script_pubkey_arr);
2360 }
2361 static void LDKFilter_JCalls_free(void* this_arg) {
2362         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2363         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2364                 JNIEnv *env;
2365                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2366                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2367                 FREE(j_calls);
2368         }
2369 }
2370 static void* LDKFilter_JCalls_clone(const void* this_arg) {
2371         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2372         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2373         return (void*) this_arg;
2374 }
2375 static inline LDKFilter LDKFilter_init (JNIEnv * env, jclass _a, jobject o) {
2376         jclass c = (*env)->GetObjectClass(env, o);
2377         CHECK(c != NULL);
2378         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
2379         atomic_init(&calls->refcnt, 1);
2380         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2381         calls->o = (*env)->NewWeakGlobalRef(env, o);
2382         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
2383         CHECK(calls->register_tx_meth != NULL);
2384         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V");
2385         CHECK(calls->register_output_meth != NULL);
2386
2387         LDKFilter ret = {
2388                 .this_arg = (void*) calls,
2389                 .register_tx = register_tx_jcall,
2390                 .register_output = register_output_jcall,
2391                 .free = LDKFilter_JCalls_free,
2392         };
2393         return ret;
2394 }
2395 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new (JNIEnv * env, jclass _a, jobject o) {
2396         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
2397         *res_ptr = LDKFilter_init(env, _a, o);
2398         return (long)res_ptr;
2399 }
2400 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFilter_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2401         jobject ret = (*env)->NewLocalRef(env, ((LDKFilter_JCalls*)val)->o);
2402         CHECK(ret != NULL);
2403         return ret;
2404 }
2405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray txid, jbyteArray script_pubkey) {
2406         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2407         unsigned char txid_arr[32];
2408         CHECK((*_env)->GetArrayLength (_env, txid) == 32);
2409         (*_env)->GetByteArrayRegion (_env, txid, 0, 32, txid_arr);
2410         unsigned char (*txid_ref)[32] = &txid_arr;
2411         LDKu8slice script_pubkey_ref;
2412         script_pubkey_ref.data = (*_env)->GetByteArrayElements (_env, script_pubkey, NULL);
2413         script_pubkey_ref.datalen = (*_env)->GetArrayLength (_env, script_pubkey);
2414         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
2415         (*_env)->ReleaseByteArrayElements(_env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
2416 }
2417
2418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv * _env, jclass _b, jlong this_arg, jlong outpoint, jbyteArray script_pubkey) {
2419         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2420         LDKOutPoint outpoint_conv;
2421         outpoint_conv.inner = (void*)(outpoint & (~1));
2422         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
2423         LDKu8slice script_pubkey_ref;
2424         script_pubkey_ref.data = (*_env)->GetByteArrayElements (_env, script_pubkey, NULL);
2425         script_pubkey_ref.datalen = (*_env)->GetArrayLength (_env, script_pubkey);
2426         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
2427         (*_env)->ReleaseByteArrayElements(_env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
2428 }
2429
2430 typedef struct LDKBroadcasterInterface_JCalls {
2431         atomic_size_t refcnt;
2432         JavaVM *vm;
2433         jweak o;
2434         jmethodID broadcast_transaction_meth;
2435 } LDKBroadcasterInterface_JCalls;
2436 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2437         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2438         JNIEnv *_env;
2439         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2440         LDKTransaction *tx_copy = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
2441         *tx_copy = tx;
2442         long tx_ref = (long)tx_copy;
2443         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2444         CHECK(obj != NULL);
2445         return (*_env)->CallVoidMethod(_env, obj, j_calls->broadcast_transaction_meth, tx_ref);
2446 }
2447 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2448         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2449         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2450                 JNIEnv *env;
2451                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2452                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2453                 FREE(j_calls);
2454         }
2455 }
2456 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2457         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2458         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2459         return (void*) this_arg;
2460 }
2461 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv * env, jclass _a, jobject o) {
2462         jclass c = (*env)->GetObjectClass(env, o);
2463         CHECK(c != NULL);
2464         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2465         atomic_init(&calls->refcnt, 1);
2466         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2467         calls->o = (*env)->NewWeakGlobalRef(env, o);
2468         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "(J)V");
2469         CHECK(calls->broadcast_transaction_meth != NULL);
2470
2471         LDKBroadcasterInterface ret = {
2472                 .this_arg = (void*) calls,
2473                 .broadcast_transaction = broadcast_transaction_jcall,
2474                 .free = LDKBroadcasterInterface_JCalls_free,
2475         };
2476         return ret;
2477 }
2478 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2479         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2480         *res_ptr = LDKBroadcasterInterface_init(env, _a, o);
2481         return (long)res_ptr;
2482 }
2483 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2484         jobject ret = (*env)->NewLocalRef(env, ((LDKBroadcasterInterface_JCalls*)val)->o);
2485         CHECK(ret != NULL);
2486         return ret;
2487 }
2488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong tx) {
2489         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
2490         LDKTransaction tx_conv = *(LDKTransaction*)tx;
2491         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_conv);
2492 }
2493
2494 typedef struct LDKFeeEstimator_JCalls {
2495         atomic_size_t refcnt;
2496         JavaVM *vm;
2497         jweak o;
2498         jmethodID get_est_sat_per_1000_weight_meth;
2499 } LDKFeeEstimator_JCalls;
2500 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2501         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2502         JNIEnv *_env;
2503         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2504         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(_env, confirmation_target);
2505         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2506         CHECK(obj != NULL);
2507         return (*_env)->CallIntMethod(_env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2508 }
2509 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2510         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2511         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2512                 JNIEnv *env;
2513                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2514                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2515                 FREE(j_calls);
2516         }
2517 }
2518 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2519         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2520         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2521         return (void*) this_arg;
2522 }
2523 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv * env, jclass _a, jobject o) {
2524         jclass c = (*env)->GetObjectClass(env, o);
2525         CHECK(c != NULL);
2526         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2527         atomic_init(&calls->refcnt, 1);
2528         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2529         calls->o = (*env)->NewWeakGlobalRef(env, o);
2530         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
2531         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
2532
2533         LDKFeeEstimator ret = {
2534                 .this_arg = (void*) calls,
2535                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2536                 .free = LDKFeeEstimator_JCalls_free,
2537         };
2538         return ret;
2539 }
2540 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new (JNIEnv * env, jclass _a, jobject o) {
2541         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2542         *res_ptr = LDKFeeEstimator_init(env, _a, o);
2543         return (long)res_ptr;
2544 }
2545 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2546         jobject ret = (*env)->NewLocalRef(env, ((LDKFeeEstimator_JCalls*)val)->o);
2547         CHECK(ret != NULL);
2548         return ret;
2549 }
2550 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1get_1est_1sat_1per_11000_1weight(JNIEnv * _env, jclass _b, jlong this_arg, jclass confirmation_target) {
2551         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
2552         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(_env, confirmation_target);
2553         jint ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2554         return ret_val;
2555 }
2556
2557 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2558         LDKCVecTempl_C2TupleTempl_usize__Transaction *vec = (LDKCVecTempl_C2TupleTempl_usize__Transaction*)ptr;
2559         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_usize__Transaction));
2560 }
2561 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2562         LDKCVecTempl_C2TupleTempl_usize__Transaction *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_usize__Transaction), "LDKCVecTempl_C2TupleTempl_usize__Transaction");
2563         ret->datalen = (*env)->GetArrayLength(env, elems);
2564         if (ret->datalen == 0) {
2565                 ret->data = NULL;
2566         } else {
2567                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction) * ret->datalen, "LDKCVecTempl_C2TupleTempl_usize__Transaction Data");
2568                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2569                 for (size_t i = 0; i < ret->datalen; i++) {
2570                         jlong arr_elem = java_elems[i];
2571                         LDKC2TupleTempl_usize__Transaction arr_elem_conv = *(LDKC2TupleTempl_usize__Transaction*)arr_elem;
2572                         FREE((void*)arr_elem);
2573                         ret->data[i] = arr_elem_conv;
2574                 }
2575                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2576         }
2577         return (long)ret;
2578 }
2579 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2580         LDKCVecTempl_Transaction *vec = (LDKCVecTempl_Transaction*)ptr;
2581         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTransaction));
2582 }
2583 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2584         LDKCVecTempl_Transaction *ret = MALLOC(sizeof(LDKCVecTempl_Transaction), "LDKCVecTempl_Transaction");
2585         ret->datalen = (*env)->GetArrayLength(env, elems);
2586         if (ret->datalen == 0) {
2587                 ret->data = NULL;
2588         } else {
2589                 ret->data = MALLOC(sizeof(LDKTransaction) * ret->datalen, "LDKCVecTempl_Transaction Data");
2590                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2591                 for (size_t i = 0; i < ret->datalen; i++) {
2592                         jlong arr_elem = java_elems[i];
2593                         LDKTransaction arr_elem_conv = *(LDKTransaction*)arr_elem;
2594                         ret->data[i] = arr_elem_conv;
2595                 }
2596                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2597         }
2598         return (long)ret;
2599 }
2600 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2601         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *vec = (LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)ptr;
2602         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut));
2603 }
2604 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
2605         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
2606         ret->datalen = (*env)->GetArrayLength(env, elems);
2607         if (ret->datalen == 0) {
2608                 ret->data = NULL;
2609         } else {
2610                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut) * ret->datalen, "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut Data");
2611                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2612                 for (size_t i = 0; i < ret->datalen; i++) {
2613                         jlong arr_elem = java_elems[i];
2614                         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut arr_elem_conv = *(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)arr_elem;
2615                         FREE((void*)arr_elem);
2616                         ret->data[i] = arr_elem_conv;
2617                 }
2618                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2619         }
2620         return (long)ret;
2621 }
2622 typedef struct LDKKeysInterface_JCalls {
2623         atomic_size_t refcnt;
2624         JavaVM *vm;
2625         jweak o;
2626         jmethodID get_node_secret_meth;
2627         jmethodID get_destination_script_meth;
2628         jmethodID get_shutdown_pubkey_meth;
2629         jmethodID get_channel_keys_meth;
2630         jmethodID get_secure_random_bytes_meth;
2631 } LDKKeysInterface_JCalls;
2632 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2633         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2634         JNIEnv *_env;
2635         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2636         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2637         CHECK(obj != NULL);
2638         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_node_secret_meth);
2639         LDKSecretKey ret_ref;
2640         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
2641         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.bytes);
2642         return ret_ref;
2643 }
2644 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
2645         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2646         JNIEnv *_env;
2647         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2648         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2649         CHECK(obj != NULL);
2650         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_destination_script_meth);
2651         LDKCVec_u8Z ret_ref;
2652         ret_ref.data = (*_env)->GetByteArrayElements (_env, ret, NULL);
2653         ret_ref.datalen = (*_env)->GetArrayLength (_env, ret);
2654         return ret_ref;
2655 }
2656 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
2657         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2658         JNIEnv *_env;
2659         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2660         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2661         CHECK(obj != NULL);
2662         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_shutdown_pubkey_meth);
2663         LDKPublicKey ret_ref;
2664         CHECK((*_env)->GetArrayLength (_env, ret) == 33);
2665         (*_env)->GetByteArrayRegion (_env, ret, 0, 33, ret_ref.compressed_form);
2666         return ret_ref;
2667 }
2668 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2669         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2670         JNIEnv *_env;
2671         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2672         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2673         CHECK(obj != NULL);
2674         LDKChannelKeys* ret = (LDKChannelKeys*)(*_env)->CallLongMethod(_env, obj, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
2675         LDKChannelKeys res = *ret;
2676         FREE(ret);
2677         return res;
2678 }
2679 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2680         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2681         JNIEnv *_env;
2682         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2683         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2684         CHECK(obj != NULL);
2685         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_secure_random_bytes_meth);
2686         LDKThirtyTwoBytes ret_ref;
2687         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
2688         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.data);
2689         return ret_ref;
2690 }
2691 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2692         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2693         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2694                 JNIEnv *env;
2695                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2696                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2697                 FREE(j_calls);
2698         }
2699 }
2700 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2701         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2702         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2703         return (void*) this_arg;
2704 }
2705 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv * env, jclass _a, jobject o) {
2706         jclass c = (*env)->GetObjectClass(env, o);
2707         CHECK(c != NULL);
2708         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2709         atomic_init(&calls->refcnt, 1);
2710         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2711         calls->o = (*env)->NewWeakGlobalRef(env, o);
2712         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
2713         CHECK(calls->get_node_secret_meth != NULL);
2714         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
2715         CHECK(calls->get_destination_script_meth != NULL);
2716         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
2717         CHECK(calls->get_shutdown_pubkey_meth != NULL);
2718         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
2719         CHECK(calls->get_channel_keys_meth != NULL);
2720         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
2721         CHECK(calls->get_secure_random_bytes_meth != NULL);
2722
2723         LDKKeysInterface ret = {
2724                 .this_arg = (void*) calls,
2725                 .get_node_secret = get_node_secret_jcall,
2726                 .get_destination_script = get_destination_script_jcall,
2727                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2728                 .get_channel_keys = get_channel_keys_jcall,
2729                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2730                 .free = LDKKeysInterface_JCalls_free,
2731         };
2732         return ret;
2733 }
2734 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2735         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2736         *res_ptr = LDKKeysInterface_init(env, _a, o);
2737         return (long)res_ptr;
2738 }
2739 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2740         jobject ret = (*env)->NewLocalRef(env, ((LDKKeysInterface_JCalls*)val)->o);
2741         CHECK(ret != NULL);
2742         return ret;
2743 }
2744 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv * _env, jclass _b, jlong this_arg) {
2745         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2746         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2747         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
2748         return arg_arr;
2749 }
2750
2751 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv * _env, jclass _b, jlong this_arg) {
2752         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2753         LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2754         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
2755         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
2756         CVec_u8Z_free(arg_var);
2757         return arg_arr;
2758 }
2759
2760 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_arg) {
2761         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2762         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
2763         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
2764         return arg_arr;
2765 }
2766
2767 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1keys(JNIEnv * _env, jclass _b, jlong this_arg, jboolean inbound, jlong channel_value_satoshis) {
2768         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2769         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2770         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2771         return (long)ret;
2772 }
2773
2774 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv * _env, jclass _b, jlong this_arg) {
2775         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2776         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2777         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
2778         return arg_arr;
2779 }
2780
2781 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2782         LDKCVecTempl_ChannelDetails *vec = (LDKCVecTempl_ChannelDetails*)ptr;
2783         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2784         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2785         for (size_t i = 0; i < vec->datalen; i++) {
2786                 CHECK((((long)vec->data[i].inner) & 1) == 0);
2787                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2788         }
2789         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2790         return ret;
2791 }
2792 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1new(JNIEnv *env, jclass _b, jlongArray elems){
2793         LDKCVecTempl_ChannelDetails *ret = MALLOC(sizeof(LDKCVecTempl_ChannelDetails), "LDKCVecTempl_ChannelDetails");
2794         ret->datalen = (*env)->GetArrayLength(env, elems);
2795         if (ret->datalen == 0) {
2796                 ret->data = NULL;
2797         } else {
2798                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVecTempl_ChannelDetails Data");
2799                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2800                 for (size_t i = 0; i < ret->datalen; i++) {
2801                         jlong arr_elem = java_elems[i];
2802                         LDKChannelDetails arr_elem_conv;
2803                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2804                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2805                         if (arr_elem_conv.inner != NULL)
2806                                 arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2807                         ret->data[i] = arr_elem_conv;
2808                 }
2809                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2810         }
2811         return (long)ret;
2812 }
2813 static jclass LDKNetAddress_IPv4_class = NULL;
2814 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2815 static jclass LDKNetAddress_IPv6_class = NULL;
2816 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2817 static jclass LDKNetAddress_OnionV2_class = NULL;
2818 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2819 static jclass LDKNetAddress_OnionV3_class = NULL;
2820 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv * env, jclass _a) {
2822         LDKNetAddress_IPv4_class =
2823                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2824         CHECK(LDKNetAddress_IPv4_class != NULL);
2825         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
2826         CHECK(LDKNetAddress_IPv4_meth != NULL);
2827         LDKNetAddress_IPv6_class =
2828                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2829         CHECK(LDKNetAddress_IPv6_class != NULL);
2830         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
2831         CHECK(LDKNetAddress_IPv6_meth != NULL);
2832         LDKNetAddress_OnionV2_class =
2833                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2834         CHECK(LDKNetAddress_OnionV2_class != NULL);
2835         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
2836         CHECK(LDKNetAddress_OnionV2_meth != NULL);
2837         LDKNetAddress_OnionV3_class =
2838                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2839         CHECK(LDKNetAddress_OnionV3_class != NULL);
2840         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2841         CHECK(LDKNetAddress_OnionV3_meth != NULL);
2842 }
2843 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
2844         LDKNetAddress *obj = (LDKNetAddress*)ptr;
2845         switch(obj->tag) {
2846                 case LDKNetAddress_IPv4: {
2847                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 4);
2848                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 4, obj->i_pv4.addr.data);
2849                         return (*_env)->NewObject(_env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
2850                 }
2851                 case LDKNetAddress_IPv6: {
2852                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 16);
2853                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 16, obj->i_pv6.addr.data);
2854                         return (*_env)->NewObject(_env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
2855                 }
2856                 case LDKNetAddress_OnionV2: {
2857                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 10);
2858                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 10, obj->onion_v2.addr.data);
2859                         return (*_env)->NewObject(_env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
2860                 }
2861                 case LDKNetAddress_OnionV3: {
2862                         jbyteArray ed25519_pubkey_arr = (*_env)->NewByteArray(_env, 32);
2863                         (*_env)->SetByteArrayRegion(_env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2864                         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);
2865                 }
2866                 default: abort();
2867         }
2868 }
2869 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2870         LDKCVecTempl_NetAddress *vec = (LDKCVecTempl_NetAddress*)ptr;
2871         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKNetAddress));
2872 }
2873 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1new(JNIEnv *env, jclass _b, jlongArray elems){
2874         LDKCVecTempl_NetAddress *ret = MALLOC(sizeof(LDKCVecTempl_NetAddress), "LDKCVecTempl_NetAddress");
2875         ret->datalen = (*env)->GetArrayLength(env, elems);
2876         if (ret->datalen == 0) {
2877                 ret->data = NULL;
2878         } else {
2879                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVecTempl_NetAddress Data");
2880                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2881                 for (size_t i = 0; i < ret->datalen; i++) {
2882                         jlong arr_elem = java_elems[i];
2883                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
2884                         FREE((void*)arr_elem);
2885                         ret->data[i] = arr_elem_conv;
2886                 }
2887                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2888         }
2889         return (long)ret;
2890 }
2891 typedef struct LDKChannelMessageHandler_JCalls {
2892         atomic_size_t refcnt;
2893         JavaVM *vm;
2894         jweak o;
2895         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
2896         jmethodID handle_open_channel_meth;
2897         jmethodID handle_accept_channel_meth;
2898         jmethodID handle_funding_created_meth;
2899         jmethodID handle_funding_signed_meth;
2900         jmethodID handle_funding_locked_meth;
2901         jmethodID handle_shutdown_meth;
2902         jmethodID handle_closing_signed_meth;
2903         jmethodID handle_update_add_htlc_meth;
2904         jmethodID handle_update_fulfill_htlc_meth;
2905         jmethodID handle_update_fail_htlc_meth;
2906         jmethodID handle_update_fail_malformed_htlc_meth;
2907         jmethodID handle_commitment_signed_meth;
2908         jmethodID handle_revoke_and_ack_meth;
2909         jmethodID handle_update_fee_meth;
2910         jmethodID handle_announcement_signatures_meth;
2911         jmethodID peer_disconnected_meth;
2912         jmethodID peer_connected_meth;
2913         jmethodID handle_channel_reestablish_meth;
2914         jmethodID handle_error_meth;
2915 } LDKChannelMessageHandler_JCalls;
2916 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg) {
2917         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2918         JNIEnv *_env;
2919         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2920         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2921         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2922         LDKInitFeatures their_features_var = their_features;
2923         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2924         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2925         long their_features_ref;
2926         if (their_features_var.is_owned) {
2927                 their_features_ref = (long)their_features_var.inner | 1;
2928         } else {
2929                 their_features_ref = (long)their_features_var.inner & ~1;
2930         }
2931         long ret_msg = (long)msg;
2932         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2933         CHECK(obj != NULL);
2934         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, ret_msg);
2935 }
2936 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) {
2937         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2938         JNIEnv *_env;
2939         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2940         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2941         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2942         LDKInitFeatures their_features_var = their_features;
2943         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2944         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2945         long their_features_ref;
2946         if (their_features_var.is_owned) {
2947                 their_features_ref = (long)their_features_var.inner | 1;
2948         } else {
2949                 their_features_ref = (long)their_features_var.inner & ~1;
2950         }
2951         long ret_msg = (long)msg;
2952         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2953         CHECK(obj != NULL);
2954         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, ret_msg);
2955 }
2956 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg) {
2957         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2958         JNIEnv *_env;
2959         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2960         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2961         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2962         long ret_msg = (long)msg;
2963         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2964         CHECK(obj != NULL);
2965         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, ret_msg);
2966 }
2967 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) {
2968         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2969         JNIEnv *_env;
2970         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2971         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2972         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2973         long ret_msg = (long)msg;
2974         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2975         CHECK(obj != NULL);
2976         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, ret_msg);
2977 }
2978 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg) {
2979         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2980         JNIEnv *_env;
2981         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2982         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2983         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2984         long ret_msg = (long)msg;
2985         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2986         CHECK(obj != NULL);
2987         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, ret_msg);
2988 }
2989 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) {
2990         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2991         JNIEnv *_env;
2992         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2993         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2994         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2995         long ret_msg = (long)msg;
2996         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2997         CHECK(obj != NULL);
2998         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, ret_msg);
2999 }
3000 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) {
3001         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3002         JNIEnv *_env;
3003         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3004         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3005         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3006         long ret_msg = (long)msg;
3007         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3008         CHECK(obj != NULL);
3009         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, ret_msg);
3010 }
3011 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) {
3012         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3013         JNIEnv *_env;
3014         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3015         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3016         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3017         long ret_msg = (long)msg;
3018         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3019         CHECK(obj != NULL);
3020         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, ret_msg);
3021 }
3022 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) {
3023         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3024         JNIEnv *_env;
3025         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3026         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3027         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3028         long ret_msg = (long)msg;
3029         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3030         CHECK(obj != NULL);
3031         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, ret_msg);
3032 }
3033 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) {
3034         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3035         JNIEnv *_env;
3036         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3037         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3038         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3039         long ret_msg = (long)msg;
3040         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3041         CHECK(obj != NULL);
3042         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, ret_msg);
3043 }
3044 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) {
3045         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3046         JNIEnv *_env;
3047         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3048         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3049         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3050         long ret_msg = (long)msg;
3051         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3052         CHECK(obj != NULL);
3053         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, ret_msg);
3054 }
3055 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) {
3056         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3057         JNIEnv *_env;
3058         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3059         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3060         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3061         long ret_msg = (long)msg;
3062         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3063         CHECK(obj != NULL);
3064         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, ret_msg);
3065 }
3066 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) {
3067         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3068         JNIEnv *_env;
3069         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3070         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3071         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3072         long ret_msg = (long)msg;
3073         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3074         CHECK(obj != NULL);
3075         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, ret_msg);
3076 }
3077 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) {
3078         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3079         JNIEnv *_env;
3080         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3081         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3082         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3083         long ret_msg = (long)msg;
3084         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3085         CHECK(obj != NULL);
3086         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, ret_msg);
3087 }
3088 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) {
3089         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3090         JNIEnv *_env;
3091         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3092         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3093         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3094         long ret_msg = (long)msg;
3095         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3096         CHECK(obj != NULL);
3097         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, ret_msg);
3098 }
3099 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
3100         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3101         JNIEnv *_env;
3102         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3103         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3104         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3105         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3106         CHECK(obj != NULL);
3107         return (*_env)->CallVoidMethod(_env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
3108 }
3109 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit *msg) {
3110         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3111         JNIEnv *_env;
3112         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3113         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3114         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3115         long ret_msg = (long)msg;
3116         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3117         CHECK(obj != NULL);
3118         return (*_env)->CallVoidMethod(_env, obj, j_calls->peer_connected_meth, their_node_id_arr, ret_msg);
3119 }
3120 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) {
3121         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3122         JNIEnv *_env;
3123         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3124         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3125         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3126         long ret_msg = (long)msg;
3127         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3128         CHECK(obj != NULL);
3129         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, ret_msg);
3130 }
3131 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) {
3132         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3133         JNIEnv *_env;
3134         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3135         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3136         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3137         long ret_msg = (long)msg;
3138         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3139         CHECK(obj != NULL);
3140         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_error_meth, their_node_id_arr, ret_msg);
3141 }
3142 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
3143         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3144         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3145                 JNIEnv *env;
3146                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3147                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3148                 FREE(j_calls);
3149         }
3150 }
3151 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
3152         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3153         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3154         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
3155         return (void*) this_arg;
3156 }
3157 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
3158         jclass c = (*env)->GetObjectClass(env, o);
3159         CHECK(c != NULL);
3160         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
3161         atomic_init(&calls->refcnt, 1);
3162         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3163         calls->o = (*env)->NewWeakGlobalRef(env, o);
3164         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
3165         CHECK(calls->handle_open_channel_meth != NULL);
3166         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
3167         CHECK(calls->handle_accept_channel_meth != NULL);
3168         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
3169         CHECK(calls->handle_funding_created_meth != NULL);
3170         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
3171         CHECK(calls->handle_funding_signed_meth != NULL);
3172         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
3173         CHECK(calls->handle_funding_locked_meth != NULL);
3174         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
3175         CHECK(calls->handle_shutdown_meth != NULL);
3176         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
3177         CHECK(calls->handle_closing_signed_meth != NULL);
3178         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
3179         CHECK(calls->handle_update_add_htlc_meth != NULL);
3180         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
3181         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
3182         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
3183         CHECK(calls->handle_update_fail_htlc_meth != NULL);
3184         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
3185         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
3186         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
3187         CHECK(calls->handle_commitment_signed_meth != NULL);
3188         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
3189         CHECK(calls->handle_revoke_and_ack_meth != NULL);
3190         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
3191         CHECK(calls->handle_update_fee_meth != NULL);
3192         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
3193         CHECK(calls->handle_announcement_signatures_meth != NULL);
3194         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
3195         CHECK(calls->peer_disconnected_meth != NULL);
3196         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
3197         CHECK(calls->peer_connected_meth != NULL);
3198         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
3199         CHECK(calls->handle_channel_reestablish_meth != NULL);
3200         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
3201         CHECK(calls->handle_error_meth != NULL);
3202
3203         LDKChannelMessageHandler ret = {
3204                 .this_arg = (void*) calls,
3205                 .handle_open_channel = handle_open_channel_jcall,
3206                 .handle_accept_channel = handle_accept_channel_jcall,
3207                 .handle_funding_created = handle_funding_created_jcall,
3208                 .handle_funding_signed = handle_funding_signed_jcall,
3209                 .handle_funding_locked = handle_funding_locked_jcall,
3210                 .handle_shutdown = handle_shutdown_jcall,
3211                 .handle_closing_signed = handle_closing_signed_jcall,
3212                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3213                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3214                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3215                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3216                 .handle_commitment_signed = handle_commitment_signed_jcall,
3217                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3218                 .handle_update_fee = handle_update_fee_jcall,
3219                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3220                 .peer_disconnected = peer_disconnected_jcall,
3221                 .peer_connected = peer_connected_jcall,
3222                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3223                 .handle_error = handle_error_jcall,
3224                 .free = LDKChannelMessageHandler_JCalls_free,
3225                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, _a, MessageSendEventsProvider),
3226         };
3227         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3228         return ret;
3229 }
3230 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
3231         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3232         *res_ptr = LDKChannelMessageHandler_init(env, _a, o, MessageSendEventsProvider);
3233         return (long)res_ptr;
3234 }
3235 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3236         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelMessageHandler_JCalls*)val)->o);
3237         CHECK(ret != NULL);
3238         return ret;
3239 }
3240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1open_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong their_features, jlong msg) {
3241         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3242         LDKPublicKey their_node_id_ref;
3243         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3244         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3245         LDKInitFeatures their_features_conv;
3246         their_features_conv.inner = (void*)(their_features & (~1));
3247         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3248         // Warning: we may need a move here but can't clone!
3249         LDKOpenChannel msg_conv;
3250         msg_conv.inner = (void*)(msg & (~1));
3251         msg_conv.is_owned = (msg & 1) || (msg == 0);
3252         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3253 }
3254
3255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1accept_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong their_features, jlong msg) {
3256         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3257         LDKPublicKey their_node_id_ref;
3258         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3259         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3260         LDKInitFeatures their_features_conv;
3261         their_features_conv.inner = (void*)(their_features & (~1));
3262         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3263         // Warning: we may need a move here but can't clone!
3264         LDKAcceptChannel msg_conv;
3265         msg_conv.inner = (void*)(msg & (~1));
3266         msg_conv.is_owned = (msg & 1) || (msg == 0);
3267         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3268 }
3269
3270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1created(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3271         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3272         LDKPublicKey their_node_id_ref;
3273         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3274         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3275         LDKFundingCreated msg_conv;
3276         msg_conv.inner = (void*)(msg & (~1));
3277         msg_conv.is_owned = (msg & 1) || (msg == 0);
3278         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3279 }
3280
3281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1signed(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3282         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3283         LDKPublicKey their_node_id_ref;
3284         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3285         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3286         LDKFundingSigned msg_conv;
3287         msg_conv.inner = (void*)(msg & (~1));
3288         msg_conv.is_owned = (msg & 1) || (msg == 0);
3289         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3290 }
3291
3292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3293         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3294         LDKPublicKey their_node_id_ref;
3295         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3296         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3297         LDKFundingLocked msg_conv;
3298         msg_conv.inner = (void*)(msg & (~1));
3299         msg_conv.is_owned = (msg & 1) || (msg == 0);
3300         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3301 }
3302
3303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3304         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3305         LDKPublicKey their_node_id_ref;
3306         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3307         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3308         LDKShutdown msg_conv;
3309         msg_conv.inner = (void*)(msg & (~1));
3310         msg_conv.is_owned = (msg & 1) || (msg == 0);
3311         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3312 }
3313
3314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1closing_1signed(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3315         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3316         LDKPublicKey their_node_id_ref;
3317         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3318         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3319         LDKClosingSigned msg_conv;
3320         msg_conv.inner = (void*)(msg & (~1));
3321         msg_conv.is_owned = (msg & 1) || (msg == 0);
3322         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3323 }
3324
3325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1add_1htlc(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3326         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3327         LDKPublicKey their_node_id_ref;
3328         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3329         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3330         LDKUpdateAddHTLC msg_conv;
3331         msg_conv.inner = (void*)(msg & (~1));
3332         msg_conv.is_owned = (msg & 1) || (msg == 0);
3333         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3334 }
3335
3336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fulfill_1htlc(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3337         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3338         LDKPublicKey their_node_id_ref;
3339         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3340         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3341         LDKUpdateFulfillHTLC msg_conv;
3342         msg_conv.inner = (void*)(msg & (~1));
3343         msg_conv.is_owned = (msg & 1) || (msg == 0);
3344         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3345 }
3346
3347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1htlc(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3348         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3349         LDKPublicKey their_node_id_ref;
3350         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3351         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3352         LDKUpdateFailHTLC msg_conv;
3353         msg_conv.inner = (void*)(msg & (~1));
3354         msg_conv.is_owned = (msg & 1) || (msg == 0);
3355         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3356 }
3357
3358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1malformed_1htlc(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3359         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3360         LDKPublicKey their_node_id_ref;
3361         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3362         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3363         LDKUpdateFailMalformedHTLC msg_conv;
3364         msg_conv.inner = (void*)(msg & (~1));
3365         msg_conv.is_owned = (msg & 1) || (msg == 0);
3366         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3367 }
3368
3369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3370         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3371         LDKPublicKey their_node_id_ref;
3372         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3373         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3374         LDKCommitmentSigned msg_conv;
3375         msg_conv.inner = (void*)(msg & (~1));
3376         msg_conv.is_owned = (msg & 1) || (msg == 0);
3377         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3378 }
3379
3380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1revoke_1and_1ack(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3381         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3382         LDKPublicKey their_node_id_ref;
3383         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3384         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3385         LDKRevokeAndACK msg_conv;
3386         msg_conv.inner = (void*)(msg & (~1));
3387         msg_conv.is_owned = (msg & 1) || (msg == 0);
3388         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3389 }
3390
3391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fee(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3392         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3393         LDKPublicKey their_node_id_ref;
3394         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3395         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3396         LDKUpdateFee msg_conv;
3397         msg_conv.inner = (void*)(msg & (~1));
3398         msg_conv.is_owned = (msg & 1) || (msg == 0);
3399         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3400 }
3401
3402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1announcement_1signatures(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3403         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3404         LDKPublicKey their_node_id_ref;
3405         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3406         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3407         LDKAnnouncementSignatures msg_conv;
3408         msg_conv.inner = (void*)(msg & (~1));
3409         msg_conv.is_owned = (msg & 1) || (msg == 0);
3410         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3411 }
3412
3413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jboolean no_connection_possible) {
3414         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3415         LDKPublicKey their_node_id_ref;
3416         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3417         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3418         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
3419 }
3420
3421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3422         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3423         LDKPublicKey their_node_id_ref;
3424         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3425         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3426         LDKInit msg_conv;
3427         msg_conv.inner = (void*)(msg & (~1));
3428         msg_conv.is_owned = (msg & 1) || (msg == 0);
3429         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3430 }
3431
3432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1reestablish(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3433         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3434         LDKPublicKey their_node_id_ref;
3435         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3436         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3437         LDKChannelReestablish msg_conv;
3438         msg_conv.inner = (void*)(msg & (~1));
3439         msg_conv.is_owned = (msg & 1) || (msg == 0);
3440         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3441 }
3442
3443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1error(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3444         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3445         LDKPublicKey their_node_id_ref;
3446         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3447         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3448         LDKErrorMessage msg_conv;
3449         msg_conv.inner = (void*)(msg & (~1));
3450         msg_conv.is_owned = (msg & 1) || (msg == 0);
3451         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3452 }
3453
3454 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3455         LDKCVecTempl_ChannelMonitor *vec = (LDKCVecTempl_ChannelMonitor*)ptr;
3456         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3457         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3458         for (size_t i = 0; i < vec->datalen; i++) {
3459                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3460                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3461         }
3462         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3463         return ret;
3464 }
3465 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1new(JNIEnv *env, jclass _b, jlongArray elems){
3466         LDKCVecTempl_ChannelMonitor *ret = MALLOC(sizeof(LDKCVecTempl_ChannelMonitor), "LDKCVecTempl_ChannelMonitor");
3467         ret->datalen = (*env)->GetArrayLength(env, elems);
3468         if (ret->datalen == 0) {
3469                 ret->data = NULL;
3470         } else {
3471                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVecTempl_ChannelMonitor Data");
3472                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3473                 for (size_t i = 0; i < ret->datalen; i++) {
3474                         jlong arr_elem = java_elems[i];
3475                         LDKChannelMonitor arr_elem_conv;
3476                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3477                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3478                         // Warning: we may need a move here but can't clone!
3479                         ret->data[i] = arr_elem_conv;
3480                 }
3481                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3482         }
3483         return (long)ret;
3484 }
3485 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3486         LDKCVecTempl_u64 *vec = (LDKCVecTempl_u64*)ptr;
3487         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint64_t));
3488 }
3489 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1new(JNIEnv *env, jclass _b, jlongArray elems){
3490         LDKCVecTempl_u64 *ret = MALLOC(sizeof(LDKCVecTempl_u64), "LDKCVecTempl_u64");
3491         ret->datalen = (*env)->GetArrayLength(env, elems);
3492         if (ret->datalen == 0) {
3493                 ret->data = NULL;
3494         } else {
3495                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVecTempl_u64 Data");
3496                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3497                 for (size_t i = 0; i < ret->datalen; i++) {
3498                         ret->data[i] = java_elems[i];
3499                 }
3500                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3501         }
3502         return (long)ret;
3503 }
3504 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3505         LDKCVecTempl_UpdateAddHTLC *vec = (LDKCVecTempl_UpdateAddHTLC*)ptr;
3506         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3507         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3508         for (size_t i = 0; i < vec->datalen; i++) {
3509                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3510                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3511         }
3512         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3513         return ret;
3514 }
3515 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3516         LDKCVecTempl_UpdateAddHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateAddHTLC), "LDKCVecTempl_UpdateAddHTLC");
3517         ret->datalen = (*env)->GetArrayLength(env, elems);
3518         if (ret->datalen == 0) {
3519                 ret->data = NULL;
3520         } else {
3521                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVecTempl_UpdateAddHTLC Data");
3522                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3523                 for (size_t i = 0; i < ret->datalen; i++) {
3524                         jlong arr_elem = java_elems[i];
3525                         LDKUpdateAddHTLC arr_elem_conv;
3526                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3527                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3528                         if (arr_elem_conv.inner != NULL)
3529                                 arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3530                         ret->data[i] = arr_elem_conv;
3531                 }
3532                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3533         }
3534         return (long)ret;
3535 }
3536 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3537         LDKCVecTempl_UpdateFulfillHTLC *vec = (LDKCVecTempl_UpdateFulfillHTLC*)ptr;
3538         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3539         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3540         for (size_t i = 0; i < vec->datalen; i++) {
3541                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3542                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3543         }
3544         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3545         return ret;
3546 }
3547 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3548         LDKCVecTempl_UpdateFulfillHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFulfillHTLC), "LDKCVecTempl_UpdateFulfillHTLC");
3549         ret->datalen = (*env)->GetArrayLength(env, elems);
3550         if (ret->datalen == 0) {
3551                 ret->data = NULL;
3552         } else {
3553                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVecTempl_UpdateFulfillHTLC Data");
3554                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3555                 for (size_t i = 0; i < ret->datalen; i++) {
3556                         jlong arr_elem = java_elems[i];
3557                         LDKUpdateFulfillHTLC arr_elem_conv;
3558                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3559                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3560                         if (arr_elem_conv.inner != NULL)
3561                                 arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3562                         ret->data[i] = arr_elem_conv;
3563                 }
3564                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3565         }
3566         return (long)ret;
3567 }
3568 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3569         LDKCVecTempl_UpdateFailHTLC *vec = (LDKCVecTempl_UpdateFailHTLC*)ptr;
3570         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3571         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3572         for (size_t i = 0; i < vec->datalen; i++) {
3573                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3574                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3575         }
3576         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3577         return ret;
3578 }
3579 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3580         LDKCVecTempl_UpdateFailHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailHTLC), "LDKCVecTempl_UpdateFailHTLC");
3581         ret->datalen = (*env)->GetArrayLength(env, elems);
3582         if (ret->datalen == 0) {
3583                 ret->data = NULL;
3584         } else {
3585                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailHTLC Data");
3586                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3587                 for (size_t i = 0; i < ret->datalen; i++) {
3588                         jlong arr_elem = java_elems[i];
3589                         LDKUpdateFailHTLC arr_elem_conv;
3590                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3591                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3592                         if (arr_elem_conv.inner != NULL)
3593                                 arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3594                         ret->data[i] = arr_elem_conv;
3595                 }
3596                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3597         }
3598         return (long)ret;
3599 }
3600 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3601         LDKCVecTempl_UpdateFailMalformedHTLC *vec = (LDKCVecTempl_UpdateFailMalformedHTLC*)ptr;
3602         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3603         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3604         for (size_t i = 0; i < vec->datalen; i++) {
3605                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3606                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3607         }
3608         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3609         return ret;
3610 }
3611 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3612         LDKCVecTempl_UpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailMalformedHTLC), "LDKCVecTempl_UpdateFailMalformedHTLC");
3613         ret->datalen = (*env)->GetArrayLength(env, elems);
3614         if (ret->datalen == 0) {
3615                 ret->data = NULL;
3616         } else {
3617                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailMalformedHTLC Data");
3618                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3619                 for (size_t i = 0; i < ret->datalen; i++) {
3620                         jlong arr_elem = java_elems[i];
3621                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3622                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3623                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3624                         if (arr_elem_conv.inner != NULL)
3625                                 arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3626                         ret->data[i] = arr_elem_conv;
3627                 }
3628                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3629         }
3630         return (long)ret;
3631 }
3632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3633         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3634 }
3635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
3636         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
3637         CHECK(val->result_ok);
3638         return *val->contents.result;
3639 }
3640 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
3641         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
3642         CHECK(!val->result_ok);
3643         LDKLightningError err_var = (*val->contents.err);
3644         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3645         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3646         long err_ref = (long)err_var.inner & ~1;
3647         return err_ref;
3648 }
3649 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3650         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *vec = (LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)ptr;
3651         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate));
3652 }
3653 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *env, jclass _b, jlongArray elems){
3654         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *ret = MALLOC(sizeof(LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
3655         ret->datalen = (*env)->GetArrayLength(env, elems);
3656         if (ret->datalen == 0) {
3657                 ret->data = NULL;
3658         } else {
3659                 ret->data = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate) * ret->datalen, "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate Data");
3660                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3661                 for (size_t i = 0; i < ret->datalen; i++) {
3662                         jlong arr_elem = java_elems[i];
3663                         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate arr_elem_conv = *(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)arr_elem;
3664                         FREE((void*)arr_elem);
3665                         ret->data[i] = arr_elem_conv;
3666                 }
3667                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3668         }
3669         return (long)ret;
3670 }
3671 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3672         LDKCVecTempl_NodeAnnouncement *vec = (LDKCVecTempl_NodeAnnouncement*)ptr;
3673         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3674         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3675         for (size_t i = 0; i < vec->datalen; i++) {
3676                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3677                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3678         }
3679         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3680         return ret;
3681 }
3682 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1new(JNIEnv *env, jclass _b, jlongArray elems){
3683         LDKCVecTempl_NodeAnnouncement *ret = MALLOC(sizeof(LDKCVecTempl_NodeAnnouncement), "LDKCVecTempl_NodeAnnouncement");
3684         ret->datalen = (*env)->GetArrayLength(env, elems);
3685         if (ret->datalen == 0) {
3686                 ret->data = NULL;
3687         } else {
3688                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVecTempl_NodeAnnouncement Data");
3689                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3690                 for (size_t i = 0; i < ret->datalen; i++) {
3691                         jlong arr_elem = java_elems[i];
3692                         LDKNodeAnnouncement arr_elem_conv;
3693                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3694                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3695                         if (arr_elem_conv.inner != NULL)
3696                                 arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3697                         ret->data[i] = arr_elem_conv;
3698                 }
3699                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3700         }
3701         return (long)ret;
3702 }
3703 typedef struct LDKRoutingMessageHandler_JCalls {
3704         atomic_size_t refcnt;
3705         JavaVM *vm;
3706         jweak o;
3707         jmethodID handle_node_announcement_meth;
3708         jmethodID handle_channel_announcement_meth;
3709         jmethodID handle_channel_update_meth;
3710         jmethodID handle_htlc_fail_channel_update_meth;
3711         jmethodID get_next_channel_announcements_meth;
3712         jmethodID get_next_node_announcements_meth;
3713         jmethodID should_request_full_sync_meth;
3714 } LDKRoutingMessageHandler_JCalls;
3715 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement *msg) {
3716         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3717         JNIEnv *_env;
3718         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3719         long ret_msg = (long)msg;
3720         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3721         CHECK(obj != NULL);
3722         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_node_announcement_meth, ret_msg);
3723         LDKCResult_boolLightningErrorZ res = *ret;
3724         FREE(ret);
3725         return res;
3726 }
3727 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement *msg) {
3728         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3729         JNIEnv *_env;
3730         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3731         long ret_msg = (long)msg;
3732         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3733         CHECK(obj != NULL);
3734         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_announcement_meth, ret_msg);
3735         LDKCResult_boolLightningErrorZ res = *ret;
3736         FREE(ret);
3737         return res;
3738 }
3739 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate *msg) {
3740         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3741         JNIEnv *_env;
3742         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3743         long ret_msg = (long)msg;
3744         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3745         CHECK(obj != NULL);
3746         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_update_meth, ret_msg);
3747         LDKCResult_boolLightningErrorZ res = *ret;
3748         FREE(ret);
3749         return res;
3750 }
3751 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate *update) {
3752         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3753         JNIEnv *_env;
3754         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3755         long ret_update = (long)update;
3756         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3757         CHECK(obj != NULL);
3758         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
3759 }
3760 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
3761         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3762         JNIEnv *_env;
3763         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3764         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3765         CHECK(obj != NULL);
3766         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
3767         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
3768         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
3769         if (ret_constr.datalen > 0)
3770                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
3771         else
3772                 ret_constr.data = NULL;
3773         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
3774         for (size_t l = 0; l < ret_constr.datalen; l++) {
3775                 long arr_conv_63 = ret_vals[l];
3776                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
3777                 FREE((void*)arr_conv_63);
3778                 ret_constr.data[l] = arr_conv_63_conv;
3779         }
3780         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
3781         return ret_constr;
3782 }
3783 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
3784         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3785         JNIEnv *_env;
3786         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3787         jbyteArray starting_point_arr = (*_env)->NewByteArray(_env, 33);
3788         (*_env)->SetByteArrayRegion(_env, starting_point_arr, 0, 33, starting_point.compressed_form);
3789         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3790         CHECK(obj != NULL);
3791         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
3792         LDKCVec_NodeAnnouncementZ ret_constr;
3793         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
3794         if (ret_constr.datalen > 0)
3795                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
3796         else
3797                 ret_constr.data = NULL;
3798         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
3799         for (size_t s = 0; s < ret_constr.datalen; s++) {
3800                 long arr_conv_18 = ret_vals[s];
3801                 LDKNodeAnnouncement arr_conv_18_conv;
3802                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
3803                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
3804                 if (arr_conv_18_conv.inner != NULL)
3805                         arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv);
3806                 ret_constr.data[s] = arr_conv_18_conv;
3807         }
3808         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
3809         return ret_constr;
3810 }
3811 bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) {
3812         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3813         JNIEnv *_env;
3814         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3815         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
3816         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, node_id.compressed_form);
3817         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3818         CHECK(obj != NULL);
3819         return (*_env)->CallBooleanMethod(_env, obj, j_calls->should_request_full_sync_meth, node_id_arr);
3820 }
3821 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
3822         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3823         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3824                 JNIEnv *env;
3825                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3826                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3827                 FREE(j_calls);
3828         }
3829 }
3830 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
3831         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3832         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3833         return (void*) this_arg;
3834 }
3835 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * env, jclass _a, jobject o) {
3836         jclass c = (*env)->GetObjectClass(env, o);
3837         CHECK(c != NULL);
3838         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
3839         atomic_init(&calls->refcnt, 1);
3840         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3841         calls->o = (*env)->NewWeakGlobalRef(env, o);
3842         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
3843         CHECK(calls->handle_node_announcement_meth != NULL);
3844         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
3845         CHECK(calls->handle_channel_announcement_meth != NULL);
3846         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
3847         CHECK(calls->handle_channel_update_meth != NULL);
3848         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
3849         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
3850         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
3851         CHECK(calls->get_next_channel_announcements_meth != NULL);
3852         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
3853         CHECK(calls->get_next_node_announcements_meth != NULL);
3854         calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "([B)Z");
3855         CHECK(calls->should_request_full_sync_meth != NULL);
3856
3857         LDKRoutingMessageHandler ret = {
3858                 .this_arg = (void*) calls,
3859                 .handle_node_announcement = handle_node_announcement_jcall,
3860                 .handle_channel_announcement = handle_channel_announcement_jcall,
3861                 .handle_channel_update = handle_channel_update_jcall,
3862                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
3863                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
3864                 .get_next_node_announcements = get_next_node_announcements_jcall,
3865                 .should_request_full_sync = should_request_full_sync_jcall,
3866                 .free = LDKRoutingMessageHandler_JCalls_free,
3867         };
3868         return ret;
3869 }
3870 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new (JNIEnv * env, jclass _a, jobject o) {
3871         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
3872         *res_ptr = LDKRoutingMessageHandler_init(env, _a, o);
3873         return (long)res_ptr;
3874 }
3875 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3876         jobject ret = (*env)->NewLocalRef(env, ((LDKRoutingMessageHandler_JCalls*)val)->o);
3877         CHECK(ret != NULL);
3878         return ret;
3879 }
3880 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3881         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3882         LDKNodeAnnouncement msg_conv;
3883         msg_conv.inner = (void*)(msg & (~1));
3884         msg_conv.is_owned = (msg & 1) || (msg == 0);
3885         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3886         *ret = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
3887         return (long)ret;
3888 }
3889
3890 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3891         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3892         LDKChannelAnnouncement msg_conv;
3893         msg_conv.inner = (void*)(msg & (~1));
3894         msg_conv.is_owned = (msg & 1) || (msg == 0);
3895         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3896         *ret = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3897         return (long)ret;
3898 }
3899
3900 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3901         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3902         LDKChannelUpdate msg_conv;
3903         msg_conv.inner = (void*)(msg & (~1));
3904         msg_conv.is_owned = (msg & 1) || (msg == 0);
3905         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3906         *ret = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
3907         return (long)ret;
3908 }
3909
3910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong update) {
3911         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3912         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
3913         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
3914 }
3915
3916 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv * _env, jclass _b, jlong this_arg, jlong starting_point, jbyte batch_amount) {
3917         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3918         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
3919         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
3920         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
3921         for (size_t l = 0; l < ret_var.datalen; l++) {
3922                 long arr_conv_63_ref = (long)&ret_var.data[l];
3923                 ret_arr_ptr[l] = arr_conv_63_ref;
3924         }
3925         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
3926         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(ret_var);
3927         return ret_arr;
3928 }
3929
3930 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray starting_point, jbyte batch_amount) {
3931         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3932         LDKPublicKey starting_point_ref;
3933         CHECK((*_env)->GetArrayLength (_env, starting_point) == 33);
3934         (*_env)->GetByteArrayRegion (_env, starting_point, 0, 33, starting_point_ref.compressed_form);
3935         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
3936         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
3937         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
3938         for (size_t s = 0; s < ret_var.datalen; s++) {
3939                 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
3940                 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3941                 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3942                 long arr_conv_18_ref;
3943                 if (arr_conv_18_var.is_owned) {
3944                         arr_conv_18_ref = (long)arr_conv_18_var.inner | 1;
3945                 } else {
3946                         arr_conv_18_ref = (long)arr_conv_18_var.inner & ~1;
3947                 }
3948                 ret_arr_ptr[s] = arr_conv_18_ref;
3949         }
3950         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
3951         FREE(ret_var.data);
3952         return ret_arr;
3953 }
3954
3955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray node_id) {
3956         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3957         LDKPublicKey node_id_ref;
3958         CHECK((*_env)->GetArrayLength (_env, node_id) == 33);
3959         (*_env)->GetByteArrayRegion (_env, node_id, 0, 33, node_id_ref.compressed_form);
3960         jboolean ret_val = (this_arg_conv->should_request_full_sync)(this_arg_conv->this_arg, node_id_ref);
3961         return ret_val;
3962 }
3963
3964 typedef struct LDKSocketDescriptor_JCalls {
3965         atomic_size_t refcnt;
3966         JavaVM *vm;
3967         jweak o;
3968         jmethodID send_data_meth;
3969         jmethodID disconnect_socket_meth;
3970         jmethodID eq_meth;
3971         jmethodID hash_meth;
3972 } LDKSocketDescriptor_JCalls;
3973 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
3974         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3975         JNIEnv *_env;
3976         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3977         LDKu8slice data_var = data;
3978         jbyteArray data_arr = (*_env)->NewByteArray(_env, data_var.datalen);
3979         (*_env)->SetByteArrayRegion(_env, data_arr, 0, data_var.datalen, data_var.data);
3980         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3981         CHECK(obj != NULL);
3982         return (*_env)->CallLongMethod(_env, obj, j_calls->send_data_meth, data_arr, resume_read);
3983 }
3984 void disconnect_socket_jcall(void* this_arg) {
3985         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3986         JNIEnv *_env;
3987         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3988         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3989         CHECK(obj != NULL);
3990         return (*_env)->CallVoidMethod(_env, obj, j_calls->disconnect_socket_meth);
3991 }
3992 bool eq_jcall(const void* this_arg, const void *other_arg) {
3993         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3994         JNIEnv *_env;
3995         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3996         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3997         CHECK(obj != NULL);
3998         return (*_env)->CallBooleanMethod(_env, obj, j_calls->eq_meth, other_arg);
3999 }
4000 uint64_t hash_jcall(const void* this_arg) {
4001         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4002         JNIEnv *_env;
4003         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
4004         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
4005         CHECK(obj != NULL);
4006         return (*_env)->CallLongMethod(_env, obj, j_calls->hash_meth);
4007 }
4008 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
4009         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4010         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4011                 JNIEnv *env;
4012                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
4013                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4014                 FREE(j_calls);
4015         }
4016 }
4017 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
4018         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4019         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4020         return (void*) this_arg;
4021 }
4022 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv * env, jclass _a, jobject o) {
4023         jclass c = (*env)->GetObjectClass(env, o);
4024         CHECK(c != NULL);
4025         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
4026         atomic_init(&calls->refcnt, 1);
4027         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4028         calls->o = (*env)->NewWeakGlobalRef(env, o);
4029         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
4030         CHECK(calls->send_data_meth != NULL);
4031         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
4032         CHECK(calls->disconnect_socket_meth != NULL);
4033         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
4034         CHECK(calls->eq_meth != NULL);
4035         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
4036         CHECK(calls->hash_meth != NULL);
4037
4038         LDKSocketDescriptor ret = {
4039                 .this_arg = (void*) calls,
4040                 .send_data = send_data_jcall,
4041                 .disconnect_socket = disconnect_socket_jcall,
4042                 .eq = eq_jcall,
4043                 .hash = hash_jcall,
4044                 .clone = LDKSocketDescriptor_JCalls_clone,
4045                 .free = LDKSocketDescriptor_JCalls_free,
4046         };
4047         return ret;
4048 }
4049 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new (JNIEnv * env, jclass _a, jobject o) {
4050         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
4051         *res_ptr = LDKSocketDescriptor_init(env, _a, o);
4052         return (long)res_ptr;
4053 }
4054 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
4055         jobject ret = (*env)->NewLocalRef(env, ((LDKSocketDescriptor_JCalls*)val)->o);
4056         CHECK(ret != NULL);
4057         return ret;
4058 }
4059 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray data, jboolean resume_read) {
4060         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4061         LDKu8slice data_ref;
4062         data_ref.data = (*_env)->GetByteArrayElements (_env, data, NULL);
4063         data_ref.datalen = (*_env)->GetArrayLength (_env, data);
4064         jlong ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
4065         (*_env)->ReleaseByteArrayElements(_env, data, (int8_t*)data_ref.data, 0);
4066         return ret_val;
4067 }
4068
4069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv * _env, jclass _b, jlong this_arg) {
4070         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4071         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
4072 }
4073
4074 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv * _env, jclass _b, jlong this_arg) {
4075         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4076         jlong ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
4077         return ret_val;
4078 }
4079
4080 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4081         LDKCVecTempl_PublicKey *vec = (LDKCVecTempl_PublicKey*)ptr;
4082         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKPublicKey));
4083 }
4084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4085         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4086 }
4087 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4088         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4089         CHECK(val->result_ok);
4090         LDKCVecTempl_u8 res_var = (*val->contents.result);
4091         jbyteArray res_arr = (*_env)->NewByteArray(_env, res_var.datalen);
4092         (*_env)->SetByteArrayRegion(_env, res_arr, 0, res_var.datalen, res_var.data);
4093         return res_arr;
4094 }
4095 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4096         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4097         CHECK(!val->result_ok);
4098         LDKPeerHandleError err_var = (*val->contents.err);
4099         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4100         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4101         long err_ref = (long)err_var.inner & ~1;
4102         return err_ref;
4103 }
4104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4105         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4106 }
4107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4108         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
4109         CHECK(val->result_ok);
4110         return *val->contents.result;
4111 }
4112 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4113         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
4114         CHECK(!val->result_ok);
4115         LDKPeerHandleError err_var = (*val->contents.err);
4116         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4117         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4118         long err_ref = (long)err_var.inner & ~1;
4119         return err_ref;
4120 }
4121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4122         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
4123 }
4124 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4125         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
4126         CHECK(val->result_ok);
4127         jbyteArray res_arr = (*_env)->NewByteArray(_env, 32);
4128         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 32, (*val->contents.result).bytes);
4129         return res_arr;
4130 }
4131 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4132         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
4133         CHECK(!val->result_ok);
4134         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4135         return err_conv;
4136 }
4137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4138         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
4139 }
4140 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4141         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
4142         CHECK(val->result_ok);
4143         jbyteArray res_arr = (*_env)->NewByteArray(_env, 33);
4144         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 33, (*val->contents.result).compressed_form);
4145         return res_arr;
4146 }
4147 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4148         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
4149         CHECK(!val->result_ok);
4150         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4151         return err_conv;
4152 }
4153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4154         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
4155 }
4156 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4157         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4158         CHECK(val->result_ok);
4159         LDKTxCreationKeys res_var = (*val->contents.result);
4160         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4161         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4162         long res_ref = (long)res_var.inner & ~1;
4163         return res_ref;
4164 }
4165 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4166         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4167         CHECK(!val->result_ok);
4168         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4169         return err_conv;
4170 }
4171 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4172         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *vec = (LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature*)ptr;
4173         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature));
4174 }
4175 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
4176         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature), "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature");
4177         ret->datalen = (*env)->GetArrayLength(env, elems);
4178         if (ret->datalen == 0) {
4179                 ret->data = NULL;
4180         } else {
4181                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature) * ret->datalen, "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature Data");
4182                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4183                 for (size_t i = 0; i < ret->datalen; i++) {
4184                         jlong arr_elem = java_elems[i];
4185                         LDKC2TupleTempl_HTLCOutputInCommitment__Signature arr_elem_conv = *(LDKC2TupleTempl_HTLCOutputInCommitment__Signature*)arr_elem;
4186                         FREE((void*)arr_elem);
4187                         ret->data[i] = arr_elem_conv;
4188                 }
4189                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4190         }
4191         return (long)ret;
4192 }
4193 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4194         LDKCVecTempl_RouteHop *vec = (LDKCVecTempl_RouteHop*)ptr;
4195         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
4196         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
4197         for (size_t i = 0; i < vec->datalen; i++) {
4198                 CHECK((((long)vec->data[i].inner) & 1) == 0);
4199                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
4200         }
4201         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
4202         return ret;
4203 }
4204 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
4205         LDKCVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_RouteHop), "LDKCVecTempl_RouteHop");
4206         ret->datalen = (*env)->GetArrayLength(env, elems);
4207         if (ret->datalen == 0) {
4208                 ret->data = NULL;
4209         } else {
4210                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVecTempl_RouteHop Data");
4211                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4212                 for (size_t i = 0; i < ret->datalen; i++) {
4213                         jlong arr_elem = java_elems[i];
4214                         LDKRouteHop arr_elem_conv;
4215                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4216                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4217                         if (arr_elem_conv.inner != NULL)
4218                                 arr_elem_conv = RouteHop_clone(&arr_elem_conv);
4219                         ret->data[i] = arr_elem_conv;
4220                 }
4221                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4222         }
4223         return (long)ret;
4224 }
4225 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4226         LDKCVecTempl_CVecTempl_RouteHop *vec = (LDKCVecTempl_CVecTempl_RouteHop*)ptr;
4227         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVecTempl_RouteHop));
4228 }
4229 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4230         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
4231 }
4232 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4233         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
4234         CHECK(val->result_ok);
4235         LDKRoute res_var = (*val->contents.result);
4236         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4237         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4238         long res_ref = (long)res_var.inner & ~1;
4239         return res_ref;
4240 }
4241 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4242         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
4243         CHECK(!val->result_ok);
4244         LDKLightningError err_var = (*val->contents.err);
4245         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4246         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4247         long err_ref = (long)err_var.inner & ~1;
4248         return err_ref;
4249 }
4250 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4251         LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr;
4252         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
4253         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
4254         for (size_t i = 0; i < vec->datalen; i++) {
4255                 CHECK((((long)vec->data[i].inner) & 1) == 0);
4256                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
4257         }
4258         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
4259         return ret;
4260 }
4261 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1new(JNIEnv *env, jclass _b, jlongArray elems){
4262         LDKCVecTempl_RouteHint *ret = MALLOC(sizeof(LDKCVecTempl_RouteHint), "LDKCVecTempl_RouteHint");
4263         ret->datalen = (*env)->GetArrayLength(env, elems);
4264         if (ret->datalen == 0) {
4265                 ret->data = NULL;
4266         } else {
4267                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVecTempl_RouteHint Data");
4268                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4269                 for (size_t i = 0; i < ret->datalen; i++) {
4270                         jlong arr_elem = java_elems[i];
4271                         LDKRouteHint arr_elem_conv;
4272                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4273                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4274                         if (arr_elem_conv.inner != NULL)
4275                                 arr_elem_conv = RouteHint_clone(&arr_elem_conv);
4276                         ret->data[i] = arr_elem_conv;
4277                 }
4278                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4279         }
4280         return (long)ret;
4281 }
4282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4283         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arg_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arg;
4284         FREE((void*)arg);
4285         C2Tuple_HTLCOutputInCommitmentSignatureZ_free(arg_conv);
4286 }
4287
4288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4289         LDKC2Tuple_OutPointScriptZ arg_conv = *(LDKC2Tuple_OutPointScriptZ*)arg;
4290         FREE((void*)arg);
4291         C2Tuple_OutPointScriptZ_free(arg_conv);
4292 }
4293
4294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4295         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4296         FREE((void*)arg);
4297         C2Tuple_SignatureCVec_SignatureZZ_free(arg_conv);
4298 }
4299
4300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4301         LDKC2Tuple_TxidCVec_TxOutZZ arg_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arg;
4302         FREE((void*)arg);
4303         C2Tuple_TxidCVec_TxOutZZ_free(arg_conv);
4304 }
4305
4306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4307         LDKC2Tuple_u64u64Z arg_conv = *(LDKC2Tuple_u64u64Z*)arg;
4308         FREE((void*)arg);
4309         C2Tuple_u64u64Z_free(arg_conv);
4310 }
4311
4312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4313         LDKC2Tuple_usizeTransactionZ arg_conv = *(LDKC2Tuple_usizeTransactionZ*)arg;
4314         FREE((void*)arg);
4315         C2Tuple_usizeTransactionZ_free(arg_conv);
4316 }
4317
4318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4319         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arg_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arg;
4320         FREE((void*)arg);
4321         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(arg_conv);
4322 }
4323
4324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4325         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ arg_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
4326         FREE((void*)arg);
4327         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(arg_conv);
4328 }
4329
4330 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4331         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4332         FREE((void*)arg);
4333         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4334         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(arg_conv);
4335         return (long)ret;
4336 }
4337
4338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4339         LDKCResult_CVec_SignatureZNoneZ arg_conv = *(LDKCResult_CVec_SignatureZNoneZ*)arg;
4340         FREE((void*)arg);
4341         CResult_CVec_SignatureZNoneZ_free(arg_conv);
4342 }
4343
4344 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jobjectArray arg) {
4345         LDKCVec_SignatureZ arg_constr;
4346         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4347         if (arg_constr.datalen > 0)
4348                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4349         else
4350                 arg_constr.data = NULL;
4351         for (size_t i = 0; i < arg_constr.datalen; i++) {
4352                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
4353                 LDKSignature arr_conv_8_ref;
4354                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
4355                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
4356                 arg_constr.data[i] = arr_conv_8_ref;
4357         }
4358         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4359         *ret = CResult_CVec_SignatureZNoneZ_ok(arg_constr);
4360         return (long)ret;
4361 }
4362
4363 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4364         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4365         FREE((void*)arg);
4366         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4367         *ret = CResult_CVec_u8ZPeerHandleErrorZ_err(arg_conv);
4368         return (long)ret;
4369 }
4370
4371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4372         LDKCResult_CVec_u8ZPeerHandleErrorZ arg_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4373         FREE((void*)arg);
4374         CResult_CVec_u8ZPeerHandleErrorZ_free(arg_conv);
4375 }
4376
4377 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4378         LDKCVec_u8Z arg_ref;
4379         arg_ref.data = (*_env)->GetByteArrayElements (_env, arg, NULL);
4380         arg_ref.datalen = (*_env)->GetArrayLength (_env, arg);
4381         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4382         *ret = CResult_CVec_u8ZPeerHandleErrorZ_ok(arg_ref);
4383         (*_env)->ReleaseByteArrayElements(_env, arg, (int8_t*)arg_ref.data, 0);
4384         return (long)ret;
4385 }
4386
4387 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4388         LDKAPIError arg_conv = *(LDKAPIError*)arg;
4389         FREE((void*)arg);
4390         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4391         *ret = CResult_NoneAPIErrorZ_err(arg_conv);
4392         return (long)ret;
4393 }
4394
4395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4396         LDKCResult_NoneAPIErrorZ arg_conv = *(LDKCResult_NoneAPIErrorZ*)arg;
4397         FREE((void*)arg);
4398         CResult_NoneAPIErrorZ_free(arg_conv);
4399 }
4400
4401 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4402         LDKChannelMonitorUpdateErr arg_conv = *(LDKChannelMonitorUpdateErr*)arg;
4403         FREE((void*)arg);
4404         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4405         *ret = CResult_NoneChannelMonitorUpdateErrZ_err(arg_conv);
4406         return (long)ret;
4407 }
4408
4409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4410         LDKCResult_NoneChannelMonitorUpdateErrZ arg_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
4411         FREE((void*)arg);
4412         CResult_NoneChannelMonitorUpdateErrZ_free(arg_conv);
4413 }
4414
4415 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4416         LDKMonitorUpdateError arg_conv = *(LDKMonitorUpdateError*)arg;
4417         FREE((void*)arg);
4418         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4419         *ret = CResult_NoneMonitorUpdateErrorZ_err(arg_conv);
4420         return (long)ret;
4421 }
4422
4423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4424         LDKCResult_NoneMonitorUpdateErrorZ arg_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)arg;
4425         FREE((void*)arg);
4426         CResult_NoneMonitorUpdateErrorZ_free(arg_conv);
4427 }
4428
4429 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4430         LDKPaymentSendFailure arg_conv = *(LDKPaymentSendFailure*)arg;
4431         FREE((void*)arg);
4432         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4433         *ret = CResult_NonePaymentSendFailureZ_err(arg_conv);
4434         return (long)ret;
4435 }
4436
4437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4438         LDKCResult_NonePaymentSendFailureZ arg_conv = *(LDKCResult_NonePaymentSendFailureZ*)arg;
4439         FREE((void*)arg);
4440         CResult_NonePaymentSendFailureZ_free(arg_conv);
4441 }
4442
4443 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4444         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4445         FREE((void*)arg);
4446         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4447         *ret = CResult_NonePeerHandleErrorZ_err(arg_conv);
4448         return (long)ret;
4449 }
4450
4451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4452         LDKCResult_NonePeerHandleErrorZ arg_conv = *(LDKCResult_NonePeerHandleErrorZ*)arg;
4453         FREE((void*)arg);
4454         CResult_NonePeerHandleErrorZ_free(arg_conv);
4455 }
4456
4457 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4458         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4459         FREE((void*)arg);
4460         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4461         *ret = CResult_PublicKeySecpErrorZ_err(arg_conv);
4462         return (long)ret;
4463 }
4464
4465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4466         LDKCResult_PublicKeySecpErrorZ arg_conv = *(LDKCResult_PublicKeySecpErrorZ*)arg;
4467         FREE((void*)arg);
4468         CResult_PublicKeySecpErrorZ_free(arg_conv);
4469 }
4470
4471 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4472         LDKPublicKey arg_ref;
4473         CHECK((*_env)->GetArrayLength (_env, arg) == 33);
4474         (*_env)->GetByteArrayRegion (_env, arg, 0, 33, arg_ref.compressed_form);
4475         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4476         *ret = CResult_PublicKeySecpErrorZ_ok(arg_ref);
4477         return (long)ret;
4478 }
4479
4480 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4481         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4482         FREE((void*)arg);
4483         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4484         *ret = CResult_RouteLightningErrorZ_err(arg_conv);
4485         return (long)ret;
4486 }
4487
4488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4489         LDKCResult_RouteLightningErrorZ arg_conv = *(LDKCResult_RouteLightningErrorZ*)arg;
4490         FREE((void*)arg);
4491         CResult_RouteLightningErrorZ_free(arg_conv);
4492 }
4493
4494 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4495         LDKRoute arg_conv = *(LDKRoute*)arg;
4496         FREE((void*)arg);
4497         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4498         *ret = CResult_RouteLightningErrorZ_ok(arg_conv);
4499         return (long)ret;
4500 }
4501
4502 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4503         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4504         FREE((void*)arg);
4505         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4506         *ret = CResult_SecretKeySecpErrorZ_err(arg_conv);
4507         return (long)ret;
4508 }
4509
4510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4511         LDKCResult_SecretKeySecpErrorZ arg_conv = *(LDKCResult_SecretKeySecpErrorZ*)arg;
4512         FREE((void*)arg);
4513         CResult_SecretKeySecpErrorZ_free(arg_conv);
4514 }
4515
4516 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4517         LDKSecretKey arg_ref;
4518         CHECK((*_env)->GetArrayLength (_env, arg) == 32);
4519         (*_env)->GetByteArrayRegion (_env, arg, 0, 32, arg_ref.bytes);
4520         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4521         *ret = CResult_SecretKeySecpErrorZ_ok(arg_ref);
4522         return (long)ret;
4523 }
4524
4525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4526         LDKCResult_SignatureNoneZ arg_conv = *(LDKCResult_SignatureNoneZ*)arg;
4527         FREE((void*)arg);
4528         CResult_SignatureNoneZ_free(arg_conv);
4529 }
4530
4531 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4532         LDKSignature arg_ref;
4533         CHECK((*_env)->GetArrayLength (_env, arg) == 64);
4534         (*_env)->GetByteArrayRegion (_env, arg, 0, 64, arg_ref.compact_form);
4535         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4536         *ret = CResult_SignatureNoneZ_ok(arg_ref);
4537         return (long)ret;
4538 }
4539
4540 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4541         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4542         FREE((void*)arg);
4543         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4544         *ret = CResult_TxCreationKeysSecpErrorZ_err(arg_conv);
4545         return (long)ret;
4546 }
4547
4548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4549         LDKCResult_TxCreationKeysSecpErrorZ arg_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4550         FREE((void*)arg);
4551         CResult_TxCreationKeysSecpErrorZ_free(arg_conv);
4552 }
4553
4554 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4555         LDKTxCreationKeys arg_conv = *(LDKTxCreationKeys*)arg;
4556         FREE((void*)arg);
4557         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4558         *ret = CResult_TxCreationKeysSecpErrorZ_ok(arg_conv);
4559         return (long)ret;
4560 }
4561
4562 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4563         LDKAccessError arg_conv = *(LDKAccessError*)arg;
4564         FREE((void*)arg);
4565         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4566         *ret = CResult_TxOutAccessErrorZ_err(arg_conv);
4567         return (long)ret;
4568 }
4569
4570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4571         LDKCResult_TxOutAccessErrorZ arg_conv = *(LDKCResult_TxOutAccessErrorZ*)arg;
4572         FREE((void*)arg);
4573         CResult_TxOutAccessErrorZ_free(arg_conv);
4574 }
4575
4576 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4577         LDKTxOut arg_conv = *(LDKTxOut*)arg;
4578         FREE((void*)arg);
4579         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4580         *ret = CResult_TxOutAccessErrorZ_ok(arg_conv);
4581         return (long)ret;
4582 }
4583
4584 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4585         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4586         FREE((void*)arg);
4587         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4588         *ret = CResult_boolLightningErrorZ_err(arg_conv);
4589         return (long)ret;
4590 }
4591
4592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4593         LDKCResult_boolLightningErrorZ arg_conv = *(LDKCResult_boolLightningErrorZ*)arg;
4594         FREE((void*)arg);
4595         CResult_boolLightningErrorZ_free(arg_conv);
4596 }
4597
4598 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4599         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4600         *ret = CResult_boolLightningErrorZ_ok(arg);
4601         return (long)ret;
4602 }
4603
4604 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4605         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4606         FREE((void*)arg);
4607         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4608         *ret = CResult_boolPeerHandleErrorZ_err(arg_conv);
4609         return (long)ret;
4610 }
4611
4612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4613         LDKCResult_boolPeerHandleErrorZ arg_conv = *(LDKCResult_boolPeerHandleErrorZ*)arg;
4614         FREE((void*)arg);
4615         CResult_boolPeerHandleErrorZ_free(arg_conv);
4616 }
4617
4618 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4619         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4620         *ret = CResult_boolPeerHandleErrorZ_ok(arg);
4621         return (long)ret;
4622 }
4623
4624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4625         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_constr;
4626         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4627         if (arg_constr.datalen > 0)
4628                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
4629         else
4630                 arg_constr.data = NULL;
4631         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4632         for (size_t q = 0; q < arg_constr.datalen; q++) {
4633                 long arr_conv_42 = arg_vals[q];
4634                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
4635                 FREE((void*)arr_conv_42);
4636                 arg_constr.data[q] = arr_conv_42_conv;
4637         }
4638         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4639         CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_constr);
4640 }
4641
4642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4643         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_constr;
4644         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4645         if (arg_constr.datalen > 0)
4646                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ Elements");
4647         else
4648                 arg_constr.data = NULL;
4649         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4650         for (size_t b = 0; b < arg_constr.datalen; b++) {
4651                 long arr_conv_27 = arg_vals[b];
4652                 LDKC2Tuple_TxidCVec_TxOutZZ arr_conv_27_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arr_conv_27;
4653                 FREE((void*)arr_conv_27);
4654                 arg_constr.data[b] = arr_conv_27_conv;
4655         }
4656         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4657         CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_constr);
4658 }
4659
4660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4661         LDKCVec_C2Tuple_usizeTransactionZZ arg_constr;
4662         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4663         if (arg_constr.datalen > 0)
4664                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
4665         else
4666                 arg_constr.data = NULL;
4667         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4668         for (size_t d = 0; d < arg_constr.datalen; d++) {
4669                 long arr_conv_29 = arg_vals[d];
4670                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
4671                 FREE((void*)arr_conv_29);
4672                 arg_constr.data[d] = arr_conv_29_conv;
4673         }
4674         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4675         CVec_C2Tuple_usizeTransactionZZ_free(arg_constr);
4676 }
4677
4678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4679         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_constr;
4680         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4681         if (arg_constr.datalen > 0)
4682                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
4683         else
4684                 arg_constr.data = NULL;
4685         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4686         for (size_t l = 0; l < arg_constr.datalen; l++) {
4687                 long arr_conv_63 = arg_vals[l];
4688                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
4689                 FREE((void*)arr_conv_63);
4690                 arg_constr.data[l] = arr_conv_63_conv;
4691         }
4692         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4693         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_constr);
4694 }
4695
4696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
4697         LDKCVec_CVec_RouteHopZZ arg_constr;
4698         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4699         if (arg_constr.datalen > 0)
4700                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
4701         else
4702                 arg_constr.data = NULL;
4703         for (size_t m = 0; m < arg_constr.datalen; m++) {
4704                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, arg, m);
4705                 LDKCVec_RouteHopZ arr_conv_12_constr;
4706                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
4707                 if (arr_conv_12_constr.datalen > 0)
4708                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
4709                 else
4710                         arr_conv_12_constr.data = NULL;
4711                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
4712                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
4713                         long arr_conv_10 = arr_conv_12_vals[k];
4714                         LDKRouteHop arr_conv_10_conv;
4715                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
4716                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
4717                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
4718                 }
4719                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
4720                 arg_constr.data[m] = arr_conv_12_constr;
4721         }
4722         CVec_CVec_RouteHopZZ_free(arg_constr);
4723 }
4724
4725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4726         LDKCVec_ChannelDetailsZ arg_constr;
4727         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4728         if (arg_constr.datalen > 0)
4729                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
4730         else
4731                 arg_constr.data = NULL;
4732         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4733         for (size_t q = 0; q < arg_constr.datalen; q++) {
4734                 long arr_conv_16 = arg_vals[q];
4735                 LDKChannelDetails arr_conv_16_conv;
4736                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4737                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4738                 arg_constr.data[q] = arr_conv_16_conv;
4739         }
4740         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4741         CVec_ChannelDetailsZ_free(arg_constr);
4742 }
4743
4744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4745         LDKCVec_ChannelMonitorZ arg_constr;
4746         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4747         if (arg_constr.datalen > 0)
4748                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
4749         else
4750                 arg_constr.data = NULL;
4751         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4752         for (size_t q = 0; q < arg_constr.datalen; q++) {
4753                 long arr_conv_16 = arg_vals[q];
4754                 LDKChannelMonitor arr_conv_16_conv;
4755                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4756                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4757                 arg_constr.data[q] = arr_conv_16_conv;
4758         }
4759         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4760         CVec_ChannelMonitorZ_free(arg_constr);
4761 }
4762
4763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4764         LDKCVec_EventZ arg_constr;
4765         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4766         if (arg_constr.datalen > 0)
4767                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4768         else
4769                 arg_constr.data = NULL;
4770         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4771         for (size_t h = 0; h < arg_constr.datalen; h++) {
4772                 long arr_conv_7 = arg_vals[h];
4773                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
4774                 FREE((void*)arr_conv_7);
4775                 arg_constr.data[h] = arr_conv_7_conv;
4776         }
4777         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4778         CVec_EventZ_free(arg_constr);
4779 }
4780
4781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4782         LDKCVec_HTLCOutputInCommitmentZ arg_constr;
4783         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4784         if (arg_constr.datalen > 0)
4785                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
4786         else
4787                 arg_constr.data = NULL;
4788         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4789         for (size_t y = 0; y < arg_constr.datalen; y++) {
4790                 long arr_conv_24 = arg_vals[y];
4791                 LDKHTLCOutputInCommitment arr_conv_24_conv;
4792                 arr_conv_24_conv.inner = (void*)(arr_conv_24 & (~1));
4793                 arr_conv_24_conv.is_owned = (arr_conv_24 & 1) || (arr_conv_24 == 0);
4794                 arg_constr.data[y] = arr_conv_24_conv;
4795         }
4796         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4797         CVec_HTLCOutputInCommitmentZ_free(arg_constr);
4798 }
4799
4800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4801         LDKCVec_MessageSendEventZ arg_constr;
4802         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4803         if (arg_constr.datalen > 0)
4804                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4805         else
4806                 arg_constr.data = NULL;
4807         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4808         for (size_t s = 0; s < arg_constr.datalen; s++) {
4809                 long arr_conv_18 = arg_vals[s];
4810                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
4811                 FREE((void*)arr_conv_18);
4812                 arg_constr.data[s] = arr_conv_18_conv;
4813         }
4814         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4815         CVec_MessageSendEventZ_free(arg_constr);
4816 }
4817
4818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4819         LDKCVec_MonitorEventZ arg_constr;
4820         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4821         if (arg_constr.datalen > 0)
4822                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4823         else
4824                 arg_constr.data = NULL;
4825         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4826         for (size_t o = 0; o < arg_constr.datalen; o++) {
4827                 long arr_conv_14 = arg_vals[o];
4828                 LDKMonitorEvent arr_conv_14_conv;
4829                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
4830                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
4831                 arg_constr.data[o] = arr_conv_14_conv;
4832         }
4833         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4834         CVec_MonitorEventZ_free(arg_constr);
4835 }
4836
4837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4838         LDKCVec_NetAddressZ arg_constr;
4839         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4840         if (arg_constr.datalen > 0)
4841                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
4842         else
4843                 arg_constr.data = NULL;
4844         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4845         for (size_t m = 0; m < arg_constr.datalen; m++) {
4846                 long arr_conv_12 = arg_vals[m];
4847                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
4848                 FREE((void*)arr_conv_12);
4849                 arg_constr.data[m] = arr_conv_12_conv;
4850         }
4851         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4852         CVec_NetAddressZ_free(arg_constr);
4853 }
4854
4855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4856         LDKCVec_NodeAnnouncementZ arg_constr;
4857         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4858         if (arg_constr.datalen > 0)
4859                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
4860         else
4861                 arg_constr.data = NULL;
4862         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4863         for (size_t s = 0; s < arg_constr.datalen; s++) {
4864                 long arr_conv_18 = arg_vals[s];
4865                 LDKNodeAnnouncement arr_conv_18_conv;
4866                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
4867                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
4868                 arg_constr.data[s] = arr_conv_18_conv;
4869         }
4870         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4871         CVec_NodeAnnouncementZ_free(arg_constr);
4872 }
4873
4874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
4875         LDKCVec_PublicKeyZ arg_constr;
4876         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4877         if (arg_constr.datalen > 0)
4878                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
4879         else
4880                 arg_constr.data = NULL;
4881         for (size_t i = 0; i < arg_constr.datalen; i++) {
4882                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
4883                 LDKPublicKey arr_conv_8_ref;
4884                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 33);
4885                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 33, arr_conv_8_ref.compressed_form);
4886                 arg_constr.data[i] = arr_conv_8_ref;
4887         }
4888         CVec_PublicKeyZ_free(arg_constr);
4889 }
4890
4891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4892         LDKCVec_RouteHintZ arg_constr;
4893         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4894         if (arg_constr.datalen > 0)
4895                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
4896         else
4897                 arg_constr.data = NULL;
4898         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4899         for (size_t l = 0; l < arg_constr.datalen; l++) {
4900                 long arr_conv_11 = arg_vals[l];
4901                 LDKRouteHint arr_conv_11_conv;
4902                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
4903                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
4904                 arg_constr.data[l] = arr_conv_11_conv;
4905         }
4906         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4907         CVec_RouteHintZ_free(arg_constr);
4908 }
4909
4910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4911         LDKCVec_RouteHopZ arg_constr;
4912         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4913         if (arg_constr.datalen > 0)
4914                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
4915         else
4916                 arg_constr.data = NULL;
4917         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4918         for (size_t k = 0; k < arg_constr.datalen; k++) {
4919                 long arr_conv_10 = arg_vals[k];
4920                 LDKRouteHop arr_conv_10_conv;
4921                 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
4922                 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
4923                 arg_constr.data[k] = arr_conv_10_conv;
4924         }
4925         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4926         CVec_RouteHopZ_free(arg_constr);
4927 }
4928
4929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
4930         LDKCVec_SignatureZ arg_constr;
4931         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4932         if (arg_constr.datalen > 0)
4933                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4934         else
4935                 arg_constr.data = NULL;
4936         for (size_t i = 0; i < arg_constr.datalen; i++) {
4937                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
4938                 LDKSignature arr_conv_8_ref;
4939                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
4940                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
4941                 arg_constr.data[i] = arr_conv_8_ref;
4942         }
4943         CVec_SignatureZ_free(arg_constr);
4944 }
4945
4946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4947         LDKCVec_SpendableOutputDescriptorZ arg_constr;
4948         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4949         if (arg_constr.datalen > 0)
4950                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
4951         else
4952                 arg_constr.data = NULL;
4953         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4954         for (size_t b = 0; b < arg_constr.datalen; b++) {
4955                 long arr_conv_27 = arg_vals[b];
4956                 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)arr_conv_27;
4957                 FREE((void*)arr_conv_27);
4958                 arg_constr.data[b] = arr_conv_27_conv;
4959         }
4960         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4961         CVec_SpendableOutputDescriptorZ_free(arg_constr);
4962 }
4963
4964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4965         LDKCVec_TransactionZ arg_constr;
4966         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4967         if (arg_constr.datalen > 0)
4968                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
4969         else
4970                 arg_constr.data = NULL;
4971         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4972         for (size_t n = 0; n < arg_constr.datalen; n++) {
4973                 long arr_conv_13 = arg_vals[n];
4974                 LDKTransaction arr_conv_13_conv = *(LDKTransaction*)arr_conv_13;
4975                 arg_constr.data[n] = arr_conv_13_conv;
4976         }
4977         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4978         CVec_TransactionZ_free(arg_constr);
4979 }
4980
4981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4982         LDKCVec_TxOutZ arg_constr;
4983         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4984         if (arg_constr.datalen > 0)
4985                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
4986         else
4987                 arg_constr.data = NULL;
4988         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4989         for (size_t h = 0; h < arg_constr.datalen; h++) {
4990                 long arr_conv_7 = arg_vals[h];
4991                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
4992                 FREE((void*)arr_conv_7);
4993                 arg_constr.data[h] = arr_conv_7_conv;
4994         }
4995         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4996         CVec_TxOutZ_free(arg_constr);
4997 }
4998
4999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5000         LDKCVec_UpdateAddHTLCZ arg_constr;
5001         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5002         if (arg_constr.datalen > 0)
5003                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
5004         else
5005                 arg_constr.data = NULL;
5006         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5007         for (size_t p = 0; p < arg_constr.datalen; p++) {
5008                 long arr_conv_15 = arg_vals[p];
5009                 LDKUpdateAddHTLC arr_conv_15_conv;
5010                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
5011                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
5012                 arg_constr.data[p] = arr_conv_15_conv;
5013         }
5014         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5015         CVec_UpdateAddHTLCZ_free(arg_constr);
5016 }
5017
5018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5019         LDKCVec_UpdateFailHTLCZ arg_constr;
5020         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5021         if (arg_constr.datalen > 0)
5022                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
5023         else
5024                 arg_constr.data = NULL;
5025         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5026         for (size_t q = 0; q < arg_constr.datalen; q++) {
5027                 long arr_conv_16 = arg_vals[q];
5028                 LDKUpdateFailHTLC arr_conv_16_conv;
5029                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5030                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5031                 arg_constr.data[q] = arr_conv_16_conv;
5032         }
5033         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5034         CVec_UpdateFailHTLCZ_free(arg_constr);
5035 }
5036
5037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5038         LDKCVec_UpdateFailMalformedHTLCZ arg_constr;
5039         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5040         if (arg_constr.datalen > 0)
5041                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
5042         else
5043                 arg_constr.data = NULL;
5044         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5045         for (size_t z = 0; z < arg_constr.datalen; z++) {
5046                 long arr_conv_25 = arg_vals[z];
5047                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
5048                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
5049                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
5050                 arg_constr.data[z] = arr_conv_25_conv;
5051         }
5052         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5053         CVec_UpdateFailMalformedHTLCZ_free(arg_constr);
5054 }
5055
5056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5057         LDKCVec_UpdateFulfillHTLCZ arg_constr;
5058         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5059         if (arg_constr.datalen > 0)
5060                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
5061         else
5062                 arg_constr.data = NULL;
5063         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5064         for (size_t t = 0; t < arg_constr.datalen; t++) {
5065                 long arr_conv_19 = arg_vals[t];
5066                 LDKUpdateFulfillHTLC arr_conv_19_conv;
5067                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
5068                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
5069                 arg_constr.data[t] = arr_conv_19_conv;
5070         }
5071         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5072         CVec_UpdateFulfillHTLCZ_free(arg_constr);
5073 }
5074
5075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5076         LDKCVec_u64Z arg_constr;
5077         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5078         if (arg_constr.datalen > 0)
5079                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
5080         else
5081                 arg_constr.data = NULL;
5082         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5083         for (size_t g = 0; g < arg_constr.datalen; g++) {
5084                 long arr_conv_6 = arg_vals[g];
5085                 arg_constr.data[g] = arr_conv_6;
5086         }
5087         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5088         CVec_u64Z_free(arg_constr);
5089 }
5090
5091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv * _env, jclass _b, jbyteArray arg) {
5092         LDKCVec_u8Z arg_ref;
5093         arg_ref.data = (*_env)->GetByteArrayElements (_env, arg, NULL);
5094         arg_ref.datalen = (*_env)->GetArrayLength (_env, arg);
5095         CVec_u8Z_free(arg_ref);
5096         (*_env)->ReleaseByteArrayElements(_env, arg, (int8_t*)arg_ref.data, 0);
5097 }
5098
5099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv * _env, jclass _b, jlong _res) {
5100         LDKTransaction _res_conv = *(LDKTransaction*)_res;
5101         Transaction_free(_res_conv);
5102 }
5103
5104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv * _env, jclass _b, jlong _res) {
5105         LDKTxOut _res_conv = *(LDKTxOut*)_res;
5106         FREE((void*)_res);
5107         TxOut_free(_res_conv);
5108 }
5109
5110 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
5111         LDKTransaction b_conv = *(LDKTransaction*)b;
5112         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5113         *ret = C2Tuple_usizeTransactionZ_new(a, b_conv);
5114         return (long)ret;
5115 }
5116
5117 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv * _env, jclass _b) {
5118         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5119         *ret = CResult_NoneChannelMonitorUpdateErrZ_ok();
5120         return (long)ret;
5121 }
5122
5123 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv * _env, jclass _b) {
5124         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
5125         *ret = CResult_NoneMonitorUpdateErrorZ_ok();
5126         return (long)ret;
5127 }
5128
5129 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv * _env, jclass _b, jlong a, jbyteArray b) {
5130         LDKOutPoint a_conv;
5131         a_conv.inner = (void*)(a & (~1));
5132         a_conv.is_owned = (a & 1) || (a == 0);
5133         if (a_conv.inner != NULL)
5134                 a_conv = OutPoint_clone(&a_conv);
5135         LDKCVec_u8Z b_ref;
5136         b_ref.data = (*_env)->GetByteArrayElements (_env, b, NULL);
5137         b_ref.datalen = (*_env)->GetArrayLength (_env, b);
5138         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5139         *ret = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
5140         (*_env)->ReleaseByteArrayElements(_env, b, (int8_t*)b_ref.data, 0);
5141         return (long)ret;
5142 }
5143
5144 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlongArray b) {
5145         LDKThirtyTwoBytes a_ref;
5146         CHECK((*_env)->GetArrayLength (_env, a) == 32);
5147         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
5148         LDKCVec_TxOutZ b_constr;
5149         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
5150         if (b_constr.datalen > 0)
5151                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
5152         else
5153                 b_constr.data = NULL;
5154         long* b_vals = (*_env)->GetLongArrayElements (_env, b, NULL);
5155         for (size_t h = 0; h < b_constr.datalen; h++) {
5156                 long arr_conv_7 = b_vals[h];
5157                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
5158                 FREE((void*)arr_conv_7);
5159                 b_constr.data[h] = arr_conv_7_conv;
5160         }
5161         (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0);
5162         LDKC2Tuple_TxidCVec_TxOutZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKC2Tuple_TxidCVec_TxOutZZ");
5163         *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_constr);
5164         return (long)ret;
5165 }
5166
5167 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
5168         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
5169         *ret = C2Tuple_u64u64Z_new(a, b);
5170         return (long)ret;
5171 }
5172
5173 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jobjectArray b) {
5174         LDKSignature a_ref;
5175         CHECK((*_env)->GetArrayLength (_env, a) == 64);
5176         (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form);
5177         LDKCVec_SignatureZ b_constr;
5178         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
5179         if (b_constr.datalen > 0)
5180                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5181         else
5182                 b_constr.data = NULL;
5183         for (size_t i = 0; i < b_constr.datalen; i++) {
5184                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, b, i);
5185                 LDKSignature arr_conv_8_ref;
5186                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
5187                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
5188                 b_constr.data[i] = arr_conv_8_ref;
5189         }
5190         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5191         *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
5192         return (long)ret;
5193 }
5194
5195 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv * _env, jclass _b) {
5196         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5197         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
5198         return (long)ret;
5199 }
5200
5201 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv * _env, jclass _b) {
5202         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5203         *ret = CResult_SignatureNoneZ_err();
5204         return (long)ret;
5205 }
5206
5207 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv * _env, jclass _b) {
5208         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5209         *ret = CResult_CVec_SignatureZNoneZ_err();
5210         return (long)ret;
5211 }
5212
5213 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv * _env, jclass _b) {
5214         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5215         *ret = CResult_NoneAPIErrorZ_ok();
5216         return (long)ret;
5217 }
5218
5219 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv * _env, jclass _b) {
5220         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5221         *ret = CResult_NonePaymentSendFailureZ_ok();
5222         return (long)ret;
5223 }
5224
5225 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b, jlong c) {
5226         LDKChannelAnnouncement a_conv;
5227         a_conv.inner = (void*)(a & (~1));
5228         a_conv.is_owned = (a & 1) || (a == 0);
5229         if (a_conv.inner != NULL)
5230                 a_conv = ChannelAnnouncement_clone(&a_conv);
5231         LDKChannelUpdate b_conv;
5232         b_conv.inner = (void*)(b & (~1));
5233         b_conv.is_owned = (b & 1) || (b == 0);
5234         if (b_conv.inner != NULL)
5235                 b_conv = ChannelUpdate_clone(&b_conv);
5236         LDKChannelUpdate c_conv;
5237         c_conv.inner = (void*)(c & (~1));
5238         c_conv.is_owned = (c & 1) || (c == 0);
5239         if (c_conv.inner != NULL)
5240                 c_conv = ChannelUpdate_clone(&c_conv);
5241         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5242         *ret = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5243         return (long)ret;
5244 }
5245
5246 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b) {
5247         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5248         *ret = CResult_NonePeerHandleErrorZ_ok();
5249         return (long)ret;
5250 }
5251
5252 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1new(JNIEnv * _env, jclass _b, jlong a, jbyteArray b) {
5253         LDKHTLCOutputInCommitment a_conv;
5254         a_conv.inner = (void*)(a & (~1));
5255         a_conv.is_owned = (a & 1) || (a == 0);
5256         if (a_conv.inner != NULL)
5257                 a_conv = HTLCOutputInCommitment_clone(&a_conv);
5258         LDKSignature b_ref;
5259         CHECK((*_env)->GetArrayLength (_env, b) == 64);
5260         (*_env)->GetByteArrayRegion (_env, b, 0, 64, b_ref.compact_form);
5261         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* ret = MALLOC(sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKC2Tuple_HTLCOutputInCommitmentSignatureZ");
5262         *ret = C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a_conv, b_ref);
5263         return (long)ret;
5264 }
5265
5266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5267         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
5268         FREE((void*)this_ptr);
5269         Event_free(this_ptr_conv);
5270 }
5271
5272 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5273         LDKEvent* orig_conv = (LDKEvent*)orig;
5274         LDKEvent* ret = MALLOC(sizeof(LDKEvent), "LDKEvent");
5275         *ret = Event_clone(orig_conv);
5276         return (long)ret;
5277 }
5278
5279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5280         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
5281         FREE((void*)this_ptr);
5282         MessageSendEvent_free(this_ptr_conv);
5283 }
5284
5285 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5286         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
5287         LDKMessageSendEvent* ret = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5288         *ret = MessageSendEvent_clone(orig_conv);
5289         return (long)ret;
5290 }
5291
5292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5293         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
5294         FREE((void*)this_ptr);
5295         MessageSendEventsProvider_free(this_ptr_conv);
5296 }
5297
5298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5299         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
5300         FREE((void*)this_ptr);
5301         EventsProvider_free(this_ptr_conv);
5302 }
5303
5304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5305         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
5306         FREE((void*)this_ptr);
5307         APIError_free(this_ptr_conv);
5308 }
5309
5310 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5311         LDKAPIError* orig_conv = (LDKAPIError*)orig;
5312         LDKAPIError* ret = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5313         *ret = APIError_clone(orig_conv);
5314         return (long)ret;
5315 }
5316
5317 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5318         LDKLevel* orig_conv = (LDKLevel*)orig;
5319         jclass ret = LDKLevel_to_java(_env, Level_clone(orig_conv));
5320         return ret;
5321 }
5322
5323 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv * _env, jclass _b) {
5324         jclass ret = LDKLevel_to_java(_env, Level_max());
5325         return ret;
5326 }
5327
5328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5329         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
5330         FREE((void*)this_ptr);
5331         Logger_free(this_ptr_conv);
5332 }
5333
5334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5335         LDKChannelHandshakeConfig this_ptr_conv;
5336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5337         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5338         ChannelHandshakeConfig_free(this_ptr_conv);
5339 }
5340
5341 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5342         LDKChannelHandshakeConfig orig_conv;
5343         orig_conv.inner = (void*)(orig & (~1));
5344         orig_conv.is_owned = (orig & 1) || (orig == 0);
5345         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_clone(&orig_conv);
5346         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5347 }
5348
5349 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
5350         LDKChannelHandshakeConfig this_ptr_conv;
5351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5352         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5353         jint ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
5354         return ret_val;
5355 }
5356
5357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5358         LDKChannelHandshakeConfig this_ptr_conv;
5359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5360         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5361         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
5362 }
5363
5364 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
5365         LDKChannelHandshakeConfig this_ptr_conv;
5366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5367         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5368         jshort ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
5369         return ret_val;
5370 }
5371
5372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5373         LDKChannelHandshakeConfig this_ptr_conv;
5374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5375         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5376         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
5377 }
5378
5379 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5380         LDKChannelHandshakeConfig this_ptr_conv;
5381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5382         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5383         jlong ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
5384         return ret_val;
5385 }
5386
5387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5388         LDKChannelHandshakeConfig this_ptr_conv;
5389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5390         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5391         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
5392 }
5393
5394 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv * _env, jclass _b, jint minimum_depth_arg, jshort our_to_self_delay_arg, jlong our_htlc_minimum_msat_arg) {
5395         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
5396         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5397 }
5398
5399 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv * _env, jclass _b) {
5400         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_default();
5401         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5402 }
5403
5404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5405         LDKChannelHandshakeLimits this_ptr_conv;
5406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5407         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5408         ChannelHandshakeLimits_free(this_ptr_conv);
5409 }
5410
5411 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5412         LDKChannelHandshakeLimits orig_conv;
5413         orig_conv.inner = (void*)(orig & (~1));
5414         orig_conv.is_owned = (orig & 1) || (orig == 0);
5415         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_clone(&orig_conv);
5416         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5417 }
5418
5419 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5420         LDKChannelHandshakeLimits this_ptr_conv;
5421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5422         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5423         jlong ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
5424         return ret_val;
5425 }
5426
5427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5428         LDKChannelHandshakeLimits this_ptr_conv;
5429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5430         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5431         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
5432 }
5433
5434 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5435         LDKChannelHandshakeLimits this_ptr_conv;
5436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5437         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5438         jlong ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
5439         return ret_val;
5440 }
5441
5442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5443         LDKChannelHandshakeLimits this_ptr_conv;
5444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5445         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5446         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
5447 }
5448
5449 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5450         LDKChannelHandshakeLimits this_ptr_conv;
5451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5452         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5453         jlong ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
5454         return ret_val;
5455 }
5456
5457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5458         LDKChannelHandshakeLimits this_ptr_conv;
5459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5460         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5461         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
5462 }
5463
5464 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5465         LDKChannelHandshakeLimits this_ptr_conv;
5466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5467         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5468         jlong ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
5469         return ret_val;
5470 }
5471
5472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5473         LDKChannelHandshakeLimits this_ptr_conv;
5474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5475         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5476         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
5477 }
5478
5479 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
5480         LDKChannelHandshakeLimits this_ptr_conv;
5481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5482         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5483         jshort ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
5484         return ret_val;
5485 }
5486
5487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5488         LDKChannelHandshakeLimits this_ptr_conv;
5489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5490         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5491         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
5492 }
5493
5494 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5495         LDKChannelHandshakeLimits this_ptr_conv;
5496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5497         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5498         jlong ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
5499         return ret_val;
5500 }
5501
5502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5503         LDKChannelHandshakeLimits this_ptr_conv;
5504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5505         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5506         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
5507 }
5508
5509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5510         LDKChannelHandshakeLimits this_ptr_conv;
5511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5512         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5513         jlong ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
5514         return ret_val;
5515 }
5516
5517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5518         LDKChannelHandshakeLimits this_ptr_conv;
5519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5520         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5521         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
5522 }
5523
5524 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
5525         LDKChannelHandshakeLimits this_ptr_conv;
5526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5527         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5528         jint ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
5529         return ret_val;
5530 }
5531
5532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5533         LDKChannelHandshakeLimits this_ptr_conv;
5534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5535         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5536         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
5537 }
5538
5539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr) {
5540         LDKChannelHandshakeLimits this_ptr_conv;
5541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5542         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5543         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
5544         return ret_val;
5545 }
5546
5547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5548         LDKChannelHandshakeLimits this_ptr_conv;
5549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5550         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5551         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
5552 }
5553
5554 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
5555         LDKChannelHandshakeLimits this_ptr_conv;
5556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5557         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5558         jshort ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
5559         return ret_val;
5560 }
5561
5562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5563         LDKChannelHandshakeLimits this_ptr_conv;
5564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5565         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5566         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
5567 }
5568
5569 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv * _env, jclass _b, jlong min_funding_satoshis_arg, jlong max_htlc_minimum_msat_arg, jlong min_max_htlc_value_in_flight_msat_arg, jlong max_channel_reserve_satoshis_arg, jshort min_max_accepted_htlcs_arg, jlong min_dust_limit_satoshis_arg, jlong max_dust_limit_satoshis_arg, jint max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, jshort their_to_self_delay_arg) {
5570         LDKChannelHandshakeLimits ret = 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);
5571         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5572 }
5573
5574 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv * _env, jclass _b) {
5575         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_default();
5576         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5577 }
5578
5579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5580         LDKChannelConfig this_ptr_conv;
5581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5582         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5583         ChannelConfig_free(this_ptr_conv);
5584 }
5585
5586 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5587         LDKChannelConfig orig_conv;
5588         orig_conv.inner = (void*)(orig & (~1));
5589         orig_conv.is_owned = (orig & 1) || (orig == 0);
5590         LDKChannelConfig ret = ChannelConfig_clone(&orig_conv);
5591         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5592 }
5593
5594 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
5595         LDKChannelConfig this_ptr_conv;
5596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5597         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5598         jint ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
5599         return ret_val;
5600 }
5601
5602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5603         LDKChannelConfig this_ptr_conv;
5604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5605         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5606         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
5607 }
5608
5609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr) {
5610         LDKChannelConfig this_ptr_conv;
5611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5612         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5613         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
5614         return ret_val;
5615 }
5616
5617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5618         LDKChannelConfig this_ptr_conv;
5619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5620         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5621         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
5622 }
5623
5624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
5625         LDKChannelConfig this_ptr_conv;
5626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5627         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5628         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
5629         return ret_val;
5630 }
5631
5632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5633         LDKChannelConfig this_ptr_conv;
5634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5635         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5636         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
5637 }
5638
5639 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv * _env, jclass _b, jint fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
5640         LDKChannelConfig ret = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
5641         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5642 }
5643
5644 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv * _env, jclass _b) {
5645         LDKChannelConfig ret = ChannelConfig_default();
5646         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5647 }
5648
5649 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv * _env, jclass _b, jlong obj) {
5650         LDKChannelConfig obj_conv;
5651         obj_conv.inner = (void*)(obj & (~1));
5652         obj_conv.is_owned = (obj & 1) || (obj == 0);
5653         LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
5654         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
5655         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
5656         CVec_u8Z_free(arg_var);
5657         return arg_arr;
5658 }
5659
5660 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
5661         LDKu8slice ser_ref;
5662         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
5663         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
5664         LDKChannelConfig ret = ChannelConfig_read(ser_ref);
5665         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
5666         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5667 }
5668
5669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5670         LDKUserConfig this_ptr_conv;
5671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5672         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5673         UserConfig_free(this_ptr_conv);
5674 }
5675
5676 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5677         LDKUserConfig orig_conv;
5678         orig_conv.inner = (void*)(orig & (~1));
5679         orig_conv.is_owned = (orig & 1) || (orig == 0);
5680         LDKUserConfig ret = UserConfig_clone(&orig_conv);
5681         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5682 }
5683
5684 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
5685         LDKUserConfig this_ptr_conv;
5686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5687         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5688         LDKChannelHandshakeConfig ret = UserConfig_get_own_channel_config(&this_ptr_conv);
5689         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5690 }
5691
5692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5693         LDKUserConfig this_ptr_conv;
5694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5695         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5696         LDKChannelHandshakeConfig val_conv;
5697         val_conv.inner = (void*)(val & (~1));
5698         val_conv.is_owned = (val & 1) || (val == 0);
5699         if (val_conv.inner != NULL)
5700                 val_conv = ChannelHandshakeConfig_clone(&val_conv);
5701         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
5702 }
5703
5704 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr) {
5705         LDKUserConfig this_ptr_conv;
5706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5707         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5708         LDKChannelHandshakeLimits ret = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
5709         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5710 }
5711
5712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5713         LDKUserConfig this_ptr_conv;
5714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5715         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5716         LDKChannelHandshakeLimits val_conv;
5717         val_conv.inner = (void*)(val & (~1));
5718         val_conv.is_owned = (val & 1) || (val == 0);
5719         if (val_conv.inner != NULL)
5720                 val_conv = ChannelHandshakeLimits_clone(&val_conv);
5721         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
5722 }
5723
5724 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr) {
5725         LDKUserConfig this_ptr_conv;
5726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5727         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5728         LDKChannelConfig ret = UserConfig_get_channel_options(&this_ptr_conv);
5729         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5730 }
5731
5732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5733         LDKUserConfig this_ptr_conv;
5734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5735         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5736         LDKChannelConfig val_conv;
5737         val_conv.inner = (void*)(val & (~1));
5738         val_conv.is_owned = (val & 1) || (val == 0);
5739         if (val_conv.inner != NULL)
5740                 val_conv = ChannelConfig_clone(&val_conv);
5741         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
5742 }
5743
5744 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv * _env, jclass _b, jlong own_channel_config_arg, jlong peer_channel_config_limits_arg, jlong channel_options_arg) {
5745         LDKChannelHandshakeConfig own_channel_config_arg_conv;
5746         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
5747         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
5748         if (own_channel_config_arg_conv.inner != NULL)
5749                 own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
5750         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
5751         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
5752         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
5753         if (peer_channel_config_limits_arg_conv.inner != NULL)
5754                 peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
5755         LDKChannelConfig channel_options_arg_conv;
5756         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
5757         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
5758         if (channel_options_arg_conv.inner != NULL)
5759                 channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
5760         LDKUserConfig ret = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
5761         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5762 }
5763
5764 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv * _env, jclass _b) {
5765         LDKUserConfig ret = UserConfig_default();
5766         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5767 }
5768
5769 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5770         LDKAccessError* orig_conv = (LDKAccessError*)orig;
5771         jclass ret = LDKAccessError_to_java(_env, AccessError_clone(orig_conv));
5772         return ret;
5773 }
5774
5775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5776         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
5777         FREE((void*)this_ptr);
5778         Access_free(this_ptr_conv);
5779 }
5780
5781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5782         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
5783         FREE((void*)this_ptr);
5784         Watch_free(this_ptr_conv);
5785 }
5786
5787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5788         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
5789         FREE((void*)this_ptr);
5790         Filter_free(this_ptr_conv);
5791 }
5792
5793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5794         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
5795         FREE((void*)this_ptr);
5796         BroadcasterInterface_free(this_ptr_conv);
5797 }
5798
5799 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5800         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)orig;
5801         jclass ret = LDKConfirmationTarget_to_java(_env, ConfirmationTarget_clone(orig_conv));
5802         return ret;
5803 }
5804
5805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5806         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
5807         FREE((void*)this_ptr);
5808         FeeEstimator_free(this_ptr_conv);
5809 }
5810
5811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5812         LDKChainMonitor this_ptr_conv;
5813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5814         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5815         ChainMonitor_free(this_ptr_conv);
5816 }
5817
5818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height) {
5819         LDKChainMonitor this_arg_conv;
5820         this_arg_conv.inner = (void*)(this_arg & (~1));
5821         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5822         unsigned char header_arr[80];
5823         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5824         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5825         unsigned char (*header_ref)[80] = &header_arr;
5826         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5827         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
5828         if (txdata_constr.datalen > 0)
5829                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5830         else
5831                 txdata_constr.data = NULL;
5832         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
5833         for (size_t d = 0; d < txdata_constr.datalen; d++) {
5834                 long arr_conv_29 = txdata_vals[d];
5835                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
5836                 FREE((void*)arr_conv_29);
5837                 txdata_constr.data[d] = arr_conv_29_conv;
5838         }
5839         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
5840         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
5841 }
5842
5843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint disconnected_height) {
5844         LDKChainMonitor this_arg_conv;
5845         this_arg_conv.inner = (void*)(this_arg & (~1));
5846         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5847         unsigned char header_arr[80];
5848         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5849         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5850         unsigned char (*header_ref)[80] = &header_arr;
5851         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
5852 }
5853
5854 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv * _env, jclass _b, jlong chain_source, jlong broadcaster, jlong logger, jlong feeest) {
5855         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
5856         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5857         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5858                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5859                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5860         }
5861         LDKLogger logger_conv = *(LDKLogger*)logger;
5862         if (logger_conv.free == LDKLogger_JCalls_free) {
5863                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5864                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5865         }
5866         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
5867         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
5868                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5869                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
5870         }
5871         LDKChainMonitor ret = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv);
5872         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5873 }
5874
5875 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv * _env, jclass _b, jlong this_arg) {
5876         LDKChainMonitor this_arg_conv;
5877         this_arg_conv.inner = (void*)(this_arg & (~1));
5878         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5879         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
5880         *ret = ChainMonitor_as_Watch(&this_arg_conv);
5881         return (long)ret;
5882 }
5883
5884 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5885         LDKChainMonitor this_arg_conv;
5886         this_arg_conv.inner = (void*)(this_arg & (~1));
5887         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5888         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5889         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
5890         return (long)ret;
5891 }
5892
5893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5894         LDKChannelMonitorUpdate this_ptr_conv;
5895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5896         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5897         ChannelMonitorUpdate_free(this_ptr_conv);
5898 }
5899
5900 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5901         LDKChannelMonitorUpdate orig_conv;
5902         orig_conv.inner = (void*)(orig & (~1));
5903         orig_conv.is_owned = (orig & 1) || (orig == 0);
5904         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_clone(&orig_conv);
5905         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5906 }
5907
5908 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5909         LDKChannelMonitorUpdate this_ptr_conv;
5910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5911         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5912         jlong ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
5913         return ret_val;
5914 }
5915
5916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5917         LDKChannelMonitorUpdate this_ptr_conv;
5918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5919         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5920         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
5921 }
5922
5923 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5924         LDKChannelMonitorUpdate obj_conv;
5925         obj_conv.inner = (void*)(obj & (~1));
5926         obj_conv.is_owned = (obj & 1) || (obj == 0);
5927         LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
5928         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
5929         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
5930         CVec_u8Z_free(arg_var);
5931         return arg_arr;
5932 }
5933
5934 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
5935         LDKu8slice ser_ref;
5936         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
5937         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
5938         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_read(ser_ref);
5939         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
5940         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5941 }
5942
5943 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5944         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)orig;
5945         jclass ret = LDKChannelMonitorUpdateErr_to_java(_env, ChannelMonitorUpdateErr_clone(orig_conv));
5946         return ret;
5947 }
5948
5949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5950         LDKMonitorUpdateError this_ptr_conv;
5951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5952         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5953         MonitorUpdateError_free(this_ptr_conv);
5954 }
5955
5956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5957         LDKMonitorEvent this_ptr_conv;
5958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5959         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5960         MonitorEvent_free(this_ptr_conv);
5961 }
5962
5963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5964         LDKHTLCUpdate this_ptr_conv;
5965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5966         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5967         HTLCUpdate_free(this_ptr_conv);
5968 }
5969
5970 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5971         LDKHTLCUpdate orig_conv;
5972         orig_conv.inner = (void*)(orig & (~1));
5973         orig_conv.is_owned = (orig & 1) || (orig == 0);
5974         LDKHTLCUpdate ret = HTLCUpdate_clone(&orig_conv);
5975         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5976 }
5977
5978 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5979         LDKHTLCUpdate obj_conv;
5980         obj_conv.inner = (void*)(obj & (~1));
5981         obj_conv.is_owned = (obj & 1) || (obj == 0);
5982         LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
5983         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
5984         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
5985         CVec_u8Z_free(arg_var);
5986         return arg_arr;
5987 }
5988
5989 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
5990         LDKu8slice ser_ref;
5991         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
5992         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
5993         LDKHTLCUpdate ret = HTLCUpdate_read(ser_ref);
5994         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
5995         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5996 }
5997
5998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5999         LDKChannelMonitor this_ptr_conv;
6000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6001         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6002         ChannelMonitor_free(this_ptr_conv);
6003 }
6004
6005 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv * _env, jclass _b, jlong this_arg, jlong updates, jlong broadcaster, jlong logger) {
6006         LDKChannelMonitor this_arg_conv;
6007         this_arg_conv.inner = (void*)(this_arg & (~1));
6008         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6009         LDKChannelMonitorUpdate updates_conv;
6010         updates_conv.inner = (void*)(updates & (~1));
6011         updates_conv.is_owned = (updates & 1) || (updates == 0);
6012         if (updates_conv.inner != NULL)
6013                 updates_conv = ChannelMonitorUpdate_clone(&updates_conv);
6014         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
6015         LDKLogger* logger_conv = (LDKLogger*)logger;
6016         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6017         *ret = ChannelMonitor_update_monitor(&this_arg_conv, updates_conv, broadcaster_conv, logger_conv);
6018         return (long)ret;
6019 }
6020
6021 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6022         LDKChannelMonitor this_arg_conv;
6023         this_arg_conv.inner = (void*)(this_arg & (~1));
6024         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6025         jlong ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
6026         return ret_val;
6027 }
6028
6029 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv * _env, jclass _b, jlong this_arg) {
6030         LDKChannelMonitor this_arg_conv;
6031         this_arg_conv.inner = (void*)(this_arg & (~1));
6032         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6033         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6034         *ret = ChannelMonitor_get_funding_txo(&this_arg_conv);
6035         return (long)ret;
6036 }
6037
6038 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
6039         LDKChannelMonitor this_arg_conv;
6040         this_arg_conv.inner = (void*)(this_arg & (~1));
6041         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6042         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
6043         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6044         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6045         for (size_t o = 0; o < ret_var.datalen; o++) {
6046                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
6047                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6048                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6049                 long arr_conv_14_ref;
6050                 if (arr_conv_14_var.is_owned) {
6051                         arr_conv_14_ref = (long)arr_conv_14_var.inner | 1;
6052                 } else {
6053                         arr_conv_14_ref = (long)arr_conv_14_var.inner & ~1;
6054                 }
6055                 ret_arr_ptr[o] = arr_conv_14_ref;
6056         }
6057         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6058         FREE(ret_var.data);
6059         return ret_arr;
6060 }
6061
6062 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
6063         LDKChannelMonitor this_arg_conv;
6064         this_arg_conv.inner = (void*)(this_arg & (~1));
6065         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6066         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
6067         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6068         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6069         for (size_t h = 0; h < ret_var.datalen; h++) {
6070                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6071                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
6072                 long arr_conv_7_ref = (long)arr_conv_7_copy;
6073                 ret_arr_ptr[h] = arr_conv_7_ref;
6074         }
6075         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6076         CVec_EventZ_free(ret_var);
6077         return ret_arr;
6078 }
6079
6080 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) {
6081         LDKChannelMonitor this_arg_conv;
6082         this_arg_conv.inner = (void*)(this_arg & (~1));
6083         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6084         LDKLogger* logger_conv = (LDKLogger*)logger;
6085         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
6086         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6087         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6088         for (size_t n = 0; n < ret_var.datalen; n++) {
6089                 LDKTransaction *arr_conv_13_copy = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
6090                 *arr_conv_13_copy = ret_var.data[n];
6091                 long arr_conv_13_ref = (long)arr_conv_13_copy;
6092                 ret_arr_ptr[n] = arr_conv_13_ref;
6093         }
6094         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6095         CVec_TransactionZ_free(ret_var);
6096         return ret_arr;
6097 }
6098
6099 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height, jlong broadcaster, jlong fee_estimator, jlong logger) {
6100         LDKChannelMonitor this_arg_conv;
6101         this_arg_conv.inner = (void*)(this_arg & (~1));
6102         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6103         unsigned char header_arr[80];
6104         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6105         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6106         unsigned char (*header_ref)[80] = &header_arr;
6107         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6108         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
6109         if (txdata_constr.datalen > 0)
6110                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6111         else
6112                 txdata_constr.data = NULL;
6113         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
6114         for (size_t d = 0; d < txdata_constr.datalen; d++) {
6115                 long arr_conv_29 = txdata_vals[d];
6116                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
6117                 FREE((void*)arr_conv_29);
6118                 txdata_constr.data[d] = arr_conv_29_conv;
6119         }
6120         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
6121         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6122         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6123                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6124                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
6125         }
6126         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6127         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6128                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6129                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6130         }
6131         LDKLogger logger_conv = *(LDKLogger*)logger;
6132         if (logger_conv.free == LDKLogger_JCalls_free) {
6133                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6134                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6135         }
6136         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
6137         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6138         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6139         for (size_t b = 0; b < ret_var.datalen; b++) {
6140                 long arr_conv_27_ref = (long)&ret_var.data[b];
6141                 ret_arr_ptr[b] = arr_conv_27_ref;
6142         }
6143         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6144         CVec_C2Tuple_TxidCVec_TxOutZZZ_free(ret_var);
6145         return ret_arr;
6146 }
6147
6148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint height, jlong broadcaster, jlong fee_estimator, jlong logger) {
6149         LDKChannelMonitor this_arg_conv;
6150         this_arg_conv.inner = (void*)(this_arg & (~1));
6151         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6152         unsigned char header_arr[80];
6153         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6154         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6155         unsigned char (*header_ref)[80] = &header_arr;
6156         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6157         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6158                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6159                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
6160         }
6161         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6162         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6163                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6164                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6165         }
6166         LDKLogger logger_conv = *(LDKLogger*)logger;
6167         if (logger_conv.free == LDKLogger_JCalls_free) {
6168                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6169                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6170         }
6171         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
6172 }
6173
6174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6175         LDKOutPoint this_ptr_conv;
6176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6177         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6178         OutPoint_free(this_ptr_conv);
6179 }
6180
6181 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6182         LDKOutPoint orig_conv;
6183         orig_conv.inner = (void*)(orig & (~1));
6184         orig_conv.is_owned = (orig & 1) || (orig == 0);
6185         LDKOutPoint ret = OutPoint_clone(&orig_conv);
6186         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6187 }
6188
6189 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
6190         LDKOutPoint this_ptr_conv;
6191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6192         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6193         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6194         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
6195         return ret_arr;
6196 }
6197
6198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6199         LDKOutPoint this_ptr_conv;
6200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6201         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6202         LDKThirtyTwoBytes val_ref;
6203         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6204         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6205         OutPoint_set_txid(&this_ptr_conv, val_ref);
6206 }
6207
6208 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
6209         LDKOutPoint this_ptr_conv;
6210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6211         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6212         jshort ret_val = OutPoint_get_index(&this_ptr_conv);
6213         return ret_val;
6214 }
6215
6216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6217         LDKOutPoint this_ptr_conv;
6218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6219         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6220         OutPoint_set_index(&this_ptr_conv, val);
6221 }
6222
6223 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv * _env, jclass _b, jbyteArray txid_arg, jshort index_arg) {
6224         LDKThirtyTwoBytes txid_arg_ref;
6225         CHECK((*_env)->GetArrayLength (_env, txid_arg) == 32);
6226         (*_env)->GetByteArrayRegion (_env, txid_arg, 0, 32, txid_arg_ref.data);
6227         LDKOutPoint ret = OutPoint_new(txid_arg_ref, index_arg);
6228         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6229 }
6230
6231 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6232         LDKOutPoint this_arg_conv;
6233         this_arg_conv.inner = (void*)(this_arg & (~1));
6234         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6235         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
6236         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
6237         return arg_arr;
6238 }
6239
6240 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv * _env, jclass _b, jlong obj) {
6241         LDKOutPoint obj_conv;
6242         obj_conv.inner = (void*)(obj & (~1));
6243         obj_conv.is_owned = (obj & 1) || (obj == 0);
6244         LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
6245         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
6246         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
6247         CVec_u8Z_free(arg_var);
6248         return arg_arr;
6249 }
6250
6251 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
6252         LDKu8slice ser_ref;
6253         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
6254         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
6255         LDKOutPoint ret = OutPoint_read(ser_ref);
6256         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
6257         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6258 }
6259
6260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6261         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
6262         FREE((void*)this_ptr);
6263         SpendableOutputDescriptor_free(this_ptr_conv);
6264 }
6265
6266 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6267         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
6268         LDKSpendableOutputDescriptor* ret = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
6269         *ret = SpendableOutputDescriptor_clone(orig_conv);
6270         return (long)ret;
6271 }
6272
6273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6274         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
6275         FREE((void*)this_ptr);
6276         ChannelKeys_free(this_ptr_conv);
6277 }
6278
6279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6280         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
6281         FREE((void*)this_ptr);
6282         KeysInterface_free(this_ptr_conv);
6283 }
6284
6285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6286         LDKInMemoryChannelKeys this_ptr_conv;
6287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6288         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6289         InMemoryChannelKeys_free(this_ptr_conv);
6290 }
6291
6292 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6293         LDKInMemoryChannelKeys orig_conv;
6294         orig_conv.inner = (void*)(orig & (~1));
6295         orig_conv.is_owned = (orig & 1) || (orig == 0);
6296         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_clone(&orig_conv);
6297         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6298 }
6299
6300 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6301         LDKInMemoryChannelKeys this_ptr_conv;
6302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6303         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6304         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6305         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv));
6306         return ret_arr;
6307 }
6308
6309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6310         LDKInMemoryChannelKeys this_ptr_conv;
6311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6312         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6313         LDKSecretKey val_ref;
6314         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6315         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6316         InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
6317 }
6318
6319 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6320         LDKInMemoryChannelKeys this_ptr_conv;
6321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6322         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6323         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6324         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv));
6325         return ret_arr;
6326 }
6327
6328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6329         LDKInMemoryChannelKeys this_ptr_conv;
6330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6331         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6332         LDKSecretKey val_ref;
6333         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6334         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6335         InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
6336 }
6337
6338 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6339         LDKInMemoryChannelKeys this_ptr_conv;
6340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6341         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6342         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6343         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv));
6344         return ret_arr;
6345 }
6346
6347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6348         LDKInMemoryChannelKeys this_ptr_conv;
6349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6350         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6351         LDKSecretKey val_ref;
6352         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6353         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6354         InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
6355 }
6356
6357 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6358         LDKInMemoryChannelKeys this_ptr_conv;
6359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6360         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6361         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6362         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv));
6363         return ret_arr;
6364 }
6365
6366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6367         LDKInMemoryChannelKeys this_ptr_conv;
6368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6369         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6370         LDKSecretKey val_ref;
6371         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6372         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6373         InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
6374 }
6375
6376 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6377         LDKInMemoryChannelKeys this_ptr_conv;
6378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6379         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6380         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6381         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv));
6382         return ret_arr;
6383 }
6384
6385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6386         LDKInMemoryChannelKeys this_ptr_conv;
6387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6388         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6389         LDKSecretKey val_ref;
6390         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6391         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6392         InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
6393 }
6394
6395 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr) {
6396         LDKInMemoryChannelKeys this_ptr_conv;
6397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6398         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6399         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6400         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv));
6401         return ret_arr;
6402 }
6403
6404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6405         LDKInMemoryChannelKeys this_ptr_conv;
6406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6407         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6408         LDKThirtyTwoBytes val_ref;
6409         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6410         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6411         InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
6412 }
6413
6414 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1new(JNIEnv * _env, jclass _b, jbyteArray funding_key, jbyteArray revocation_base_key, jbyteArray payment_key, jbyteArray delayed_payment_base_key, jbyteArray htlc_base_key, jbyteArray commitment_seed, jlong channel_value_satoshis, jlong key_derivation_params) {
6415         LDKSecretKey funding_key_ref;
6416         CHECK((*_env)->GetArrayLength (_env, funding_key) == 32);
6417         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_ref.bytes);
6418         LDKSecretKey revocation_base_key_ref;
6419         CHECK((*_env)->GetArrayLength (_env, revocation_base_key) == 32);
6420         (*_env)->GetByteArrayRegion (_env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
6421         LDKSecretKey payment_key_ref;
6422         CHECK((*_env)->GetArrayLength (_env, payment_key) == 32);
6423         (*_env)->GetByteArrayRegion (_env, payment_key, 0, 32, payment_key_ref.bytes);
6424         LDKSecretKey delayed_payment_base_key_ref;
6425         CHECK((*_env)->GetArrayLength (_env, delayed_payment_base_key) == 32);
6426         (*_env)->GetByteArrayRegion (_env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
6427         LDKSecretKey htlc_base_key_ref;
6428         CHECK((*_env)->GetArrayLength (_env, htlc_base_key) == 32);
6429         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
6430         LDKThirtyTwoBytes commitment_seed_ref;
6431         CHECK((*_env)->GetArrayLength (_env, commitment_seed) == 32);
6432         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_ref.data);
6433         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
6434         FREE((void*)key_derivation_params);
6435         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_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, key_derivation_params_conv);
6436         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6437 }
6438
6439 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
6440         LDKInMemoryChannelKeys this_arg_conv;
6441         this_arg_conv.inner = (void*)(this_arg & (~1));
6442         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6443         LDKChannelPublicKeys ret = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
6444         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6445 }
6446
6447 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
6448         LDKInMemoryChannelKeys this_arg_conv;
6449         this_arg_conv.inner = (void*)(this_arg & (~1));
6450         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6451         jshort ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
6452         return ret_val;
6453 }
6454
6455 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1holder_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
6456         LDKInMemoryChannelKeys this_arg_conv;
6457         this_arg_conv.inner = (void*)(this_arg & (~1));
6458         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6459         jshort ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
6460         return ret_val;
6461 }
6462
6463 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1as_1ChannelKeys(JNIEnv * _env, jclass _b, jlong this_arg) {
6464         LDKInMemoryChannelKeys this_arg_conv;
6465         this_arg_conv.inner = (void*)(this_arg & (~1));
6466         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6467         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
6468         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
6469         return (long)ret;
6470 }
6471
6472 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
6473         LDKInMemoryChannelKeys obj_conv;
6474         obj_conv.inner = (void*)(obj & (~1));
6475         obj_conv.is_owned = (obj & 1) || (obj == 0);
6476         LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
6477         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
6478         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
6479         CVec_u8Z_free(arg_var);
6480         return arg_arr;
6481 }
6482
6483 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
6484         LDKu8slice ser_ref;
6485         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
6486         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
6487         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_read(ser_ref);
6488         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
6489         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6490 }
6491
6492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6493         LDKKeysManager this_ptr_conv;
6494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6495         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6496         KeysManager_free(this_ptr_conv);
6497 }
6498
6499 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1new(JNIEnv * _env, jclass _b, jbyteArray seed, jclass network, jlong starting_time_secs, jint starting_time_nanos) {
6500         unsigned char seed_arr[32];
6501         CHECK((*_env)->GetArrayLength (_env, seed) == 32);
6502         (*_env)->GetByteArrayRegion (_env, seed, 0, 32, seed_arr);
6503         unsigned char (*seed_ref)[32] = &seed_arr;
6504         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
6505         LDKKeysManager ret = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
6506         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6507 }
6508
6509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1derive_1channel_1keys(JNIEnv * _env, jclass _b, jlong this_arg, jlong channel_value_satoshis, jlong params_1, jlong params_2) {
6510         LDKKeysManager this_arg_conv;
6511         this_arg_conv.inner = (void*)(this_arg & (~1));
6512         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6513         LDKInMemoryChannelKeys ret = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
6514         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6515 }
6516
6517 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv * _env, jclass _b, jlong this_arg) {
6518         LDKKeysManager this_arg_conv;
6519         this_arg_conv.inner = (void*)(this_arg & (~1));
6520         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6521         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6522         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
6523         return (long)ret;
6524 }
6525
6526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6527         LDKChannelManager this_ptr_conv;
6528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6529         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6530         ChannelManager_free(this_ptr_conv);
6531 }
6532
6533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6534         LDKChannelDetails this_ptr_conv;
6535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6536         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6537         ChannelDetails_free(this_ptr_conv);
6538 }
6539
6540 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6541         LDKChannelDetails orig_conv;
6542         orig_conv.inner = (void*)(orig & (~1));
6543         orig_conv.is_owned = (orig & 1) || (orig == 0);
6544         LDKChannelDetails ret = ChannelDetails_clone(&orig_conv);
6545         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6546 }
6547
6548 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6549         LDKChannelDetails this_ptr_conv;
6550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6551         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6552         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6553         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
6554         return ret_arr;
6555 }
6556
6557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6558         LDKChannelDetails this_ptr_conv;
6559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6560         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6561         LDKThirtyTwoBytes val_ref;
6562         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6563         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6564         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
6565 }
6566
6567 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6568         LDKChannelDetails this_ptr_conv;
6569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6570         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6571         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6572         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
6573         return arg_arr;
6574 }
6575
6576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6577         LDKChannelDetails this_ptr_conv;
6578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6579         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6580         LDKPublicKey val_ref;
6581         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6582         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6583         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
6584 }
6585
6586 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
6587         LDKChannelDetails this_ptr_conv;
6588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6589         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6590         LDKInitFeatures ret = ChannelDetails_get_counterparty_features(&this_ptr_conv);
6591         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6592 }
6593
6594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6595         LDKChannelDetails this_ptr_conv;
6596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6597         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6598         LDKInitFeatures val_conv;
6599         val_conv.inner = (void*)(val & (~1));
6600         val_conv.is_owned = (val & 1) || (val == 0);
6601         // Warning: we may need a move here but can't clone!
6602         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
6603 }
6604
6605 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6606         LDKChannelDetails this_ptr_conv;
6607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6608         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6609         jlong ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
6610         return ret_val;
6611 }
6612
6613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6614         LDKChannelDetails this_ptr_conv;
6615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6616         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6617         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
6618 }
6619
6620 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6621         LDKChannelDetails this_ptr_conv;
6622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6623         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6624         jlong ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
6625         return ret_val;
6626 }
6627
6628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6629         LDKChannelDetails this_ptr_conv;
6630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6631         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6632         ChannelDetails_set_user_id(&this_ptr_conv, val);
6633 }
6634
6635 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6636         LDKChannelDetails this_ptr_conv;
6637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6638         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6639         jlong ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
6640         return ret_val;
6641 }
6642
6643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6644         LDKChannelDetails this_ptr_conv;
6645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6646         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6647         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
6648 }
6649
6650 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6651         LDKChannelDetails this_ptr_conv;
6652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6653         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6654         jlong ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
6655         return ret_val;
6656 }
6657
6658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6659         LDKChannelDetails this_ptr_conv;
6660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6661         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6662         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
6663 }
6664
6665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr) {
6666         LDKChannelDetails this_ptr_conv;
6667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6668         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6669         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
6670         return ret_val;
6671 }
6672
6673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
6674         LDKChannelDetails this_ptr_conv;
6675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6676         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6677         ChannelDetails_set_is_live(&this_ptr_conv, val);
6678 }
6679
6680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6681         LDKPaymentSendFailure this_ptr_conv;
6682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6683         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6684         PaymentSendFailure_free(this_ptr_conv);
6685 }
6686
6687 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv * _env, jclass _b, jclass network, jlong fee_est, jlong chain_monitor, jlong tx_broadcaster, jlong logger, jlong keys_manager, jlong config, jlong current_blockchain_height) {
6688         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
6689         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
6690         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
6691                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6692                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
6693         }
6694         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
6695         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
6696                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6697                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
6698         }
6699         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
6700         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6701                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6702                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
6703         }
6704         LDKLogger logger_conv = *(LDKLogger*)logger;
6705         if (logger_conv.free == LDKLogger_JCalls_free) {
6706                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6707                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6708         }
6709         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
6710         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
6711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6712                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
6713         }
6714         LDKUserConfig config_conv;
6715         config_conv.inner = (void*)(config & (~1));
6716         config_conv.is_owned = (config & 1) || (config == 0);
6717         if (config_conv.inner != NULL)
6718                 config_conv = UserConfig_clone(&config_conv);
6719         LDKChannelManager ret = ChannelManager_new(network_conv, fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, current_blockchain_height);
6720         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6721 }
6722
6723 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_network_key, jlong channel_value_satoshis, jlong push_msat, jlong user_id, jlong override_config) {
6724         LDKChannelManager this_arg_conv;
6725         this_arg_conv.inner = (void*)(this_arg & (~1));
6726         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6727         LDKPublicKey their_network_key_ref;
6728         CHECK((*_env)->GetArrayLength (_env, their_network_key) == 33);
6729         (*_env)->GetByteArrayRegion (_env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
6730         LDKUserConfig override_config_conv;
6731         override_config_conv.inner = (void*)(override_config & (~1));
6732         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
6733         if (override_config_conv.inner != NULL)
6734                 override_config_conv = UserConfig_clone(&override_config_conv);
6735         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6736         *ret = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
6737         return (long)ret;
6738 }
6739
6740 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6741         LDKChannelManager this_arg_conv;
6742         this_arg_conv.inner = (void*)(this_arg & (~1));
6743         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6744         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
6745         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6746         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6747         for (size_t q = 0; q < ret_var.datalen; q++) {
6748                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
6749                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6750                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6751                 long arr_conv_16_ref;
6752                 if (arr_conv_16_var.is_owned) {
6753                         arr_conv_16_ref = (long)arr_conv_16_var.inner | 1;
6754                 } else {
6755                         arr_conv_16_ref = (long)arr_conv_16_var.inner & ~1;
6756                 }
6757                 ret_arr_ptr[q] = arr_conv_16_ref;
6758         }
6759         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6760         FREE(ret_var.data);
6761         return ret_arr;
6762 }
6763
6764 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6765         LDKChannelManager this_arg_conv;
6766         this_arg_conv.inner = (void*)(this_arg & (~1));
6767         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6768         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
6769         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6770         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6771         for (size_t q = 0; q < ret_var.datalen; q++) {
6772                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
6773                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6774                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6775                 long arr_conv_16_ref;
6776                 if (arr_conv_16_var.is_owned) {
6777                         arr_conv_16_ref = (long)arr_conv_16_var.inner | 1;
6778                 } else {
6779                         arr_conv_16_ref = (long)arr_conv_16_var.inner & ~1;
6780                 }
6781                 ret_arr_ptr[q] = arr_conv_16_ref;
6782         }
6783         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6784         FREE(ret_var.data);
6785         return ret_arr;
6786 }
6787
6788 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
6789         LDKChannelManager this_arg_conv;
6790         this_arg_conv.inner = (void*)(this_arg & (~1));
6791         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6792         unsigned char channel_id_arr[32];
6793         CHECK((*_env)->GetArrayLength (_env, channel_id) == 32);
6794         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
6795         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6796         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6797         *ret = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
6798         return (long)ret;
6799 }
6800
6801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
6802         LDKChannelManager this_arg_conv;
6803         this_arg_conv.inner = (void*)(this_arg & (~1));
6804         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6805         unsigned char channel_id_arr[32];
6806         CHECK((*_env)->GetArrayLength (_env, channel_id) == 32);
6807         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
6808         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6809         ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
6810 }
6811
6812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6813         LDKChannelManager this_arg_conv;
6814         this_arg_conv.inner = (void*)(this_arg & (~1));
6815         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6816         ChannelManager_force_close_all_channels(&this_arg_conv);
6817 }
6818
6819 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv * _env, jclass _b, jlong this_arg, jlong route, jbyteArray payment_hash, jbyteArray payment_secret) {
6820         LDKChannelManager this_arg_conv;
6821         this_arg_conv.inner = (void*)(this_arg & (~1));
6822         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6823         LDKRoute route_conv;
6824         route_conv.inner = (void*)(route & (~1));
6825         route_conv.is_owned = (route & 1) || (route == 0);
6826         LDKThirtyTwoBytes payment_hash_ref;
6827         CHECK((*_env)->GetArrayLength (_env, payment_hash) == 32);
6828         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_ref.data);
6829         LDKThirtyTwoBytes payment_secret_ref;
6830         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6831         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6832         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
6833         *ret = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
6834         return (long)ret;
6835 }
6836
6837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray temporary_channel_id, jlong funding_txo) {
6838         LDKChannelManager this_arg_conv;
6839         this_arg_conv.inner = (void*)(this_arg & (~1));
6840         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6841         unsigned char temporary_channel_id_arr[32];
6842         CHECK((*_env)->GetArrayLength (_env, temporary_channel_id) == 32);
6843         (*_env)->GetByteArrayRegion (_env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
6844         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
6845         LDKOutPoint funding_txo_conv;
6846         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6847         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6848         if (funding_txo_conv.inner != NULL)
6849                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6850         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
6851 }
6852
6853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray rgb, jbyteArray alias, jlongArray addresses) {
6854         LDKChannelManager this_arg_conv;
6855         this_arg_conv.inner = (void*)(this_arg & (~1));
6856         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6857         LDKThreeBytes rgb_ref;
6858         CHECK((*_env)->GetArrayLength (_env, rgb) == 3);
6859         (*_env)->GetByteArrayRegion (_env, rgb, 0, 3, rgb_ref.data);
6860         LDKThirtyTwoBytes alias_ref;
6861         CHECK((*_env)->GetArrayLength (_env, alias) == 32);
6862         (*_env)->GetByteArrayRegion (_env, alias, 0, 32, alias_ref.data);
6863         LDKCVec_NetAddressZ addresses_constr;
6864         addresses_constr.datalen = (*_env)->GetArrayLength (_env, addresses);
6865         if (addresses_constr.datalen > 0)
6866                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
6867         else
6868                 addresses_constr.data = NULL;
6869         long* addresses_vals = (*_env)->GetLongArrayElements (_env, addresses, NULL);
6870         for (size_t m = 0; m < addresses_constr.datalen; m++) {
6871                 long arr_conv_12 = addresses_vals[m];
6872                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
6873                 FREE((void*)arr_conv_12);
6874                 addresses_constr.data[m] = arr_conv_12_conv;
6875         }
6876         (*_env)->ReleaseLongArrayElements (_env, addresses, addresses_vals, 0);
6877         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
6878 }
6879
6880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv * _env, jclass _b, jlong this_arg) {
6881         LDKChannelManager this_arg_conv;
6882         this_arg_conv.inner = (void*)(this_arg & (~1));
6883         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6884         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
6885 }
6886
6887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv * _env, jclass _b, jlong this_arg) {
6888         LDKChannelManager this_arg_conv;
6889         this_arg_conv.inner = (void*)(this_arg & (~1));
6890         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6891         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
6892 }
6893
6894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray payment_hash, jbyteArray payment_secret) {
6895         LDKChannelManager this_arg_conv;
6896         this_arg_conv.inner = (void*)(this_arg & (~1));
6897         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6898         unsigned char payment_hash_arr[32];
6899         CHECK((*_env)->GetArrayLength (_env, payment_hash) == 32);
6900         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_arr);
6901         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
6902         LDKThirtyTwoBytes payment_secret_ref;
6903         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6904         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6905         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
6906         return ret_val;
6907 }
6908
6909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray payment_preimage, jbyteArray payment_secret, jlong expected_amount) {
6910         LDKChannelManager this_arg_conv;
6911         this_arg_conv.inner = (void*)(this_arg & (~1));
6912         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6913         LDKThirtyTwoBytes payment_preimage_ref;
6914         CHECK((*_env)->GetArrayLength (_env, payment_preimage) == 32);
6915         (*_env)->GetByteArrayRegion (_env, payment_preimage, 0, 32, payment_preimage_ref.data);
6916         LDKThirtyTwoBytes payment_secret_ref;
6917         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6918         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6919         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
6920         return ret_val;
6921 }
6922
6923 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6924         LDKChannelManager this_arg_conv;
6925         this_arg_conv.inner = (void*)(this_arg & (~1));
6926         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6927         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6928         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
6929         return arg_arr;
6930 }
6931
6932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1monitor_1updated(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong highest_applied_update_id) {
6933         LDKChannelManager this_arg_conv;
6934         this_arg_conv.inner = (void*)(this_arg & (~1));
6935         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6936         LDKOutPoint funding_txo_conv;
6937         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6938         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6939         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
6940 }
6941
6942 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6943         LDKChannelManager this_arg_conv;
6944         this_arg_conv.inner = (void*)(this_arg & (~1));
6945         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6946         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6947         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
6948         return (long)ret;
6949 }
6950
6951 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6952         LDKChannelManager this_arg_conv;
6953         this_arg_conv.inner = (void*)(this_arg & (~1));
6954         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6955         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6956         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
6957         return (long)ret;
6958 }
6959
6960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height) {
6961         LDKChannelManager this_arg_conv;
6962         this_arg_conv.inner = (void*)(this_arg & (~1));
6963         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6964         unsigned char header_arr[80];
6965         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6966         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6967         unsigned char (*header_ref)[80] = &header_arr;
6968         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6969         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
6970         if (txdata_constr.datalen > 0)
6971                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6972         else
6973                 txdata_constr.data = NULL;
6974         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
6975         for (size_t d = 0; d < txdata_constr.datalen; d++) {
6976                 long arr_conv_29 = txdata_vals[d];
6977                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
6978                 FREE((void*)arr_conv_29);
6979                 txdata_constr.data[d] = arr_conv_29_conv;
6980         }
6981         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
6982         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
6983 }
6984
6985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header) {
6986         LDKChannelManager this_arg_conv;
6987         this_arg_conv.inner = (void*)(this_arg & (~1));
6988         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6989         unsigned char header_arr[80];
6990         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6991         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6992         unsigned char (*header_ref)[80] = &header_arr;
6993         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
6994 }
6995
6996 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
6997         LDKChannelManager this_arg_conv;
6998         this_arg_conv.inner = (void*)(this_arg & (~1));
6999         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
7000         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7001         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
7002         return (long)ret;
7003 }
7004
7005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7006         LDKChannelManagerReadArgs this_ptr_conv;
7007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7008         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7009         ChannelManagerReadArgs_free(this_ptr_conv);
7010 }
7011
7012 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr) {
7013         LDKChannelManagerReadArgs this_ptr_conv;
7014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7015         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7016         long ret_ = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
7017         return ret_;
7018 }
7019
7020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7021         LDKChannelManagerReadArgs this_ptr_conv;
7022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7023         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7024         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
7025         if (val_conv.free == LDKKeysInterface_JCalls_free) {
7026                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7027                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
7028         }
7029         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
7030 }
7031
7032 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr) {
7033         LDKChannelManagerReadArgs this_ptr_conv;
7034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7035         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7036         long ret_ = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
7037         return ret_;
7038 }
7039
7040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7041         LDKChannelManagerReadArgs this_ptr_conv;
7042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7043         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7044         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
7045         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
7046                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7047                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
7048         }
7049         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
7050 }
7051
7052 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr) {
7053         LDKChannelManagerReadArgs this_ptr_conv;
7054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7055         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7056         long ret_ = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
7057         return ret_;
7058 }
7059
7060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7061         LDKChannelManagerReadArgs this_ptr_conv;
7062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7063         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7064         LDKWatch val_conv = *(LDKWatch*)val;
7065         if (val_conv.free == LDKWatch_JCalls_free) {
7066                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7067                 LDKWatch_JCalls_clone(val_conv.this_arg);
7068         }
7069         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
7070 }
7071
7072 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr) {
7073         LDKChannelManagerReadArgs this_ptr_conv;
7074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7075         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7076         long ret_ = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
7077         return ret_;
7078 }
7079
7080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7081         LDKChannelManagerReadArgs this_ptr_conv;
7082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7083         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7084         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
7085         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
7086                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7087                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
7088         }
7089         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
7090 }
7091
7092 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv * _env, jclass _b, jlong this_ptr) {
7093         LDKChannelManagerReadArgs this_ptr_conv;
7094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7095         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7096         long ret_ = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
7097         return ret_;
7098 }
7099
7100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7101         LDKChannelManagerReadArgs this_ptr_conv;
7102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7103         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7104         LDKLogger val_conv = *(LDKLogger*)val;
7105         if (val_conv.free == LDKLogger_JCalls_free) {
7106                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7107                 LDKLogger_JCalls_clone(val_conv.this_arg);
7108         }
7109         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
7110 }
7111
7112 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
7113         LDKChannelManagerReadArgs this_ptr_conv;
7114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7115         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7116         LDKUserConfig ret = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
7117         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7118 }
7119
7120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7121         LDKChannelManagerReadArgs this_ptr_conv;
7122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7123         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7124         LDKUserConfig val_conv;
7125         val_conv.inner = (void*)(val & (~1));
7126         val_conv.is_owned = (val & 1) || (val == 0);
7127         if (val_conv.inner != NULL)
7128                 val_conv = UserConfig_clone(&val_conv);
7129         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
7130 }
7131
7132 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv * _env, jclass _b, jlong keys_manager, jlong fee_estimator, jlong chain_monitor, jlong tx_broadcaster, jlong logger, jlong default_config, jlongArray channel_monitors) {
7133         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
7134         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
7135                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7136                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
7137         }
7138         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
7139         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
7140                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7141                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
7142         }
7143         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
7144         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
7145                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7146                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
7147         }
7148         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
7149         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
7150                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7151                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
7152         }
7153         LDKLogger logger_conv = *(LDKLogger*)logger;
7154         if (logger_conv.free == LDKLogger_JCalls_free) {
7155                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7156                 LDKLogger_JCalls_clone(logger_conv.this_arg);
7157         }
7158         LDKUserConfig default_config_conv;
7159         default_config_conv.inner = (void*)(default_config & (~1));
7160         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
7161         if (default_config_conv.inner != NULL)
7162                 default_config_conv = UserConfig_clone(&default_config_conv);
7163         LDKCVec_ChannelMonitorZ channel_monitors_constr;
7164         channel_monitors_constr.datalen = (*_env)->GetArrayLength (_env, channel_monitors);
7165         if (channel_monitors_constr.datalen > 0)
7166                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7167         else
7168                 channel_monitors_constr.data = NULL;
7169         long* channel_monitors_vals = (*_env)->GetLongArrayElements (_env, channel_monitors, NULL);
7170         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
7171                 long arr_conv_16 = channel_monitors_vals[q];
7172                 LDKChannelMonitor arr_conv_16_conv;
7173                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
7174                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
7175                 // Warning: we may need a move here but can't clone!
7176                 channel_monitors_constr.data[q] = arr_conv_16_conv;
7177         }
7178         (*_env)->ReleaseLongArrayElements (_env, channel_monitors, channel_monitors_vals, 0);
7179         LDKChannelManagerReadArgs ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
7180         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7181 }
7182
7183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7184         LDKDecodeError this_ptr_conv;
7185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7186         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7187         DecodeError_free(this_ptr_conv);
7188 }
7189
7190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7191         LDKInit this_ptr_conv;
7192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7193         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7194         Init_free(this_ptr_conv);
7195 }
7196
7197 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7198         LDKInit orig_conv;
7199         orig_conv.inner = (void*)(orig & (~1));
7200         orig_conv.is_owned = (orig & 1) || (orig == 0);
7201         LDKInit ret = Init_clone(&orig_conv);
7202         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7203 }
7204
7205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7206         LDKErrorMessage this_ptr_conv;
7207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7208         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7209         ErrorMessage_free(this_ptr_conv);
7210 }
7211
7212 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7213         LDKErrorMessage orig_conv;
7214         orig_conv.inner = (void*)(orig & (~1));
7215         orig_conv.is_owned = (orig & 1) || (orig == 0);
7216         LDKErrorMessage ret = ErrorMessage_clone(&orig_conv);
7217         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7218 }
7219
7220 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7221         LDKErrorMessage this_ptr_conv;
7222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7223         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7224         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7225         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
7226         return ret_arr;
7227 }
7228
7229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7230         LDKErrorMessage this_ptr_conv;
7231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7232         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7233         LDKThirtyTwoBytes val_ref;
7234         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7235         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7236         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
7237 }
7238
7239 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) {
7240         LDKErrorMessage this_ptr_conv;
7241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7242         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7243         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
7244         char* _buf = MALLOC(_str.len + 1, "str conv buf");
7245         memcpy(_buf, _str.chars, _str.len);
7246         _buf[_str.len] = 0;
7247         jstring _conv = (*_env)->NewStringUTF(_env, _str.chars);
7248         FREE(_buf);
7249         return _conv;
7250 }
7251
7252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7253         LDKErrorMessage this_ptr_conv;
7254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7255         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7256         LDKCVec_u8Z val_ref;
7257         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
7258         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
7259         ErrorMessage_set_data(&this_ptr_conv, val_ref);
7260         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
7261 }
7262
7263 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray data_arg) {
7264         LDKThirtyTwoBytes channel_id_arg_ref;
7265         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7266         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7267         LDKCVec_u8Z data_arg_ref;
7268         data_arg_ref.data = (*_env)->GetByteArrayElements (_env, data_arg, NULL);
7269         data_arg_ref.datalen = (*_env)->GetArrayLength (_env, data_arg);
7270         LDKErrorMessage ret = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
7271         (*_env)->ReleaseByteArrayElements(_env, data_arg, (int8_t*)data_arg_ref.data, 0);
7272         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7273 }
7274
7275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7276         LDKPing this_ptr_conv;
7277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7278         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7279         Ping_free(this_ptr_conv);
7280 }
7281
7282 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7283         LDKPing orig_conv;
7284         orig_conv.inner = (void*)(orig & (~1));
7285         orig_conv.is_owned = (orig & 1) || (orig == 0);
7286         LDKPing ret = Ping_clone(&orig_conv);
7287         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7288 }
7289
7290 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7291         LDKPing this_ptr_conv;
7292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7293         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7294         jshort ret_val = Ping_get_ponglen(&this_ptr_conv);
7295         return ret_val;
7296 }
7297
7298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7299         LDKPing this_ptr_conv;
7300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7301         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7302         Ping_set_ponglen(&this_ptr_conv, val);
7303 }
7304
7305 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7306         LDKPing this_ptr_conv;
7307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7308         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7309         jshort ret_val = Ping_get_byteslen(&this_ptr_conv);
7310         return ret_val;
7311 }
7312
7313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7314         LDKPing this_ptr_conv;
7315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7316         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7317         Ping_set_byteslen(&this_ptr_conv, val);
7318 }
7319
7320 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv * _env, jclass _b, jshort ponglen_arg, jshort byteslen_arg) {
7321         LDKPing ret = Ping_new(ponglen_arg, byteslen_arg);
7322         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7323 }
7324
7325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7326         LDKPong this_ptr_conv;
7327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7328         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7329         Pong_free(this_ptr_conv);
7330 }
7331
7332 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7333         LDKPong orig_conv;
7334         orig_conv.inner = (void*)(orig & (~1));
7335         orig_conv.is_owned = (orig & 1) || (orig == 0);
7336         LDKPong ret = Pong_clone(&orig_conv);
7337         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7338 }
7339
7340 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7341         LDKPong this_ptr_conv;
7342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7343         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7344         jshort ret_val = Pong_get_byteslen(&this_ptr_conv);
7345         return ret_val;
7346 }
7347
7348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7349         LDKPong this_ptr_conv;
7350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7351         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7352         Pong_set_byteslen(&this_ptr_conv, val);
7353 }
7354
7355 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv * _env, jclass _b, jshort byteslen_arg) {
7356         LDKPong ret = Pong_new(byteslen_arg);
7357         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7358 }
7359
7360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7361         LDKOpenChannel this_ptr_conv;
7362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7363         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7364         OpenChannel_free(this_ptr_conv);
7365 }
7366
7367 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7368         LDKOpenChannel orig_conv;
7369         orig_conv.inner = (void*)(orig & (~1));
7370         orig_conv.is_owned = (orig & 1) || (orig == 0);
7371         LDKOpenChannel ret = OpenChannel_clone(&orig_conv);
7372         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7373 }
7374
7375 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7376         LDKOpenChannel this_ptr_conv;
7377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7378         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7379         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7380         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
7381         return ret_arr;
7382 }
7383
7384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7385         LDKOpenChannel this_ptr_conv;
7386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7387         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7388         LDKThirtyTwoBytes val_ref;
7389         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7390         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7391         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
7392 }
7393
7394 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7395         LDKOpenChannel this_ptr_conv;
7396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7397         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7398         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7399         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
7400         return ret_arr;
7401 }
7402
7403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7404         LDKOpenChannel this_ptr_conv;
7405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7406         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7407         LDKThirtyTwoBytes val_ref;
7408         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7409         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7410         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7411 }
7412
7413 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7414         LDKOpenChannel this_ptr_conv;
7415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7416         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7417         jlong ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
7418         return ret_val;
7419 }
7420
7421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7422         LDKOpenChannel this_ptr_conv;
7423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7424         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7425         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
7426 }
7427
7428 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7429         LDKOpenChannel this_ptr_conv;
7430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7431         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7432         jlong ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
7433         return ret_val;
7434 }
7435
7436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7437         LDKOpenChannel this_ptr_conv;
7438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7439         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7440         OpenChannel_set_push_msat(&this_ptr_conv, val);
7441 }
7442
7443 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7444         LDKOpenChannel this_ptr_conv;
7445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7446         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7447         jlong ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
7448         return ret_val;
7449 }
7450
7451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7452         LDKOpenChannel this_ptr_conv;
7453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7454         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7455         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7456 }
7457
7458 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7459         LDKOpenChannel this_ptr_conv;
7460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7462         jlong ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7463         return ret_val;
7464 }
7465
7466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7467         LDKOpenChannel this_ptr_conv;
7468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7469         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7470         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7471 }
7472
7473 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7474         LDKOpenChannel this_ptr_conv;
7475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7476         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7477         jlong ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7478         return ret_val;
7479 }
7480
7481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7482         LDKOpenChannel this_ptr_conv;
7483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7484         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7485         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7486 }
7487
7488 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7489         LDKOpenChannel this_ptr_conv;
7490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7491         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7492         jlong ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
7493         return ret_val;
7494 }
7495
7496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7497         LDKOpenChannel this_ptr_conv;
7498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7499         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7500         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7501 }
7502
7503 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
7504         LDKOpenChannel this_ptr_conv;
7505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7506         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7507         jint ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
7508         return ret_val;
7509 }
7510
7511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7512         LDKOpenChannel this_ptr_conv;
7513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7514         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7515         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
7516 }
7517
7518 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
7519         LDKOpenChannel this_ptr_conv;
7520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7521         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7522         jshort ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
7523         return ret_val;
7524 }
7525
7526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7527         LDKOpenChannel this_ptr_conv;
7528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7529         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7530         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
7531 }
7532
7533 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
7534         LDKOpenChannel this_ptr_conv;
7535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7536         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7537         jshort ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
7538         return ret_val;
7539 }
7540
7541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7542         LDKOpenChannel this_ptr_conv;
7543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7544         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7545         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7546 }
7547
7548 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
7549         LDKOpenChannel this_ptr_conv;
7550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7551         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7552         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7553         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
7554         return arg_arr;
7555 }
7556
7557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7558         LDKOpenChannel this_ptr_conv;
7559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7560         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7561         LDKPublicKey val_ref;
7562         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7563         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7564         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7565 }
7566
7567 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7568         LDKOpenChannel this_ptr_conv;
7569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7570         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7571         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7572         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
7573         return arg_arr;
7574 }
7575
7576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7577         LDKOpenChannel this_ptr_conv;
7578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7579         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7580         LDKPublicKey val_ref;
7581         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7582         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7583         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7584 }
7585
7586 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7587         LDKOpenChannel this_ptr_conv;
7588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7589         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7590         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7591         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
7592         return arg_arr;
7593 }
7594
7595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7596         LDKOpenChannel this_ptr_conv;
7597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7598         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7599         LDKPublicKey val_ref;
7600         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7601         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7602         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
7603 }
7604
7605 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7606         LDKOpenChannel this_ptr_conv;
7607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7608         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7609         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7610         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
7611         return arg_arr;
7612 }
7613
7614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7615         LDKOpenChannel this_ptr_conv;
7616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7617         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7618         LDKPublicKey val_ref;
7619         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7620         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7621         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7622 }
7623
7624 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7625         LDKOpenChannel this_ptr_conv;
7626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7627         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7628         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7629         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
7630         return arg_arr;
7631 }
7632
7633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7634         LDKOpenChannel this_ptr_conv;
7635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7636         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7637         LDKPublicKey val_ref;
7638         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7639         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7640         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7641 }
7642
7643 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7644         LDKOpenChannel this_ptr_conv;
7645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7646         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7647         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7648         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
7649         return arg_arr;
7650 }
7651
7652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7653         LDKOpenChannel this_ptr_conv;
7654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7655         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7656         LDKPublicKey val_ref;
7657         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7658         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7659         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7660 }
7661
7662 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
7663         LDKOpenChannel this_ptr_conv;
7664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7665         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7666         jbyte ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
7667         return ret_val;
7668 }
7669
7670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
7671         LDKOpenChannel this_ptr_conv;
7672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7673         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7674         OpenChannel_set_channel_flags(&this_ptr_conv, val);
7675 }
7676
7677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7678         LDKAcceptChannel this_ptr_conv;
7679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7680         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7681         AcceptChannel_free(this_ptr_conv);
7682 }
7683
7684 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7685         LDKAcceptChannel orig_conv;
7686         orig_conv.inner = (void*)(orig & (~1));
7687         orig_conv.is_owned = (orig & 1) || (orig == 0);
7688         LDKAcceptChannel ret = AcceptChannel_clone(&orig_conv);
7689         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7690 }
7691
7692 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7693         LDKAcceptChannel this_ptr_conv;
7694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7695         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7696         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7697         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
7698         return ret_arr;
7699 }
7700
7701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7702         LDKAcceptChannel this_ptr_conv;
7703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7704         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7705         LDKThirtyTwoBytes val_ref;
7706         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7707         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7708         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7709 }
7710
7711 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7712         LDKAcceptChannel this_ptr_conv;
7713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7715         jlong ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
7716         return ret_val;
7717 }
7718
7719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7720         LDKAcceptChannel this_ptr_conv;
7721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7722         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7723         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7724 }
7725
7726 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7727         LDKAcceptChannel this_ptr_conv;
7728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7729         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7730         jlong ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7731         return ret_val;
7732 }
7733
7734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7735         LDKAcceptChannel this_ptr_conv;
7736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7737         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7738         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7739 }
7740
7741 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7742         LDKAcceptChannel this_ptr_conv;
7743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7744         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7745         jlong ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7746         return ret_val;
7747 }
7748
7749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7750         LDKAcceptChannel this_ptr_conv;
7751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7752         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7753         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7754 }
7755
7756 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7757         LDKAcceptChannel this_ptr_conv;
7758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7759         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7760         jlong ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
7761         return ret_val;
7762 }
7763
7764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7765         LDKAcceptChannel this_ptr_conv;
7766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7767         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7768         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7769 }
7770
7771 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
7772         LDKAcceptChannel this_ptr_conv;
7773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7774         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7775         jint ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
7776         return ret_val;
7777 }
7778
7779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7780         LDKAcceptChannel this_ptr_conv;
7781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7782         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7783         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
7784 }
7785
7786 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
7787         LDKAcceptChannel this_ptr_conv;
7788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7789         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7790         jshort ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
7791         return ret_val;
7792 }
7793
7794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7795         LDKAcceptChannel this_ptr_conv;
7796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7797         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7798         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
7799 }
7800
7801 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
7802         LDKAcceptChannel this_ptr_conv;
7803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7804         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7805         jshort ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
7806         return ret_val;
7807 }
7808
7809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7810         LDKAcceptChannel this_ptr_conv;
7811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7812         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7813         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7814 }
7815
7816 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
7817         LDKAcceptChannel this_ptr_conv;
7818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7819         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7820         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7821         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
7822         return arg_arr;
7823 }
7824
7825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7826         LDKAcceptChannel this_ptr_conv;
7827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7828         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7829         LDKPublicKey val_ref;
7830         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7831         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7832         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7833 }
7834
7835 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7836         LDKAcceptChannel this_ptr_conv;
7837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7839         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7840         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
7841         return arg_arr;
7842 }
7843
7844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7845         LDKAcceptChannel this_ptr_conv;
7846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7847         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7848         LDKPublicKey val_ref;
7849         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7850         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7851         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7852 }
7853
7854 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7855         LDKAcceptChannel this_ptr_conv;
7856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7857         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7858         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7859         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
7860         return arg_arr;
7861 }
7862
7863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7864         LDKAcceptChannel this_ptr_conv;
7865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7866         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7867         LDKPublicKey val_ref;
7868         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7869         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7870         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
7871 }
7872
7873 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7874         LDKAcceptChannel this_ptr_conv;
7875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7876         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7877         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7878         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
7879         return arg_arr;
7880 }
7881
7882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7883         LDKAcceptChannel this_ptr_conv;
7884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7885         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7886         LDKPublicKey val_ref;
7887         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7888         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7889         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7890 }
7891
7892 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7893         LDKAcceptChannel this_ptr_conv;
7894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7895         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7896         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7897         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
7898         return arg_arr;
7899 }
7900
7901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7902         LDKAcceptChannel this_ptr_conv;
7903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7904         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7905         LDKPublicKey val_ref;
7906         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7907         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7908         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7909 }
7910
7911 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7912         LDKAcceptChannel this_ptr_conv;
7913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7914         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7915         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7916         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
7917         return arg_arr;
7918 }
7919
7920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7921         LDKAcceptChannel this_ptr_conv;
7922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7923         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7924         LDKPublicKey val_ref;
7925         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7926         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7927         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7928 }
7929
7930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7931         LDKFundingCreated this_ptr_conv;
7932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7933         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7934         FundingCreated_free(this_ptr_conv);
7935 }
7936
7937 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7938         LDKFundingCreated orig_conv;
7939         orig_conv.inner = (void*)(orig & (~1));
7940         orig_conv.is_owned = (orig & 1) || (orig == 0);
7941         LDKFundingCreated ret = FundingCreated_clone(&orig_conv);
7942         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7943 }
7944
7945 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7946         LDKFundingCreated this_ptr_conv;
7947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7948         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7949         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7950         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
7951         return ret_arr;
7952 }
7953
7954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7955         LDKFundingCreated this_ptr_conv;
7956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7957         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7958         LDKThirtyTwoBytes val_ref;
7959         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7960         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7961         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
7962 }
7963
7964 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
7965         LDKFundingCreated this_ptr_conv;
7966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7967         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7968         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7969         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
7970         return ret_arr;
7971 }
7972
7973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7974         LDKFundingCreated this_ptr_conv;
7975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7976         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7977         LDKThirtyTwoBytes val_ref;
7978         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7979         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7980         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
7981 }
7982
7983 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
7984         LDKFundingCreated this_ptr_conv;
7985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7986         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7987         jshort ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
7988         return ret_val;
7989 }
7990
7991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7992         LDKFundingCreated this_ptr_conv;
7993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7994         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7995         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
7996 }
7997
7998 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7999         LDKFundingCreated this_ptr_conv;
8000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8001         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8002         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8003         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
8004         return arg_arr;
8005 }
8006
8007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8008         LDKFundingCreated this_ptr_conv;
8009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8010         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8011         LDKSignature val_ref;
8012         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8013         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8014         FundingCreated_set_signature(&this_ptr_conv, val_ref);
8015 }
8016
8017 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1new(JNIEnv * _env, jclass _b, jbyteArray temporary_channel_id_arg, jbyteArray funding_txid_arg, jshort funding_output_index_arg, jbyteArray signature_arg) {
8018         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
8019         CHECK((*_env)->GetArrayLength (_env, temporary_channel_id_arg) == 32);
8020         (*_env)->GetByteArrayRegion (_env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
8021         LDKThirtyTwoBytes funding_txid_arg_ref;
8022         CHECK((*_env)->GetArrayLength (_env, funding_txid_arg) == 32);
8023         (*_env)->GetByteArrayRegion (_env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
8024         LDKSignature signature_arg_ref;
8025         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8026         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8027         LDKFundingCreated ret = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
8028         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8029 }
8030
8031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8032         LDKFundingSigned this_ptr_conv;
8033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8034         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8035         FundingSigned_free(this_ptr_conv);
8036 }
8037
8038 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8039         LDKFundingSigned orig_conv;
8040         orig_conv.inner = (void*)(orig & (~1));
8041         orig_conv.is_owned = (orig & 1) || (orig == 0);
8042         LDKFundingSigned ret = FundingSigned_clone(&orig_conv);
8043         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8044 }
8045
8046 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8047         LDKFundingSigned this_ptr_conv;
8048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8049         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8050         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8051         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
8052         return ret_arr;
8053 }
8054
8055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8056         LDKFundingSigned this_ptr_conv;
8057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8058         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8059         LDKThirtyTwoBytes val_ref;
8060         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8061         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8062         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
8063 }
8064
8065 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8066         LDKFundingSigned this_ptr_conv;
8067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8068         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8069         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8070         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
8071         return arg_arr;
8072 }
8073
8074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8075         LDKFundingSigned this_ptr_conv;
8076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8077         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8078         LDKSignature val_ref;
8079         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8080         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8081         FundingSigned_set_signature(&this_ptr_conv, val_ref);
8082 }
8083
8084 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray signature_arg) {
8085         LDKThirtyTwoBytes channel_id_arg_ref;
8086         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8087         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8088         LDKSignature signature_arg_ref;
8089         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8090         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8091         LDKFundingSigned ret = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
8092         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8093 }
8094
8095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8096         LDKFundingLocked this_ptr_conv;
8097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8098         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8099         FundingLocked_free(this_ptr_conv);
8100 }
8101
8102 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8103         LDKFundingLocked orig_conv;
8104         orig_conv.inner = (void*)(orig & (~1));
8105         orig_conv.is_owned = (orig & 1) || (orig == 0);
8106         LDKFundingLocked ret = FundingLocked_clone(&orig_conv);
8107         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8108 }
8109
8110 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8111         LDKFundingLocked this_ptr_conv;
8112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8113         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8114         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8115         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
8116         return ret_arr;
8117 }
8118
8119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8120         LDKFundingLocked this_ptr_conv;
8121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8122         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8123         LDKThirtyTwoBytes val_ref;
8124         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8125         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8126         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
8127 }
8128
8129 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8130         LDKFundingLocked this_ptr_conv;
8131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8132         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8133         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8134         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
8135         return arg_arr;
8136 }
8137
8138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8139         LDKFundingLocked this_ptr_conv;
8140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8141         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8142         LDKPublicKey val_ref;
8143         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8144         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8145         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
8146 }
8147
8148 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray next_per_commitment_point_arg) {
8149         LDKThirtyTwoBytes channel_id_arg_ref;
8150         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8151         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8152         LDKPublicKey next_per_commitment_point_arg_ref;
8153         CHECK((*_env)->GetArrayLength (_env, next_per_commitment_point_arg) == 33);
8154         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
8155         LDKFundingLocked ret = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
8156         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8157 }
8158
8159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8160         LDKShutdown this_ptr_conv;
8161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8162         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8163         Shutdown_free(this_ptr_conv);
8164 }
8165
8166 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8167         LDKShutdown orig_conv;
8168         orig_conv.inner = (void*)(orig & (~1));
8169         orig_conv.is_owned = (orig & 1) || (orig == 0);
8170         LDKShutdown ret = Shutdown_clone(&orig_conv);
8171         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8172 }
8173
8174 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8175         LDKShutdown this_ptr_conv;
8176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8177         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8178         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8179         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
8180         return ret_arr;
8181 }
8182
8183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8184         LDKShutdown this_ptr_conv;
8185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8186         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8187         LDKThirtyTwoBytes val_ref;
8188         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8189         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8190         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
8191 }
8192
8193 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
8194         LDKShutdown this_ptr_conv;
8195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8196         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8197         LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
8198         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
8199         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
8200         return arg_arr;
8201 }
8202
8203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8204         LDKShutdown this_ptr_conv;
8205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8206         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8207         LDKCVec_u8Z val_ref;
8208         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
8209         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
8210         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
8211         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
8212 }
8213
8214 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray scriptpubkey_arg) {
8215         LDKThirtyTwoBytes channel_id_arg_ref;
8216         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8217         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8218         LDKCVec_u8Z scriptpubkey_arg_ref;
8219         scriptpubkey_arg_ref.data = (*_env)->GetByteArrayElements (_env, scriptpubkey_arg, NULL);
8220         scriptpubkey_arg_ref.datalen = (*_env)->GetArrayLength (_env, scriptpubkey_arg);
8221         LDKShutdown ret = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
8222         (*_env)->ReleaseByteArrayElements(_env, scriptpubkey_arg, (int8_t*)scriptpubkey_arg_ref.data, 0);
8223         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8224 }
8225
8226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8227         LDKClosingSigned this_ptr_conv;
8228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8229         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8230         ClosingSigned_free(this_ptr_conv);
8231 }
8232
8233 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8234         LDKClosingSigned orig_conv;
8235         orig_conv.inner = (void*)(orig & (~1));
8236         orig_conv.is_owned = (orig & 1) || (orig == 0);
8237         LDKClosingSigned ret = ClosingSigned_clone(&orig_conv);
8238         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8239 }
8240
8241 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8242         LDKClosingSigned this_ptr_conv;
8243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8244         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8245         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8246         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
8247         return ret_arr;
8248 }
8249
8250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8251         LDKClosingSigned this_ptr_conv;
8252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8253         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8254         LDKThirtyTwoBytes val_ref;
8255         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8256         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8257         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
8258 }
8259
8260 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
8261         LDKClosingSigned this_ptr_conv;
8262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8263         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8264         jlong ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
8265         return ret_val;
8266 }
8267
8268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8269         LDKClosingSigned this_ptr_conv;
8270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8271         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8272         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
8273 }
8274
8275 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8276         LDKClosingSigned this_ptr_conv;
8277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8278         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8279         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8280         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
8281         return arg_arr;
8282 }
8283
8284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8285         LDKClosingSigned this_ptr_conv;
8286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8287         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8288         LDKSignature val_ref;
8289         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8290         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8291         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
8292 }
8293
8294 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong fee_satoshis_arg, jbyteArray signature_arg) {
8295         LDKThirtyTwoBytes channel_id_arg_ref;
8296         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8297         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8298         LDKSignature signature_arg_ref;
8299         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8300         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8301         LDKClosingSigned ret = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
8302         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8303 }
8304
8305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8306         LDKUpdateAddHTLC this_ptr_conv;
8307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8308         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8309         UpdateAddHTLC_free(this_ptr_conv);
8310 }
8311
8312 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8313         LDKUpdateAddHTLC orig_conv;
8314         orig_conv.inner = (void*)(orig & (~1));
8315         orig_conv.is_owned = (orig & 1) || (orig == 0);
8316         LDKUpdateAddHTLC ret = UpdateAddHTLC_clone(&orig_conv);
8317         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8318 }
8319
8320 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8321         LDKUpdateAddHTLC this_ptr_conv;
8322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8323         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8324         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8325         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
8326         return ret_arr;
8327 }
8328
8329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8330         LDKUpdateAddHTLC this_ptr_conv;
8331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8332         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8333         LDKThirtyTwoBytes val_ref;
8334         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8335         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8336         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
8337 }
8338
8339 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8340         LDKUpdateAddHTLC this_ptr_conv;
8341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8342         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8343         jlong ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
8344         return ret_val;
8345 }
8346
8347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8348         LDKUpdateAddHTLC this_ptr_conv;
8349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8350         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8351         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
8352 }
8353
8354 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8355         LDKUpdateAddHTLC this_ptr_conv;
8356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8357         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8358         jlong ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
8359         return ret_val;
8360 }
8361
8362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8363         LDKUpdateAddHTLC this_ptr_conv;
8364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8365         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8366         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
8367 }
8368
8369 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8370         LDKUpdateAddHTLC this_ptr_conv;
8371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8372         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8373         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8374         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
8375         return ret_arr;
8376 }
8377
8378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8379         LDKUpdateAddHTLC this_ptr_conv;
8380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8381         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8382         LDKThirtyTwoBytes val_ref;
8383         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8384         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8385         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
8386 }
8387
8388 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
8389         LDKUpdateAddHTLC this_ptr_conv;
8390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8391         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8392         jint ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
8393         return ret_val;
8394 }
8395
8396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8397         LDKUpdateAddHTLC this_ptr_conv;
8398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8399         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8400         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
8401 }
8402
8403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8404         LDKUpdateFulfillHTLC this_ptr_conv;
8405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8406         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8407         UpdateFulfillHTLC_free(this_ptr_conv);
8408 }
8409
8410 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8411         LDKUpdateFulfillHTLC orig_conv;
8412         orig_conv.inner = (void*)(orig & (~1));
8413         orig_conv.is_owned = (orig & 1) || (orig == 0);
8414         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_clone(&orig_conv);
8415         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8416 }
8417
8418 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8419         LDKUpdateFulfillHTLC this_ptr_conv;
8420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8421         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8422         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8423         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
8424         return ret_arr;
8425 }
8426
8427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8428         LDKUpdateFulfillHTLC this_ptr_conv;
8429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8430         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8431         LDKThirtyTwoBytes val_ref;
8432         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8433         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8434         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
8435 }
8436
8437 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8438         LDKUpdateFulfillHTLC this_ptr_conv;
8439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8440         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8441         jlong ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
8442         return ret_val;
8443 }
8444
8445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8446         LDKUpdateFulfillHTLC this_ptr_conv;
8447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8448         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8449         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
8450 }
8451
8452 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr) {
8453         LDKUpdateFulfillHTLC this_ptr_conv;
8454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8455         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8456         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8457         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
8458         return ret_arr;
8459 }
8460
8461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8462         LDKUpdateFulfillHTLC this_ptr_conv;
8463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8464         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8465         LDKThirtyTwoBytes val_ref;
8466         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8467         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8468         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
8469 }
8470
8471 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong htlc_id_arg, jbyteArray payment_preimage_arg) {
8472         LDKThirtyTwoBytes channel_id_arg_ref;
8473         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8474         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8475         LDKThirtyTwoBytes payment_preimage_arg_ref;
8476         CHECK((*_env)->GetArrayLength (_env, payment_preimage_arg) == 32);
8477         (*_env)->GetByteArrayRegion (_env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
8478         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
8479         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8480 }
8481
8482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8483         LDKUpdateFailHTLC this_ptr_conv;
8484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8485         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8486         UpdateFailHTLC_free(this_ptr_conv);
8487 }
8488
8489 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8490         LDKUpdateFailHTLC orig_conv;
8491         orig_conv.inner = (void*)(orig & (~1));
8492         orig_conv.is_owned = (orig & 1) || (orig == 0);
8493         LDKUpdateFailHTLC ret = UpdateFailHTLC_clone(&orig_conv);
8494         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8495 }
8496
8497 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8498         LDKUpdateFailHTLC this_ptr_conv;
8499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8500         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8501         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8502         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
8503         return ret_arr;
8504 }
8505
8506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8507         LDKUpdateFailHTLC this_ptr_conv;
8508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8509         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8510         LDKThirtyTwoBytes val_ref;
8511         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8512         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8513         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
8514 }
8515
8516 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8517         LDKUpdateFailHTLC this_ptr_conv;
8518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8519         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8520         jlong ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
8521         return ret_val;
8522 }
8523
8524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8525         LDKUpdateFailHTLC this_ptr_conv;
8526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8527         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8528         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
8529 }
8530
8531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8532         LDKUpdateFailMalformedHTLC this_ptr_conv;
8533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8534         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8535         UpdateFailMalformedHTLC_free(this_ptr_conv);
8536 }
8537
8538 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8539         LDKUpdateFailMalformedHTLC orig_conv;
8540         orig_conv.inner = (void*)(orig & (~1));
8541         orig_conv.is_owned = (orig & 1) || (orig == 0);
8542         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_clone(&orig_conv);
8543         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8544 }
8545
8546 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8547         LDKUpdateFailMalformedHTLC this_ptr_conv;
8548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8549         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8550         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8551         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
8552         return ret_arr;
8553 }
8554
8555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8556         LDKUpdateFailMalformedHTLC this_ptr_conv;
8557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8558         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8559         LDKThirtyTwoBytes val_ref;
8560         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8561         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8562         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
8563 }
8564
8565 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8566         LDKUpdateFailMalformedHTLC this_ptr_conv;
8567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8568         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8569         jlong ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
8570         return ret_val;
8571 }
8572
8573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8574         LDKUpdateFailMalformedHTLC this_ptr_conv;
8575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8576         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8577         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
8578 }
8579
8580 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr) {
8581         LDKUpdateFailMalformedHTLC this_ptr_conv;
8582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8583         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8584         jshort ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
8585         return ret_val;
8586 }
8587
8588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
8589         LDKUpdateFailMalformedHTLC this_ptr_conv;
8590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8591         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8592         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
8593 }
8594
8595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8596         LDKCommitmentSigned this_ptr_conv;
8597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8598         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8599         CommitmentSigned_free(this_ptr_conv);
8600 }
8601
8602 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8603         LDKCommitmentSigned orig_conv;
8604         orig_conv.inner = (void*)(orig & (~1));
8605         orig_conv.is_owned = (orig & 1) || (orig == 0);
8606         LDKCommitmentSigned ret = CommitmentSigned_clone(&orig_conv);
8607         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8608 }
8609
8610 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8611         LDKCommitmentSigned this_ptr_conv;
8612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8613         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8614         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8615         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
8616         return ret_arr;
8617 }
8618
8619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8620         LDKCommitmentSigned this_ptr_conv;
8621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8622         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8623         LDKThirtyTwoBytes val_ref;
8624         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8625         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8626         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
8627 }
8628
8629 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8630         LDKCommitmentSigned this_ptr_conv;
8631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8632         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8633         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8634         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
8635         return arg_arr;
8636 }
8637
8638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8639         LDKCommitmentSigned this_ptr_conv;
8640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8641         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8642         LDKSignature val_ref;
8643         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8644         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8645         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
8646 }
8647
8648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jobjectArray val) {
8649         LDKCommitmentSigned this_ptr_conv;
8650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8651         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8652         LDKCVec_SignatureZ val_constr;
8653         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
8654         if (val_constr.datalen > 0)
8655                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8656         else
8657                 val_constr.data = NULL;
8658         for (size_t i = 0; i < val_constr.datalen; i++) {
8659                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, val, i);
8660                 LDKSignature arr_conv_8_ref;
8661                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
8662                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
8663                 val_constr.data[i] = arr_conv_8_ref;
8664         }
8665         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
8666 }
8667
8668 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray signature_arg, jobjectArray htlc_signatures_arg) {
8669         LDKThirtyTwoBytes channel_id_arg_ref;
8670         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8671         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8672         LDKSignature signature_arg_ref;
8673         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8674         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8675         LDKCVec_SignatureZ htlc_signatures_arg_constr;
8676         htlc_signatures_arg_constr.datalen = (*_env)->GetArrayLength (_env, htlc_signatures_arg);
8677         if (htlc_signatures_arg_constr.datalen > 0)
8678                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8679         else
8680                 htlc_signatures_arg_constr.data = NULL;
8681         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
8682                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, htlc_signatures_arg, i);
8683                 LDKSignature arr_conv_8_ref;
8684                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
8685                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
8686                 htlc_signatures_arg_constr.data[i] = arr_conv_8_ref;
8687         }
8688         LDKCommitmentSigned ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
8689         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8690 }
8691
8692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8693         LDKRevokeAndACK this_ptr_conv;
8694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8695         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8696         RevokeAndACK_free(this_ptr_conv);
8697 }
8698
8699 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8700         LDKRevokeAndACK orig_conv;
8701         orig_conv.inner = (void*)(orig & (~1));
8702         orig_conv.is_owned = (orig & 1) || (orig == 0);
8703         LDKRevokeAndACK ret = RevokeAndACK_clone(&orig_conv);
8704         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8705 }
8706
8707 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8708         LDKRevokeAndACK this_ptr_conv;
8709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8710         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8711         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8712         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
8713         return ret_arr;
8714 }
8715
8716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8717         LDKRevokeAndACK this_ptr_conv;
8718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8719         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8720         LDKThirtyTwoBytes val_ref;
8721         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8722         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8723         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
8724 }
8725
8726 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
8727         LDKRevokeAndACK this_ptr_conv;
8728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8729         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8730         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8731         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
8732         return ret_arr;
8733 }
8734
8735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8736         LDKRevokeAndACK this_ptr_conv;
8737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8738         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8739         LDKThirtyTwoBytes val_ref;
8740         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8741         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8742         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
8743 }
8744
8745 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8746         LDKRevokeAndACK this_ptr_conv;
8747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8748         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8749         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8750         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
8751         return arg_arr;
8752 }
8753
8754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8755         LDKRevokeAndACK this_ptr_conv;
8756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8757         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8758         LDKPublicKey val_ref;
8759         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8760         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8761         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
8762 }
8763
8764 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray per_commitment_secret_arg, jbyteArray next_per_commitment_point_arg) {
8765         LDKThirtyTwoBytes channel_id_arg_ref;
8766         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8767         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8768         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
8769         CHECK((*_env)->GetArrayLength (_env, per_commitment_secret_arg) == 32);
8770         (*_env)->GetByteArrayRegion (_env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
8771         LDKPublicKey next_per_commitment_point_arg_ref;
8772         CHECK((*_env)->GetArrayLength (_env, next_per_commitment_point_arg) == 33);
8773         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
8774         LDKRevokeAndACK ret = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
8775         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8776 }
8777
8778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8779         LDKUpdateFee this_ptr_conv;
8780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8781         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8782         UpdateFee_free(this_ptr_conv);
8783 }
8784
8785 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8786         LDKUpdateFee orig_conv;
8787         orig_conv.inner = (void*)(orig & (~1));
8788         orig_conv.is_owned = (orig & 1) || (orig == 0);
8789         LDKUpdateFee ret = UpdateFee_clone(&orig_conv);
8790         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8791 }
8792
8793 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8794         LDKUpdateFee this_ptr_conv;
8795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8796         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8797         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8798         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
8799         return ret_arr;
8800 }
8801
8802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8803         LDKUpdateFee this_ptr_conv;
8804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8805         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8806         LDKThirtyTwoBytes val_ref;
8807         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8808         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8809         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
8810 }
8811
8812 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
8813         LDKUpdateFee this_ptr_conv;
8814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8815         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8816         jint ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
8817         return ret_val;
8818 }
8819
8820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8821         LDKUpdateFee this_ptr_conv;
8822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8823         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8824         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
8825 }
8826
8827 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jint feerate_per_kw_arg) {
8828         LDKThirtyTwoBytes channel_id_arg_ref;
8829         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8830         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8831         LDKUpdateFee ret = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
8832         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8833 }
8834
8835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8836         LDKDataLossProtect this_ptr_conv;
8837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8839         DataLossProtect_free(this_ptr_conv);
8840 }
8841
8842 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8843         LDKDataLossProtect orig_conv;
8844         orig_conv.inner = (void*)(orig & (~1));
8845         orig_conv.is_owned = (orig & 1) || (orig == 0);
8846         LDKDataLossProtect ret = DataLossProtect_clone(&orig_conv);
8847         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8848 }
8849
8850 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
8851         LDKDataLossProtect this_ptr_conv;
8852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8853         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8854         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8855         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
8856         return ret_arr;
8857 }
8858
8859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8860         LDKDataLossProtect this_ptr_conv;
8861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8862         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8863         LDKThirtyTwoBytes val_ref;
8864         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8865         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8866         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
8867 }
8868
8869 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8870         LDKDataLossProtect this_ptr_conv;
8871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8872         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8873         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8874         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
8875         return arg_arr;
8876 }
8877
8878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8879         LDKDataLossProtect this_ptr_conv;
8880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8881         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8882         LDKPublicKey val_ref;
8883         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8884         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8885         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
8886 }
8887
8888 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1new(JNIEnv * _env, jclass _b, jbyteArray your_last_per_commitment_secret_arg, jbyteArray my_current_per_commitment_point_arg) {
8889         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
8890         CHECK((*_env)->GetArrayLength (_env, your_last_per_commitment_secret_arg) == 32);
8891         (*_env)->GetByteArrayRegion (_env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
8892         LDKPublicKey my_current_per_commitment_point_arg_ref;
8893         CHECK((*_env)->GetArrayLength (_env, my_current_per_commitment_point_arg) == 33);
8894         (*_env)->GetByteArrayRegion (_env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
8895         LDKDataLossProtect ret = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
8896         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8897 }
8898
8899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8900         LDKChannelReestablish this_ptr_conv;
8901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8902         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8903         ChannelReestablish_free(this_ptr_conv);
8904 }
8905
8906 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8907         LDKChannelReestablish orig_conv;
8908         orig_conv.inner = (void*)(orig & (~1));
8909         orig_conv.is_owned = (orig & 1) || (orig == 0);
8910         LDKChannelReestablish ret = ChannelReestablish_clone(&orig_conv);
8911         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8912 }
8913
8914 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8915         LDKChannelReestablish this_ptr_conv;
8916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8917         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8918         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8919         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
8920         return ret_arr;
8921 }
8922
8923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8924         LDKChannelReestablish this_ptr_conv;
8925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8926         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8927         LDKThirtyTwoBytes val_ref;
8928         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8929         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8930         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
8931 }
8932
8933 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
8934         LDKChannelReestablish this_ptr_conv;
8935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8936         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8937         jlong ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
8938         return ret_val;
8939 }
8940
8941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8942         LDKChannelReestablish this_ptr_conv;
8943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8944         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8945         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
8946 }
8947
8948 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
8949         LDKChannelReestablish this_ptr_conv;
8950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8951         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8952         jlong ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
8953         return ret_val;
8954 }
8955
8956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8957         LDKChannelReestablish this_ptr_conv;
8958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8959         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8960         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
8961 }
8962
8963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8964         LDKAnnouncementSignatures this_ptr_conv;
8965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8966         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8967         AnnouncementSignatures_free(this_ptr_conv);
8968 }
8969
8970 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8971         LDKAnnouncementSignatures orig_conv;
8972         orig_conv.inner = (void*)(orig & (~1));
8973         orig_conv.is_owned = (orig & 1) || (orig == 0);
8974         LDKAnnouncementSignatures ret = AnnouncementSignatures_clone(&orig_conv);
8975         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8976 }
8977
8978 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8979         LDKAnnouncementSignatures this_ptr_conv;
8980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8981         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8982         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8983         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
8984         return ret_arr;
8985 }
8986
8987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8988         LDKAnnouncementSignatures this_ptr_conv;
8989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8990         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8991         LDKThirtyTwoBytes val_ref;
8992         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8993         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8994         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
8995 }
8996
8997 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8998         LDKAnnouncementSignatures this_ptr_conv;
8999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9000         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9001         jlong ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
9002         return ret_val;
9003 }
9004
9005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9006         LDKAnnouncementSignatures this_ptr_conv;
9007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9008         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9009         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
9010 }
9011
9012 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
9013         LDKAnnouncementSignatures this_ptr_conv;
9014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9015         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9016         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9017         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
9018         return arg_arr;
9019 }
9020
9021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9022         LDKAnnouncementSignatures this_ptr_conv;
9023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9024         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9025         LDKSignature val_ref;
9026         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9027         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9028         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
9029 }
9030
9031 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
9032         LDKAnnouncementSignatures this_ptr_conv;
9033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9034         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9035         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9036         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
9037         return arg_arr;
9038 }
9039
9040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9041         LDKAnnouncementSignatures this_ptr_conv;
9042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9043         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9044         LDKSignature val_ref;
9045         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9046         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9047         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
9048 }
9049
9050 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong short_channel_id_arg, jbyteArray node_signature_arg, jbyteArray bitcoin_signature_arg) {
9051         LDKThirtyTwoBytes channel_id_arg_ref;
9052         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
9053         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
9054         LDKSignature node_signature_arg_ref;
9055         CHECK((*_env)->GetArrayLength (_env, node_signature_arg) == 64);
9056         (*_env)->GetByteArrayRegion (_env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
9057         LDKSignature bitcoin_signature_arg_ref;
9058         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_arg) == 64);
9059         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
9060         LDKAnnouncementSignatures ret = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
9061         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9062 }
9063
9064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9065         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
9066         FREE((void*)this_ptr);
9067         NetAddress_free(this_ptr_conv);
9068 }
9069
9070 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9071         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
9072         LDKNetAddress* ret = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9073         *ret = NetAddress_clone(orig_conv);
9074         return (long)ret;
9075 }
9076
9077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9078         LDKUnsignedNodeAnnouncement this_ptr_conv;
9079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9080         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9081         UnsignedNodeAnnouncement_free(this_ptr_conv);
9082 }
9083
9084 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9085         LDKUnsignedNodeAnnouncement orig_conv;
9086         orig_conv.inner = (void*)(orig & (~1));
9087         orig_conv.is_owned = (orig & 1) || (orig == 0);
9088         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_clone(&orig_conv);
9089         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9090 }
9091
9092 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9093         LDKUnsignedNodeAnnouncement this_ptr_conv;
9094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9095         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9096         LDKNodeFeatures ret = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
9097         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9098 }
9099
9100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9101         LDKUnsignedNodeAnnouncement this_ptr_conv;
9102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9103         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9104         LDKNodeFeatures val_conv;
9105         val_conv.inner = (void*)(val & (~1));
9106         val_conv.is_owned = (val & 1) || (val == 0);
9107         // Warning: we may need a move here but can't clone!
9108         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
9109 }
9110
9111 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
9112         LDKUnsignedNodeAnnouncement this_ptr_conv;
9113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9114         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9115         jint ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
9116         return ret_val;
9117 }
9118
9119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9120         LDKUnsignedNodeAnnouncement this_ptr_conv;
9121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9122         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9123         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
9124 }
9125
9126 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9127         LDKUnsignedNodeAnnouncement this_ptr_conv;
9128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9129         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9130         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9131         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
9132         return arg_arr;
9133 }
9134
9135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9136         LDKUnsignedNodeAnnouncement this_ptr_conv;
9137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9138         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9139         LDKPublicKey val_ref;
9140         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9141         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9142         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
9143 }
9144
9145 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
9146         LDKUnsignedNodeAnnouncement this_ptr_conv;
9147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9148         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9149         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
9150         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
9151         return ret_arr;
9152 }
9153
9154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9155         LDKUnsignedNodeAnnouncement this_ptr_conv;
9156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9157         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9158         LDKThreeBytes val_ref;
9159         CHECK((*_env)->GetArrayLength (_env, val) == 3);
9160         (*_env)->GetByteArrayRegion (_env, val, 0, 3, val_ref.data);
9161         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
9162 }
9163
9164 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
9165         LDKUnsignedNodeAnnouncement this_ptr_conv;
9166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9167         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9168         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9169         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
9170         return ret_arr;
9171 }
9172
9173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9174         LDKUnsignedNodeAnnouncement this_ptr_conv;
9175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9176         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9177         LDKThirtyTwoBytes val_ref;
9178         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9179         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9180         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
9181 }
9182
9183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9184         LDKUnsignedNodeAnnouncement this_ptr_conv;
9185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9186         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9187         LDKCVec_NetAddressZ val_constr;
9188         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9189         if (val_constr.datalen > 0)
9190                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
9191         else
9192                 val_constr.data = NULL;
9193         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9194         for (size_t m = 0; m < val_constr.datalen; m++) {
9195                 long arr_conv_12 = val_vals[m];
9196                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
9197                 FREE((void*)arr_conv_12);
9198                 val_constr.data[m] = arr_conv_12_conv;
9199         }
9200         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
9201         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
9202 }
9203
9204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9205         LDKNodeAnnouncement this_ptr_conv;
9206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9207         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9208         NodeAnnouncement_free(this_ptr_conv);
9209 }
9210
9211 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9212         LDKNodeAnnouncement orig_conv;
9213         orig_conv.inner = (void*)(orig & (~1));
9214         orig_conv.is_owned = (orig & 1) || (orig == 0);
9215         LDKNodeAnnouncement ret = NodeAnnouncement_clone(&orig_conv);
9216         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9217 }
9218
9219 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
9220         LDKNodeAnnouncement this_ptr_conv;
9221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9222         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9223         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9224         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
9225         return arg_arr;
9226 }
9227
9228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9229         LDKNodeAnnouncement this_ptr_conv;
9230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9231         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9232         LDKSignature val_ref;
9233         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9234         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9235         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
9236 }
9237
9238 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9239         LDKNodeAnnouncement this_ptr_conv;
9240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9241         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9242         LDKUnsignedNodeAnnouncement ret = NodeAnnouncement_get_contents(&this_ptr_conv);
9243         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9244 }
9245
9246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9247         LDKNodeAnnouncement this_ptr_conv;
9248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9249         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9250         LDKUnsignedNodeAnnouncement val_conv;
9251         val_conv.inner = (void*)(val & (~1));
9252         val_conv.is_owned = (val & 1) || (val == 0);
9253         if (val_conv.inner != NULL)
9254                 val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
9255         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
9256 }
9257
9258 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv * _env, jclass _b, jbyteArray signature_arg, jlong contents_arg) {
9259         LDKSignature signature_arg_ref;
9260         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
9261         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
9262         LDKUnsignedNodeAnnouncement contents_arg_conv;
9263         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9264         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9265         if (contents_arg_conv.inner != NULL)
9266                 contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
9267         LDKNodeAnnouncement ret = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
9268         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9269 }
9270
9271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9272         LDKUnsignedChannelAnnouncement this_ptr_conv;
9273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9274         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9275         UnsignedChannelAnnouncement_free(this_ptr_conv);
9276 }
9277
9278 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9279         LDKUnsignedChannelAnnouncement orig_conv;
9280         orig_conv.inner = (void*)(orig & (~1));
9281         orig_conv.is_owned = (orig & 1) || (orig == 0);
9282         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_clone(&orig_conv);
9283         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9284 }
9285
9286 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9287         LDKUnsignedChannelAnnouncement this_ptr_conv;
9288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9289         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9290         LDKChannelFeatures ret = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
9291         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9292 }
9293
9294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9295         LDKUnsignedChannelAnnouncement this_ptr_conv;
9296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9297         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9298         LDKChannelFeatures val_conv;
9299         val_conv.inner = (void*)(val & (~1));
9300         val_conv.is_owned = (val & 1) || (val == 0);
9301         // Warning: we may need a move here but can't clone!
9302         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
9303 }
9304
9305 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9306         LDKUnsignedChannelAnnouncement this_ptr_conv;
9307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9308         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9309         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9310         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
9311         return ret_arr;
9312 }
9313
9314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9315         LDKUnsignedChannelAnnouncement this_ptr_conv;
9316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9317         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9318         LDKThirtyTwoBytes val_ref;
9319         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9320         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9321         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
9322 }
9323
9324 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9325         LDKUnsignedChannelAnnouncement this_ptr_conv;
9326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9327         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9328         jlong ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
9329         return ret_val;
9330 }
9331
9332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9333         LDKUnsignedChannelAnnouncement this_ptr_conv;
9334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9335         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9336         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
9337 }
9338
9339 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
9340         LDKUnsignedChannelAnnouncement this_ptr_conv;
9341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9342         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9343         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9344         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
9345         return arg_arr;
9346 }
9347
9348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9349         LDKUnsignedChannelAnnouncement this_ptr_conv;
9350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9351         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9352         LDKPublicKey val_ref;
9353         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9354         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9355         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
9356 }
9357
9358 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
9359         LDKUnsignedChannelAnnouncement this_ptr_conv;
9360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9361         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9362         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9363         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
9364         return arg_arr;
9365 }
9366
9367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9368         LDKUnsignedChannelAnnouncement this_ptr_conv;
9369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9370         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9371         LDKPublicKey val_ref;
9372         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9373         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9374         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
9375 }
9376
9377 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
9378         LDKUnsignedChannelAnnouncement this_ptr_conv;
9379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9380         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9381         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9382         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
9383         return arg_arr;
9384 }
9385
9386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9387         LDKUnsignedChannelAnnouncement this_ptr_conv;
9388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9389         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9390         LDKPublicKey val_ref;
9391         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9392         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9393         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
9394 }
9395
9396 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
9397         LDKUnsignedChannelAnnouncement this_ptr_conv;
9398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9399         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9400         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9401         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
9402         return arg_arr;
9403 }
9404
9405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9406         LDKUnsignedChannelAnnouncement this_ptr_conv;
9407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9408         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9409         LDKPublicKey val_ref;
9410         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9411         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9412         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
9413 }
9414
9415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9416         LDKChannelAnnouncement this_ptr_conv;
9417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9418         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9419         ChannelAnnouncement_free(this_ptr_conv);
9420 }
9421
9422 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9423         LDKChannelAnnouncement orig_conv;
9424         orig_conv.inner = (void*)(orig & (~1));
9425         orig_conv.is_owned = (orig & 1) || (orig == 0);
9426         LDKChannelAnnouncement ret = ChannelAnnouncement_clone(&orig_conv);
9427         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9428 }
9429
9430 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
9431         LDKChannelAnnouncement this_ptr_conv;
9432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9433         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9434         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9435         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
9436         return arg_arr;
9437 }
9438
9439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9440         LDKChannelAnnouncement this_ptr_conv;
9441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9442         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9443         LDKSignature val_ref;
9444         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9445         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9446         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
9447 }
9448
9449 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
9450         LDKChannelAnnouncement this_ptr_conv;
9451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9452         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9453         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9454         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
9455         return arg_arr;
9456 }
9457
9458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9459         LDKChannelAnnouncement this_ptr_conv;
9460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9462         LDKSignature val_ref;
9463         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9464         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9465         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
9466 }
9467
9468 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
9469         LDKChannelAnnouncement this_ptr_conv;
9470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9471         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9472         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9473         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
9474         return arg_arr;
9475 }
9476
9477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9478         LDKChannelAnnouncement this_ptr_conv;
9479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9480         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9481         LDKSignature val_ref;
9482         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9483         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9484         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
9485 }
9486
9487 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
9488         LDKChannelAnnouncement this_ptr_conv;
9489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9490         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9491         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9492         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
9493         return arg_arr;
9494 }
9495
9496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9497         LDKChannelAnnouncement this_ptr_conv;
9498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9499         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9500         LDKSignature val_ref;
9501         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9502         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9503         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
9504 }
9505
9506 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9507         LDKChannelAnnouncement this_ptr_conv;
9508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9509         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9510         LDKUnsignedChannelAnnouncement ret = ChannelAnnouncement_get_contents(&this_ptr_conv);
9511         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9512 }
9513
9514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9515         LDKChannelAnnouncement this_ptr_conv;
9516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9517         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9518         LDKUnsignedChannelAnnouncement val_conv;
9519         val_conv.inner = (void*)(val & (~1));
9520         val_conv.is_owned = (val & 1) || (val == 0);
9521         if (val_conv.inner != NULL)
9522                 val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
9523         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
9524 }
9525
9526 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1new(JNIEnv * _env, jclass _b, jbyteArray node_signature_1_arg, jbyteArray node_signature_2_arg, jbyteArray bitcoin_signature_1_arg, jbyteArray bitcoin_signature_2_arg, jlong contents_arg) {
9527         LDKSignature node_signature_1_arg_ref;
9528         CHECK((*_env)->GetArrayLength (_env, node_signature_1_arg) == 64);
9529         (*_env)->GetByteArrayRegion (_env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
9530         LDKSignature node_signature_2_arg_ref;
9531         CHECK((*_env)->GetArrayLength (_env, node_signature_2_arg) == 64);
9532         (*_env)->GetByteArrayRegion (_env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
9533         LDKSignature bitcoin_signature_1_arg_ref;
9534         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_1_arg) == 64);
9535         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
9536         LDKSignature bitcoin_signature_2_arg_ref;
9537         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_2_arg) == 64);
9538         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
9539         LDKUnsignedChannelAnnouncement contents_arg_conv;
9540         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9541         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9542         if (contents_arg_conv.inner != NULL)
9543                 contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
9544         LDKChannelAnnouncement ret = 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);
9545         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9546 }
9547
9548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9549         LDKUnsignedChannelUpdate this_ptr_conv;
9550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9551         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9552         UnsignedChannelUpdate_free(this_ptr_conv);
9553 }
9554
9555 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9556         LDKUnsignedChannelUpdate orig_conv;
9557         orig_conv.inner = (void*)(orig & (~1));
9558         orig_conv.is_owned = (orig & 1) || (orig == 0);
9559         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_clone(&orig_conv);
9560         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9561 }
9562
9563 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9564         LDKUnsignedChannelUpdate this_ptr_conv;
9565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9566         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9567         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9568         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
9569         return ret_arr;
9570 }
9571
9572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9573         LDKUnsignedChannelUpdate this_ptr_conv;
9574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9575         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9576         LDKThirtyTwoBytes val_ref;
9577         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9578         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9579         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
9580 }
9581
9582 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9583         LDKUnsignedChannelUpdate this_ptr_conv;
9584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9585         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9586         jlong ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
9587         return ret_val;
9588 }
9589
9590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9591         LDKUnsignedChannelUpdate this_ptr_conv;
9592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9593         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9594         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
9595 }
9596
9597 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
9598         LDKUnsignedChannelUpdate this_ptr_conv;
9599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9600         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9601         jint ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
9602         return ret_val;
9603 }
9604
9605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9606         LDKUnsignedChannelUpdate this_ptr_conv;
9607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9608         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9609         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
9610 }
9611
9612 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
9613         LDKUnsignedChannelUpdate this_ptr_conv;
9614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9615         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9616         jbyte ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
9617         return ret_val;
9618 }
9619
9620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
9621         LDKUnsignedChannelUpdate this_ptr_conv;
9622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9623         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9624         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
9625 }
9626
9627 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
9628         LDKUnsignedChannelUpdate this_ptr_conv;
9629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9630         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9631         jshort ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
9632         return ret_val;
9633 }
9634
9635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
9636         LDKUnsignedChannelUpdate this_ptr_conv;
9637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9638         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9639         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
9640 }
9641
9642 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9643         LDKUnsignedChannelUpdate this_ptr_conv;
9644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9645         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9646         jlong ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
9647         return ret_val;
9648 }
9649
9650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9651         LDKUnsignedChannelUpdate this_ptr_conv;
9652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9653         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9654         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
9655 }
9656
9657 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9658         LDKUnsignedChannelUpdate this_ptr_conv;
9659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9660         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9661         jint ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
9662         return ret_val;
9663 }
9664
9665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9666         LDKUnsignedChannelUpdate this_ptr_conv;
9667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9668         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9669         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
9670 }
9671
9672 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
9673         LDKUnsignedChannelUpdate this_ptr_conv;
9674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9675         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9676         jint ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
9677         return ret_val;
9678 }
9679
9680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9681         LDKUnsignedChannelUpdate this_ptr_conv;
9682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9683         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9684         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
9685 }
9686
9687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9688         LDKChannelUpdate this_ptr_conv;
9689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9690         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9691         ChannelUpdate_free(this_ptr_conv);
9692 }
9693
9694 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9695         LDKChannelUpdate orig_conv;
9696         orig_conv.inner = (void*)(orig & (~1));
9697         orig_conv.is_owned = (orig & 1) || (orig == 0);
9698         LDKChannelUpdate ret = ChannelUpdate_clone(&orig_conv);
9699         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9700 }
9701
9702 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
9703         LDKChannelUpdate this_ptr_conv;
9704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9705         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9706         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9707         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
9708         return arg_arr;
9709 }
9710
9711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9712         LDKChannelUpdate this_ptr_conv;
9713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9715         LDKSignature val_ref;
9716         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9717         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9718         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
9719 }
9720
9721 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9722         LDKChannelUpdate this_ptr_conv;
9723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9724         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9725         LDKUnsignedChannelUpdate ret = ChannelUpdate_get_contents(&this_ptr_conv);
9726         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9727 }
9728
9729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9730         LDKChannelUpdate this_ptr_conv;
9731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9732         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9733         LDKUnsignedChannelUpdate val_conv;
9734         val_conv.inner = (void*)(val & (~1));
9735         val_conv.is_owned = (val & 1) || (val == 0);
9736         if (val_conv.inner != NULL)
9737                 val_conv = UnsignedChannelUpdate_clone(&val_conv);
9738         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
9739 }
9740
9741 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv * _env, jclass _b, jbyteArray signature_arg, jlong contents_arg) {
9742         LDKSignature signature_arg_ref;
9743         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
9744         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
9745         LDKUnsignedChannelUpdate contents_arg_conv;
9746         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9747         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9748         if (contents_arg_conv.inner != NULL)
9749                 contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
9750         LDKChannelUpdate ret = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
9751         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9752 }
9753
9754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9755         LDKQueryChannelRange this_ptr_conv;
9756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9757         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9758         QueryChannelRange_free(this_ptr_conv);
9759 }
9760
9761 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9762         LDKQueryChannelRange orig_conv;
9763         orig_conv.inner = (void*)(orig & (~1));
9764         orig_conv.is_owned = (orig & 1) || (orig == 0);
9765         LDKQueryChannelRange ret = QueryChannelRange_clone(&orig_conv);
9766         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9767 }
9768
9769 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9770         LDKQueryChannelRange this_ptr_conv;
9771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9772         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9773         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9774         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
9775         return ret_arr;
9776 }
9777
9778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9779         LDKQueryChannelRange this_ptr_conv;
9780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9781         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9782         LDKThirtyTwoBytes val_ref;
9783         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9784         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9785         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
9786 }
9787
9788 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
9789         LDKQueryChannelRange this_ptr_conv;
9790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9791         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9792         jint ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
9793         return ret_val;
9794 }
9795
9796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9797         LDKQueryChannelRange this_ptr_conv;
9798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9799         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9800         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
9801 }
9802
9803 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
9804         LDKQueryChannelRange this_ptr_conv;
9805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9806         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9807         jint ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
9808         return ret_val;
9809 }
9810
9811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9812         LDKQueryChannelRange this_ptr_conv;
9813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9814         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9815         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
9816 }
9817
9818 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jint first_blocknum_arg, jint number_of_blocks_arg) {
9819         LDKThirtyTwoBytes chain_hash_arg_ref;
9820         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9821         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9822         LDKQueryChannelRange ret = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
9823         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9824 }
9825
9826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9827         LDKReplyChannelRange this_ptr_conv;
9828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9829         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9830         ReplyChannelRange_free(this_ptr_conv);
9831 }
9832
9833 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9834         LDKReplyChannelRange orig_conv;
9835         orig_conv.inner = (void*)(orig & (~1));
9836         orig_conv.is_owned = (orig & 1) || (orig == 0);
9837         LDKReplyChannelRange ret = ReplyChannelRange_clone(&orig_conv);
9838         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9839 }
9840
9841 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9842         LDKReplyChannelRange 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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9846         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
9847         return ret_arr;
9848 }
9849
9850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9851         LDKReplyChannelRange this_ptr_conv;
9852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9853         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9854         LDKThirtyTwoBytes val_ref;
9855         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9856         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9857         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
9858 }
9859
9860 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
9861         LDKReplyChannelRange this_ptr_conv;
9862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9863         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9864         jint ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
9865         return ret_val;
9866 }
9867
9868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9869         LDKReplyChannelRange this_ptr_conv;
9870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9871         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9872         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
9873 }
9874
9875 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
9876         LDKReplyChannelRange this_ptr_conv;
9877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9878         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9879         jint ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
9880         return ret_val;
9881 }
9882
9883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9884         LDKReplyChannelRange this_ptr_conv;
9885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9886         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9887         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
9888 }
9889
9890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
9891         LDKReplyChannelRange this_ptr_conv;
9892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9893         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9894         jboolean ret_val = ReplyChannelRange_get_full_information(&this_ptr_conv);
9895         return ret_val;
9896 }
9897
9898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9899         LDKReplyChannelRange this_ptr_conv;
9900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9901         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9902         ReplyChannelRange_set_full_information(&this_ptr_conv, val);
9903 }
9904
9905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9906         LDKReplyChannelRange this_ptr_conv;
9907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9908         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9909         LDKCVec_u64Z val_constr;
9910         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9911         if (val_constr.datalen > 0)
9912                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9913         else
9914                 val_constr.data = NULL;
9915         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9916         for (size_t g = 0; g < val_constr.datalen; g++) {
9917                 long arr_conv_6 = val_vals[g];
9918                 val_constr.data[g] = arr_conv_6;
9919         }
9920         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
9921         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
9922 }
9923
9924 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jint first_blocknum_arg, jint number_of_blocks_arg, jboolean full_information_arg, jlongArray short_channel_ids_arg) {
9925         LDKThirtyTwoBytes chain_hash_arg_ref;
9926         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9927         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9928         LDKCVec_u64Z short_channel_ids_arg_constr;
9929         short_channel_ids_arg_constr.datalen = (*_env)->GetArrayLength (_env, short_channel_ids_arg);
9930         if (short_channel_ids_arg_constr.datalen > 0)
9931                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9932         else
9933                 short_channel_ids_arg_constr.data = NULL;
9934         long* short_channel_ids_arg_vals = (*_env)->GetLongArrayElements (_env, short_channel_ids_arg, NULL);
9935         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
9936                 long arr_conv_6 = short_channel_ids_arg_vals[g];
9937                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
9938         }
9939         (*_env)->ReleaseLongArrayElements (_env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
9940         LDKReplyChannelRange ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr);
9941         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9942 }
9943
9944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9945         LDKQueryShortChannelIds this_ptr_conv;
9946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9947         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9948         QueryShortChannelIds_free(this_ptr_conv);
9949 }
9950
9951 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9952         LDKQueryShortChannelIds orig_conv;
9953         orig_conv.inner = (void*)(orig & (~1));
9954         orig_conv.is_owned = (orig & 1) || (orig == 0);
9955         LDKQueryShortChannelIds ret = QueryShortChannelIds_clone(&orig_conv);
9956         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9957 }
9958
9959 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9960         LDKQueryShortChannelIds this_ptr_conv;
9961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9962         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9963         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9964         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
9965         return ret_arr;
9966 }
9967
9968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9969         LDKQueryShortChannelIds this_ptr_conv;
9970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9971         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9972         LDKThirtyTwoBytes val_ref;
9973         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9974         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9975         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
9976 }
9977
9978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9979         LDKQueryShortChannelIds this_ptr_conv;
9980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9981         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9982         LDKCVec_u64Z val_constr;
9983         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9984         if (val_constr.datalen > 0)
9985                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9986         else
9987                 val_constr.data = NULL;
9988         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9989         for (size_t g = 0; g < val_constr.datalen; g++) {
9990                 long arr_conv_6 = val_vals[g];
9991                 val_constr.data[g] = arr_conv_6;
9992         }
9993         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
9994         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
9995 }
9996
9997 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlongArray short_channel_ids_arg) {
9998         LDKThirtyTwoBytes chain_hash_arg_ref;
9999         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
10000         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
10001         LDKCVec_u64Z short_channel_ids_arg_constr;
10002         short_channel_ids_arg_constr.datalen = (*_env)->GetArrayLength (_env, short_channel_ids_arg);
10003         if (short_channel_ids_arg_constr.datalen > 0)
10004                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
10005         else
10006                 short_channel_ids_arg_constr.data = NULL;
10007         long* short_channel_ids_arg_vals = (*_env)->GetLongArrayElements (_env, short_channel_ids_arg, NULL);
10008         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
10009                 long arr_conv_6 = short_channel_ids_arg_vals[g];
10010                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
10011         }
10012         (*_env)->ReleaseLongArrayElements (_env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
10013         LDKQueryShortChannelIds ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
10014         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10015 }
10016
10017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10018         LDKReplyShortChannelIdsEnd this_ptr_conv;
10019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10020         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10021         ReplyShortChannelIdsEnd_free(this_ptr_conv);
10022 }
10023
10024 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10025         LDKReplyShortChannelIdsEnd orig_conv;
10026         orig_conv.inner = (void*)(orig & (~1));
10027         orig_conv.is_owned = (orig & 1) || (orig == 0);
10028         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_clone(&orig_conv);
10029         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10030 }
10031
10032 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
10033         LDKReplyShortChannelIdsEnd this_ptr_conv;
10034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10035         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10036         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
10037         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
10038         return ret_arr;
10039 }
10040
10041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10042         LDKReplyShortChannelIdsEnd this_ptr_conv;
10043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10044         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10045         LDKThirtyTwoBytes val_ref;
10046         CHECK((*_env)->GetArrayLength (_env, val) == 32);
10047         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
10048         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
10049 }
10050
10051 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
10052         LDKReplyShortChannelIdsEnd this_ptr_conv;
10053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10054         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10055         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
10056         return ret_val;
10057 }
10058
10059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
10060         LDKReplyShortChannelIdsEnd this_ptr_conv;
10061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10062         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10063         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
10064 }
10065
10066 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jboolean full_information_arg) {
10067         LDKThirtyTwoBytes chain_hash_arg_ref;
10068         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
10069         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
10070         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
10071         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10072 }
10073
10074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10075         LDKGossipTimestampFilter this_ptr_conv;
10076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10077         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10078         GossipTimestampFilter_free(this_ptr_conv);
10079 }
10080
10081 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10082         LDKGossipTimestampFilter orig_conv;
10083         orig_conv.inner = (void*)(orig & (~1));
10084         orig_conv.is_owned = (orig & 1) || (orig == 0);
10085         LDKGossipTimestampFilter ret = GossipTimestampFilter_clone(&orig_conv);
10086         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10087 }
10088
10089 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
10090         LDKGossipTimestampFilter this_ptr_conv;
10091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10092         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10093         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
10094         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
10095         return ret_arr;
10096 }
10097
10098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10099         LDKGossipTimestampFilter this_ptr_conv;
10100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10101         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10102         LDKThirtyTwoBytes val_ref;
10103         CHECK((*_env)->GetArrayLength (_env, val) == 32);
10104         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
10105         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
10106 }
10107
10108 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
10109         LDKGossipTimestampFilter this_ptr_conv;
10110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10111         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10112         jint ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
10113         return ret_val;
10114 }
10115
10116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10117         LDKGossipTimestampFilter this_ptr_conv;
10118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10119         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10120         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
10121 }
10122
10123 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr) {
10124         LDKGossipTimestampFilter this_ptr_conv;
10125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10126         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10127         jint ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
10128         return ret_val;
10129 }
10130
10131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10132         LDKGossipTimestampFilter this_ptr_conv;
10133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10134         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10135         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
10136 }
10137
10138 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jint first_timestamp_arg, jint timestamp_range_arg) {
10139         LDKThirtyTwoBytes chain_hash_arg_ref;
10140         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
10141         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
10142         LDKGossipTimestampFilter ret = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
10143         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10144 }
10145
10146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10147         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
10148         FREE((void*)this_ptr);
10149         ErrorAction_free(this_ptr_conv);
10150 }
10151
10152 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10153         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
10154         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10155         *ret = ErrorAction_clone(orig_conv);
10156         return (long)ret;
10157 }
10158
10159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10160         LDKLightningError this_ptr_conv;
10161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10162         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10163         LightningError_free(this_ptr_conv);
10164 }
10165
10166 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) {
10167         LDKLightningError this_ptr_conv;
10168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10169         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10170         LDKStr _str = LightningError_get_err(&this_ptr_conv);
10171         char* _buf = MALLOC(_str.len + 1, "str conv buf");
10172         memcpy(_buf, _str.chars, _str.len);
10173         _buf[_str.len] = 0;
10174         jstring _conv = (*_env)->NewStringUTF(_env, _str.chars);
10175         FREE(_buf);
10176         return _conv;
10177 }
10178
10179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10180         LDKLightningError this_ptr_conv;
10181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10182         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10183         LDKCVec_u8Z val_ref;
10184         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
10185         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
10186         LightningError_set_err(&this_ptr_conv, val_ref);
10187         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
10188 }
10189
10190 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv * _env, jclass _b, jlong this_ptr) {
10191         LDKLightningError this_ptr_conv;
10192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10193         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10194         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10195         *ret = LightningError_get_action(&this_ptr_conv);
10196         return (long)ret;
10197 }
10198
10199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10200         LDKLightningError this_ptr_conv;
10201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10202         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10203         LDKErrorAction val_conv = *(LDKErrorAction*)val;
10204         FREE((void*)val);
10205         LightningError_set_action(&this_ptr_conv, val_conv);
10206 }
10207
10208 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv * _env, jclass _b, jbyteArray err_arg, jlong action_arg) {
10209         LDKCVec_u8Z err_arg_ref;
10210         err_arg_ref.data = (*_env)->GetByteArrayElements (_env, err_arg, NULL);
10211         err_arg_ref.datalen = (*_env)->GetArrayLength (_env, err_arg);
10212         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
10213         FREE((void*)action_arg);
10214         LDKLightningError ret = LightningError_new(err_arg_ref, action_arg_conv);
10215         (*_env)->ReleaseByteArrayElements(_env, err_arg, (int8_t*)err_arg_ref.data, 0);
10216         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10217 }
10218
10219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10220         LDKCommitmentUpdate this_ptr_conv;
10221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10222         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10223         CommitmentUpdate_free(this_ptr_conv);
10224 }
10225
10226 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10227         LDKCommitmentUpdate orig_conv;
10228         orig_conv.inner = (void*)(orig & (~1));
10229         orig_conv.is_owned = (orig & 1) || (orig == 0);
10230         LDKCommitmentUpdate ret = CommitmentUpdate_clone(&orig_conv);
10231         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10232 }
10233
10234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10235         LDKCommitmentUpdate this_ptr_conv;
10236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10237         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10238         LDKCVec_UpdateAddHTLCZ val_constr;
10239         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10240         if (val_constr.datalen > 0)
10241                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10242         else
10243                 val_constr.data = NULL;
10244         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10245         for (size_t p = 0; p < val_constr.datalen; p++) {
10246                 long arr_conv_15 = val_vals[p];
10247                 LDKUpdateAddHTLC arr_conv_15_conv;
10248                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10249                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10250                 if (arr_conv_15_conv.inner != NULL)
10251                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10252                 val_constr.data[p] = arr_conv_15_conv;
10253         }
10254         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10255         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
10256 }
10257
10258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10259         LDKCommitmentUpdate this_ptr_conv;
10260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10261         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10262         LDKCVec_UpdateFulfillHTLCZ val_constr;
10263         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10264         if (val_constr.datalen > 0)
10265                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10266         else
10267                 val_constr.data = NULL;
10268         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10269         for (size_t t = 0; t < val_constr.datalen; t++) {
10270                 long arr_conv_19 = val_vals[t];
10271                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10272                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
10273                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
10274                 if (arr_conv_19_conv.inner != NULL)
10275                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
10276                 val_constr.data[t] = arr_conv_19_conv;
10277         }
10278         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10279         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
10280 }
10281
10282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10283         LDKCommitmentUpdate this_ptr_conv;
10284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10285         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10286         LDKCVec_UpdateFailHTLCZ val_constr;
10287         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10288         if (val_constr.datalen > 0)
10289                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10290         else
10291                 val_constr.data = NULL;
10292         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10293         for (size_t q = 0; q < val_constr.datalen; q++) {
10294                 long arr_conv_16 = val_vals[q];
10295                 LDKUpdateFailHTLC arr_conv_16_conv;
10296                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
10297                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
10298                 if (arr_conv_16_conv.inner != NULL)
10299                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
10300                 val_constr.data[q] = arr_conv_16_conv;
10301         }
10302         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10303         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
10304 }
10305
10306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10307         LDKCommitmentUpdate this_ptr_conv;
10308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10309         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10310         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
10311         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10312         if (val_constr.datalen > 0)
10313                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10314         else
10315                 val_constr.data = NULL;
10316         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10317         for (size_t z = 0; z < val_constr.datalen; z++) {
10318                 long arr_conv_25 = val_vals[z];
10319                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
10320                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
10321                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
10322                 if (arr_conv_25_conv.inner != NULL)
10323                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
10324                 val_constr.data[z] = arr_conv_25_conv;
10325         }
10326         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10327         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
10328 }
10329
10330 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr) {
10331         LDKCommitmentUpdate this_ptr_conv;
10332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10333         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10334         LDKUpdateFee ret = CommitmentUpdate_get_update_fee(&this_ptr_conv);
10335         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10336 }
10337
10338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10339         LDKCommitmentUpdate this_ptr_conv;
10340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10341         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10342         LDKUpdateFee val_conv;
10343         val_conv.inner = (void*)(val & (~1));
10344         val_conv.is_owned = (val & 1) || (val == 0);
10345         if (val_conv.inner != NULL)
10346                 val_conv = UpdateFee_clone(&val_conv);
10347         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
10348 }
10349
10350 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr) {
10351         LDKCommitmentUpdate this_ptr_conv;
10352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10353         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10354         LDKCommitmentSigned ret = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
10355         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10356 }
10357
10358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10359         LDKCommitmentUpdate this_ptr_conv;
10360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10361         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10362         LDKCommitmentSigned val_conv;
10363         val_conv.inner = (void*)(val & (~1));
10364         val_conv.is_owned = (val & 1) || (val == 0);
10365         if (val_conv.inner != NULL)
10366                 val_conv = CommitmentSigned_clone(&val_conv);
10367         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
10368 }
10369
10370 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv * _env, jclass _b, jlongArray update_add_htlcs_arg, jlongArray update_fulfill_htlcs_arg, jlongArray update_fail_htlcs_arg, jlongArray update_fail_malformed_htlcs_arg, jlong update_fee_arg, jlong commitment_signed_arg) {
10371         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
10372         update_add_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_add_htlcs_arg);
10373         if (update_add_htlcs_arg_constr.datalen > 0)
10374                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10375         else
10376                 update_add_htlcs_arg_constr.data = NULL;
10377         long* update_add_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_add_htlcs_arg, NULL);
10378         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
10379                 long arr_conv_15 = update_add_htlcs_arg_vals[p];
10380                 LDKUpdateAddHTLC arr_conv_15_conv;
10381                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10382                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10383                 if (arr_conv_15_conv.inner != NULL)
10384                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10385                 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
10386         }
10387         (*_env)->ReleaseLongArrayElements (_env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
10388         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
10389         update_fulfill_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fulfill_htlcs_arg);
10390         if (update_fulfill_htlcs_arg_constr.datalen > 0)
10391                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10392         else
10393                 update_fulfill_htlcs_arg_constr.data = NULL;
10394         long* update_fulfill_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fulfill_htlcs_arg, NULL);
10395         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
10396                 long arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
10397                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10398                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
10399                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
10400                 if (arr_conv_19_conv.inner != NULL)
10401                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
10402                 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
10403         }
10404         (*_env)->ReleaseLongArrayElements (_env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
10405         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
10406         update_fail_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fail_htlcs_arg);
10407         if (update_fail_htlcs_arg_constr.datalen > 0)
10408                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10409         else
10410                 update_fail_htlcs_arg_constr.data = NULL;
10411         long* update_fail_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fail_htlcs_arg, NULL);
10412         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
10413                 long arr_conv_16 = update_fail_htlcs_arg_vals[q];
10414                 LDKUpdateFailHTLC arr_conv_16_conv;
10415                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
10416                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
10417                 if (arr_conv_16_conv.inner != NULL)
10418                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
10419                 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
10420         }
10421         (*_env)->ReleaseLongArrayElements (_env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
10422         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
10423         update_fail_malformed_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fail_malformed_htlcs_arg);
10424         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
10425                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10426         else
10427                 update_fail_malformed_htlcs_arg_constr.data = NULL;
10428         long* update_fail_malformed_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fail_malformed_htlcs_arg, NULL);
10429         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
10430                 long arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
10431                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
10432                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
10433                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
10434                 if (arr_conv_25_conv.inner != NULL)
10435                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
10436                 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
10437         }
10438         (*_env)->ReleaseLongArrayElements (_env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
10439         LDKUpdateFee update_fee_arg_conv;
10440         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
10441         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
10442         if (update_fee_arg_conv.inner != NULL)
10443                 update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
10444         LDKCommitmentSigned commitment_signed_arg_conv;
10445         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
10446         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
10447         if (commitment_signed_arg_conv.inner != NULL)
10448                 commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
10449         LDKCommitmentUpdate ret = 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);
10450         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10451 }
10452
10453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10454         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
10455         FREE((void*)this_ptr);
10456         HTLCFailChannelUpdate_free(this_ptr_conv);
10457 }
10458
10459 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10460         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
10461         LDKHTLCFailChannelUpdate* ret = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
10462         *ret = HTLCFailChannelUpdate_clone(orig_conv);
10463         return (long)ret;
10464 }
10465
10466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10467         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
10468         FREE((void*)this_ptr);
10469         ChannelMessageHandler_free(this_ptr_conv);
10470 }
10471
10472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10473         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
10474         FREE((void*)this_ptr);
10475         RoutingMessageHandler_free(this_ptr_conv);
10476 }
10477
10478 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
10479         LDKAcceptChannel obj_conv;
10480         obj_conv.inner = (void*)(obj & (~1));
10481         obj_conv.is_owned = (obj & 1) || (obj == 0);
10482         LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
10483         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10484         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10485         CVec_u8Z_free(arg_var);
10486         return arg_arr;
10487 }
10488
10489 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10490         LDKu8slice ser_ref;
10491         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10492         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10493         LDKAcceptChannel ret = AcceptChannel_read(ser_ref);
10494         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10495         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10496 }
10497
10498 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv * _env, jclass _b, jlong obj) {
10499         LDKAnnouncementSignatures obj_conv;
10500         obj_conv.inner = (void*)(obj & (~1));
10501         obj_conv.is_owned = (obj & 1) || (obj == 0);
10502         LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
10503         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10504         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10505         CVec_u8Z_free(arg_var);
10506         return arg_arr;
10507 }
10508
10509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10510         LDKu8slice ser_ref;
10511         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10512         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10513         LDKAnnouncementSignatures ret = AnnouncementSignatures_read(ser_ref);
10514         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10515         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10516 }
10517
10518 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv * _env, jclass _b, jlong obj) {
10519         LDKChannelReestablish obj_conv;
10520         obj_conv.inner = (void*)(obj & (~1));
10521         obj_conv.is_owned = (obj & 1) || (obj == 0);
10522         LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
10523         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10524         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10525         CVec_u8Z_free(arg_var);
10526         return arg_arr;
10527 }
10528
10529 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10530         LDKu8slice ser_ref;
10531         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10532         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10533         LDKChannelReestablish ret = ChannelReestablish_read(ser_ref);
10534         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10535         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10536 }
10537
10538 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10539         LDKClosingSigned obj_conv;
10540         obj_conv.inner = (void*)(obj & (~1));
10541         obj_conv.is_owned = (obj & 1) || (obj == 0);
10542         LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
10543         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10544         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10545         CVec_u8Z_free(arg_var);
10546         return arg_arr;
10547 }
10548
10549 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10550         LDKu8slice ser_ref;
10551         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10552         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10553         LDKClosingSigned ret = ClosingSigned_read(ser_ref);
10554         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10555         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10556 }
10557
10558 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10559         LDKCommitmentSigned obj_conv;
10560         obj_conv.inner = (void*)(obj & (~1));
10561         obj_conv.is_owned = (obj & 1) || (obj == 0);
10562         LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
10563         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10564         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10565         CVec_u8Z_free(arg_var);
10566         return arg_arr;
10567 }
10568
10569 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10570         LDKu8slice ser_ref;
10571         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10572         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10573         LDKCommitmentSigned ret = CommitmentSigned_read(ser_ref);
10574         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10575         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10576 }
10577
10578 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv * _env, jclass _b, jlong obj) {
10579         LDKFundingCreated obj_conv;
10580         obj_conv.inner = (void*)(obj & (~1));
10581         obj_conv.is_owned = (obj & 1) || (obj == 0);
10582         LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
10583         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10584         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10585         CVec_u8Z_free(arg_var);
10586         return arg_arr;
10587 }
10588
10589 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10590         LDKu8slice ser_ref;
10591         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10592         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10593         LDKFundingCreated ret = FundingCreated_read(ser_ref);
10594         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10595         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10596 }
10597
10598 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10599         LDKFundingSigned obj_conv;
10600         obj_conv.inner = (void*)(obj & (~1));
10601         obj_conv.is_owned = (obj & 1) || (obj == 0);
10602         LDKCVec_u8Z arg_var = FundingSigned_write(&obj_conv);
10603         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10604         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10605         CVec_u8Z_free(arg_var);
10606         return arg_arr;
10607 }
10608
10609 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10610         LDKu8slice ser_ref;
10611         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10612         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10613         LDKFundingSigned ret = FundingSigned_read(ser_ref);
10614         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10615         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10616 }
10617
10618 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv * _env, jclass _b, jlong obj) {
10619         LDKFundingLocked obj_conv;
10620         obj_conv.inner = (void*)(obj & (~1));
10621         obj_conv.is_owned = (obj & 1) || (obj == 0);
10622         LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
10623         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10624         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10625         CVec_u8Z_free(arg_var);
10626         return arg_arr;
10627 }
10628
10629 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10630         LDKu8slice ser_ref;
10631         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10632         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10633         LDKFundingLocked ret = FundingLocked_read(ser_ref);
10634         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10635         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10636 }
10637
10638 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv * _env, jclass _b, jlong obj) {
10639         LDKInit obj_conv;
10640         obj_conv.inner = (void*)(obj & (~1));
10641         obj_conv.is_owned = (obj & 1) || (obj == 0);
10642         LDKCVec_u8Z arg_var = Init_write(&obj_conv);
10643         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10644         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10645         CVec_u8Z_free(arg_var);
10646         return arg_arr;
10647 }
10648
10649 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10650         LDKu8slice ser_ref;
10651         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10652         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10653         LDKInit ret = Init_read(ser_ref);
10654         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10655         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10656 }
10657
10658 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
10659         LDKOpenChannel obj_conv;
10660         obj_conv.inner = (void*)(obj & (~1));
10661         obj_conv.is_owned = (obj & 1) || (obj == 0);
10662         LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
10663         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10664         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10665         CVec_u8Z_free(arg_var);
10666         return arg_arr;
10667 }
10668
10669 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10670         LDKu8slice ser_ref;
10671         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10672         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10673         LDKOpenChannel ret = OpenChannel_read(ser_ref);
10674         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10675         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10676 }
10677
10678 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv * _env, jclass _b, jlong obj) {
10679         LDKRevokeAndACK obj_conv;
10680         obj_conv.inner = (void*)(obj & (~1));
10681         obj_conv.is_owned = (obj & 1) || (obj == 0);
10682         LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
10683         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10684         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10685         CVec_u8Z_free(arg_var);
10686         return arg_arr;
10687 }
10688
10689 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10690         LDKu8slice ser_ref;
10691         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10692         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10693         LDKRevokeAndACK ret = RevokeAndACK_read(ser_ref);
10694         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10695         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10696 }
10697
10698 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv * _env, jclass _b, jlong obj) {
10699         LDKShutdown obj_conv;
10700         obj_conv.inner = (void*)(obj & (~1));
10701         obj_conv.is_owned = (obj & 1) || (obj == 0);
10702         LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
10703         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10704         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10705         CVec_u8Z_free(arg_var);
10706         return arg_arr;
10707 }
10708
10709 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10710         LDKu8slice ser_ref;
10711         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10712         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10713         LDKShutdown ret = Shutdown_read(ser_ref);
10714         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10715         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10716 }
10717
10718 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10719         LDKUpdateFailHTLC obj_conv;
10720         obj_conv.inner = (void*)(obj & (~1));
10721         obj_conv.is_owned = (obj & 1) || (obj == 0);
10722         LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
10723         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10724         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10725         CVec_u8Z_free(arg_var);
10726         return arg_arr;
10727 }
10728
10729 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10730         LDKu8slice ser_ref;
10731         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10732         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10733         LDKUpdateFailHTLC ret = UpdateFailHTLC_read(ser_ref);
10734         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10735         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10736 }
10737
10738 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10739         LDKUpdateFailMalformedHTLC obj_conv;
10740         obj_conv.inner = (void*)(obj & (~1));
10741         obj_conv.is_owned = (obj & 1) || (obj == 0);
10742         LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
10743         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10744         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10745         CVec_u8Z_free(arg_var);
10746         return arg_arr;
10747 }
10748
10749 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10750         LDKu8slice ser_ref;
10751         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10752         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10753         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_read(ser_ref);
10754         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10755         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10756 }
10757
10758 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv * _env, jclass _b, jlong obj) {
10759         LDKUpdateFee obj_conv;
10760         obj_conv.inner = (void*)(obj & (~1));
10761         obj_conv.is_owned = (obj & 1) || (obj == 0);
10762         LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
10763         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10764         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10765         CVec_u8Z_free(arg_var);
10766         return arg_arr;
10767 }
10768
10769 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10770         LDKu8slice ser_ref;
10771         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10772         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10773         LDKUpdateFee ret = UpdateFee_read(ser_ref);
10774         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10775         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10776 }
10777
10778 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10779         LDKUpdateFulfillHTLC obj_conv;
10780         obj_conv.inner = (void*)(obj & (~1));
10781         obj_conv.is_owned = (obj & 1) || (obj == 0);
10782         LDKCVec_u8Z arg_var = UpdateFulfillHTLC_write(&obj_conv);
10783         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10784         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10785         CVec_u8Z_free(arg_var);
10786         return arg_arr;
10787 }
10788
10789 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10790         LDKu8slice ser_ref;
10791         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10792         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10793         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_read(ser_ref);
10794         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10795         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10796 }
10797
10798 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10799         LDKUpdateAddHTLC obj_conv;
10800         obj_conv.inner = (void*)(obj & (~1));
10801         obj_conv.is_owned = (obj & 1) || (obj == 0);
10802         LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
10803         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10804         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10805         CVec_u8Z_free(arg_var);
10806         return arg_arr;
10807 }
10808
10809 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10810         LDKu8slice ser_ref;
10811         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10812         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10813         LDKUpdateAddHTLC ret = UpdateAddHTLC_read(ser_ref);
10814         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10815         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10816 }
10817
10818 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv * _env, jclass _b, jlong obj) {
10819         LDKPing obj_conv;
10820         obj_conv.inner = (void*)(obj & (~1));
10821         obj_conv.is_owned = (obj & 1) || (obj == 0);
10822         LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
10823         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10824         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10825         CVec_u8Z_free(arg_var);
10826         return arg_arr;
10827 }
10828
10829 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10830         LDKu8slice ser_ref;
10831         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10832         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10833         LDKPing ret = Ping_read(ser_ref);
10834         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10835         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10836 }
10837
10838 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv * _env, jclass _b, jlong obj) {
10839         LDKPong obj_conv;
10840         obj_conv.inner = (void*)(obj & (~1));
10841         obj_conv.is_owned = (obj & 1) || (obj == 0);
10842         LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
10843         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10844         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10845         CVec_u8Z_free(arg_var);
10846         return arg_arr;
10847 }
10848
10849 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10850         LDKu8slice ser_ref;
10851         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10852         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10853         LDKPong ret = Pong_read(ser_ref);
10854         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10855         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10856 }
10857
10858 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10859         LDKUnsignedChannelAnnouncement obj_conv;
10860         obj_conv.inner = (void*)(obj & (~1));
10861         obj_conv.is_owned = (obj & 1) || (obj == 0);
10862         LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_write(&obj_conv);
10863         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10864         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10865         CVec_u8Z_free(arg_var);
10866         return arg_arr;
10867 }
10868
10869 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10870         LDKu8slice ser_ref;
10871         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10872         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10873         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_read(ser_ref);
10874         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10875         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10876 }
10877
10878 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10879         LDKChannelAnnouncement obj_conv;
10880         obj_conv.inner = (void*)(obj & (~1));
10881         obj_conv.is_owned = (obj & 1) || (obj == 0);
10882         LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
10883         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10884         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10885         CVec_u8Z_free(arg_var);
10886         return arg_arr;
10887 }
10888
10889 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10890         LDKu8slice ser_ref;
10891         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10892         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10893         LDKChannelAnnouncement ret = ChannelAnnouncement_read(ser_ref);
10894         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10895         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10896 }
10897
10898 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
10899         LDKUnsignedChannelUpdate obj_conv;
10900         obj_conv.inner = (void*)(obj & (~1));
10901         obj_conv.is_owned = (obj & 1) || (obj == 0);
10902         LDKCVec_u8Z arg_var = UnsignedChannelUpdate_write(&obj_conv);
10903         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10904         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10905         CVec_u8Z_free(arg_var);
10906         return arg_arr;
10907 }
10908
10909 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10910         LDKu8slice ser_ref;
10911         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10912         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10913         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_read(ser_ref);
10914         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10915         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10916 }
10917
10918 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
10919         LDKChannelUpdate obj_conv;
10920         obj_conv.inner = (void*)(obj & (~1));
10921         obj_conv.is_owned = (obj & 1) || (obj == 0);
10922         LDKCVec_u8Z arg_var = ChannelUpdate_write(&obj_conv);
10923         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10924         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10925         CVec_u8Z_free(arg_var);
10926         return arg_arr;
10927 }
10928
10929 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10930         LDKu8slice ser_ref;
10931         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10932         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10933         LDKChannelUpdate ret = ChannelUpdate_read(ser_ref);
10934         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10935         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10936 }
10937
10938 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv * _env, jclass _b, jlong obj) {
10939         LDKErrorMessage obj_conv;
10940         obj_conv.inner = (void*)(obj & (~1));
10941         obj_conv.is_owned = (obj & 1) || (obj == 0);
10942         LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
10943         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10944         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10945         CVec_u8Z_free(arg_var);
10946         return arg_arr;
10947 }
10948
10949 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10950         LDKu8slice ser_ref;
10951         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10952         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10953         LDKErrorMessage ret = ErrorMessage_read(ser_ref);
10954         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10955         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10956 }
10957
10958 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10959         LDKUnsignedNodeAnnouncement obj_conv;
10960         obj_conv.inner = (void*)(obj & (~1));
10961         obj_conv.is_owned = (obj & 1) || (obj == 0);
10962         LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_write(&obj_conv);
10963         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10964         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10965         CVec_u8Z_free(arg_var);
10966         return arg_arr;
10967 }
10968
10969 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10970         LDKu8slice ser_ref;
10971         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10972         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10973         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_read(ser_ref);
10974         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10975         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10976 }
10977
10978 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10979         LDKNodeAnnouncement obj_conv;
10980         obj_conv.inner = (void*)(obj & (~1));
10981         obj_conv.is_owned = (obj & 1) || (obj == 0);
10982         LDKCVec_u8Z arg_var = NodeAnnouncement_write(&obj_conv);
10983         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10984         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10985         CVec_u8Z_free(arg_var);
10986         return arg_arr;
10987 }
10988
10989 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10990         LDKu8slice ser_ref;
10991         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10992         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10993         LDKNodeAnnouncement ret = NodeAnnouncement_read(ser_ref);
10994         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10995         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10996 }
10997
10998 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10999         LDKu8slice ser_ref;
11000         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11001         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11002         LDKQueryShortChannelIds ret = QueryShortChannelIds_read(ser_ref);
11003         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11004         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11005 }
11006
11007 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv * _env, jclass _b, jlong obj) {
11008         LDKQueryShortChannelIds obj_conv;
11009         obj_conv.inner = (void*)(obj & (~1));
11010         obj_conv.is_owned = (obj & 1) || (obj == 0);
11011         LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
11012         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11013         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11014         CVec_u8Z_free(arg_var);
11015         return arg_arr;
11016 }
11017
11018 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11019         LDKu8slice ser_ref;
11020         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11021         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11022         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_read(ser_ref);
11023         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11024         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11025 }
11026
11027 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv * _env, jclass _b, jlong obj) {
11028         LDKReplyShortChannelIdsEnd obj_conv;
11029         obj_conv.inner = (void*)(obj & (~1));
11030         obj_conv.is_owned = (obj & 1) || (obj == 0);
11031         LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
11032         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11033         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11034         CVec_u8Z_free(arg_var);
11035         return arg_arr;
11036 }
11037
11038 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11039         LDKu8slice ser_ref;
11040         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11041         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11042         LDKQueryChannelRange ret = QueryChannelRange_read(ser_ref);
11043         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11044         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11045 }
11046
11047 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
11048         LDKQueryChannelRange obj_conv;
11049         obj_conv.inner = (void*)(obj & (~1));
11050         obj_conv.is_owned = (obj & 1) || (obj == 0);
11051         LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
11052         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11053         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11054         CVec_u8Z_free(arg_var);
11055         return arg_arr;
11056 }
11057
11058 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11059         LDKu8slice ser_ref;
11060         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11061         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11062         LDKReplyChannelRange ret = ReplyChannelRange_read(ser_ref);
11063         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11064         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11065 }
11066
11067 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
11068         LDKReplyChannelRange obj_conv;
11069         obj_conv.inner = (void*)(obj & (~1));
11070         obj_conv.is_owned = (obj & 1) || (obj == 0);
11071         LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
11072         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11073         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11074         CVec_u8Z_free(arg_var);
11075         return arg_arr;
11076 }
11077
11078 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11079         LDKu8slice ser_ref;
11080         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11081         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11082         LDKGossipTimestampFilter ret = GossipTimestampFilter_read(ser_ref);
11083         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11084         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11085 }
11086
11087 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv * _env, jclass _b, jlong obj) {
11088         LDKGossipTimestampFilter obj_conv;
11089         obj_conv.inner = (void*)(obj & (~1));
11090         obj_conv.is_owned = (obj & 1) || (obj == 0);
11091         LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
11092         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11093         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11094         CVec_u8Z_free(arg_var);
11095         return arg_arr;
11096 }
11097
11098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11099         LDKMessageHandler this_ptr_conv;
11100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11101         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11102         MessageHandler_free(this_ptr_conv);
11103 }
11104
11105 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
11106         LDKMessageHandler this_ptr_conv;
11107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11108         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11109         long ret_ = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
11110         return ret_;
11111 }
11112
11113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11114         LDKMessageHandler this_ptr_conv;
11115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11116         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11117         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
11118         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
11119                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11120                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
11121         }
11122         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
11123 }
11124
11125 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
11126         LDKMessageHandler this_ptr_conv;
11127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11128         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11129         long ret_ = (long)MessageHandler_get_route_handler(&this_ptr_conv);
11130         return ret_;
11131 }
11132
11133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11134         LDKMessageHandler this_ptr_conv;
11135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11136         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11137         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
11138         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11139                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11140                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
11141         }
11142         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
11143 }
11144
11145 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv * _env, jclass _b, jlong chan_handler_arg, jlong route_handler_arg) {
11146         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
11147         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
11148                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11149                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
11150         }
11151         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
11152         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11153                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11154                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
11155         }
11156         LDKMessageHandler ret = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
11157         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11158 }
11159
11160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11161         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
11162         FREE((void*)this_ptr);
11163         SocketDescriptor_free(this_ptr_conv);
11164 }
11165
11166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11167         LDKPeerHandleError this_ptr_conv;
11168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11169         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11170         PeerHandleError_free(this_ptr_conv);
11171 }
11172
11173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr) {
11174         LDKPeerHandleError this_ptr_conv;
11175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11176         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11177         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
11178         return ret_val;
11179 }
11180
11181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
11182         LDKPeerHandleError this_ptr_conv;
11183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11184         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11185         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
11186 }
11187
11188 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv * _env, jclass _b, jboolean no_connection_possible_arg) {
11189         LDKPeerHandleError ret = PeerHandleError_new(no_connection_possible_arg);
11190         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11191 }
11192
11193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11194         LDKPeerManager this_ptr_conv;
11195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11196         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11197         PeerManager_free(this_ptr_conv);
11198 }
11199
11200 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv * _env, jclass _b, jlong message_handler, jbyteArray our_node_secret, jbyteArray ephemeral_random_data, jlong logger) {
11201         LDKMessageHandler message_handler_conv;
11202         message_handler_conv.inner = (void*)(message_handler & (~1));
11203         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
11204         // Warning: we may need a move here but can't clone!
11205         LDKSecretKey our_node_secret_ref;
11206         CHECK((*_env)->GetArrayLength (_env, our_node_secret) == 32);
11207         (*_env)->GetByteArrayRegion (_env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
11208         unsigned char ephemeral_random_data_arr[32];
11209         CHECK((*_env)->GetArrayLength (_env, ephemeral_random_data) == 32);
11210         (*_env)->GetByteArrayRegion (_env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
11211         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
11212         LDKLogger logger_conv = *(LDKLogger*)logger;
11213         if (logger_conv.free == LDKLogger_JCalls_free) {
11214                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11215                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11216         }
11217         LDKPeerManager ret = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
11218         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11219 }
11220
11221 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) {
11222         LDKPeerManager this_arg_conv;
11223         this_arg_conv.inner = (void*)(this_arg & (~1));
11224         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11225         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
11226         jobjectArray ret_arr = (*_env)->NewObjectArray(_env, ret_var.datalen, NULL, NULL);
11227         for (size_t i = 0; i < ret_var.datalen; i++) {
11228                 jbyteArray arr_conv_8_arr = (*_env)->NewByteArray(_env, 33);
11229                 (*_env)->SetByteArrayRegion(_env, arr_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
11230                 (*_env)->SetObjectArrayElement(_env, ret_arr, i, arr_conv_8_arr);
11231         }
11232         CVec_PublicKeyZ_free(ret_var);
11233         return ret_arr;
11234 }
11235
11236 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong descriptor) {
11237         LDKPeerManager this_arg_conv;
11238         this_arg_conv.inner = (void*)(this_arg & (~1));
11239         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11240         LDKPublicKey their_node_id_ref;
11241         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
11242         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11243         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
11244         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
11245                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11246                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
11247         }
11248         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11249         *ret = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
11250         return (long)ret;
11251 }
11252
11253 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
11254         LDKPeerManager this_arg_conv;
11255         this_arg_conv.inner = (void*)(this_arg & (~1));
11256         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11257         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
11258         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
11259                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11260                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
11261         }
11262         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11263         *ret = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
11264         return (long)ret;
11265 }
11266
11267 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
11268         LDKPeerManager this_arg_conv;
11269         this_arg_conv.inner = (void*)(this_arg & (~1));
11270         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11271         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
11272         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11273         *ret = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
11274         return (long)ret;
11275 }
11276
11277 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv * _env, jclass _b, jlong this_arg, jlong peer_descriptor, jbyteArray data) {
11278         LDKPeerManager this_arg_conv;
11279         this_arg_conv.inner = (void*)(this_arg & (~1));
11280         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11281         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
11282         LDKu8slice data_ref;
11283         data_ref.data = (*_env)->GetByteArrayElements (_env, data, NULL);
11284         data_ref.datalen = (*_env)->GetArrayLength (_env, data);
11285         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11286         *ret = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
11287         (*_env)->ReleaseByteArrayElements(_env, data, (int8_t*)data_ref.data, 0);
11288         return (long)ret;
11289 }
11290
11291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
11292         LDKPeerManager this_arg_conv;
11293         this_arg_conv.inner = (void*)(this_arg & (~1));
11294         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11295         PeerManager_process_events(&this_arg_conv);
11296 }
11297
11298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
11299         LDKPeerManager this_arg_conv;
11300         this_arg_conv.inner = (void*)(this_arg & (~1));
11301         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11302         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
11303         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
11304 }
11305
11306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv * _env, jclass _b, jlong this_arg) {
11307         LDKPeerManager this_arg_conv;
11308         this_arg_conv.inner = (void*)(this_arg & (~1));
11309         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11310         PeerManager_timer_tick_occured(&this_arg_conv);
11311 }
11312
11313 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv * _env, jclass _b, jbyteArray commitment_seed, jlong idx) {
11314         unsigned char commitment_seed_arr[32];
11315         CHECK((*_env)->GetArrayLength (_env, commitment_seed) == 32);
11316         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_arr);
11317         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
11318         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
11319         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
11320         return arg_arr;
11321 }
11322
11323 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_secret) {
11324         LDKPublicKey per_commitment_point_ref;
11325         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11326         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11327         unsigned char base_secret_arr[32];
11328         CHECK((*_env)->GetArrayLength (_env, base_secret) == 32);
11329         (*_env)->GetByteArrayRegion (_env, base_secret, 0, 32, base_secret_arr);
11330         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
11331         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
11332         *ret = derive_private_key(per_commitment_point_ref, base_secret_ref);
11333         return (long)ret;
11334 }
11335
11336 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_point) {
11337         LDKPublicKey per_commitment_point_ref;
11338         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11339         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11340         LDKPublicKey base_point_ref;
11341         CHECK((*_env)->GetArrayLength (_env, base_point) == 33);
11342         (*_env)->GetByteArrayRegion (_env, base_point, 0, 33, base_point_ref.compressed_form);
11343         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
11344         *ret = derive_public_key(per_commitment_point_ref, base_point_ref);
11345         return (long)ret;
11346 }
11347
11348 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1private_1revocation_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_secret, jbyteArray countersignatory_revocation_base_secret) {
11349         unsigned char per_commitment_secret_arr[32];
11350         CHECK((*_env)->GetArrayLength (_env, per_commitment_secret) == 32);
11351         (*_env)->GetByteArrayRegion (_env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
11352         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
11353         unsigned char countersignatory_revocation_base_secret_arr[32];
11354         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base_secret) == 32);
11355         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
11356         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
11357         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
11358         *ret = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
11359         return (long)ret;
11360 }
11361
11362 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1revocation_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray countersignatory_revocation_base_point) {
11363         LDKPublicKey per_commitment_point_ref;
11364         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11365         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11366         LDKPublicKey countersignatory_revocation_base_point_ref;
11367         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base_point) == 33);
11368         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
11369         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
11370         *ret = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
11371         return (long)ret;
11372 }
11373
11374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11375         LDKTxCreationKeys this_ptr_conv;
11376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11377         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11378         TxCreationKeys_free(this_ptr_conv);
11379 }
11380
11381 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11382         LDKTxCreationKeys orig_conv;
11383         orig_conv.inner = (void*)(orig & (~1));
11384         orig_conv.is_owned = (orig & 1) || (orig == 0);
11385         LDKTxCreationKeys ret = TxCreationKeys_clone(&orig_conv);
11386         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11387 }
11388
11389 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
11390         LDKTxCreationKeys this_ptr_conv;
11391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11392         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11393         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11394         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
11395         return arg_arr;
11396 }
11397
11398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11399         LDKTxCreationKeys this_ptr_conv;
11400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11401         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11402         LDKPublicKey val_ref;
11403         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11404         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11405         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
11406 }
11407
11408 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11409         LDKTxCreationKeys this_ptr_conv;
11410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11411         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11412         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11413         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
11414         return arg_arr;
11415 }
11416
11417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11418         LDKTxCreationKeys this_ptr_conv;
11419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11420         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11421         LDKPublicKey val_ref;
11422         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11423         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11424         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
11425 }
11426
11427 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11428         LDKTxCreationKeys this_ptr_conv;
11429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11430         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11431         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11432         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
11433         return arg_arr;
11434 }
11435
11436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11437         LDKTxCreationKeys this_ptr_conv;
11438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11439         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11440         LDKPublicKey val_ref;
11441         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11442         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11443         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
11444 }
11445
11446 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11447         LDKTxCreationKeys this_ptr_conv;
11448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11449         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11450         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11451         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
11452         return arg_arr;
11453 }
11454
11455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11456         LDKTxCreationKeys this_ptr_conv;
11457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11458         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11459         LDKPublicKey val_ref;
11460         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11461         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11462         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
11463 }
11464
11465 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11466         LDKTxCreationKeys this_ptr_conv;
11467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11468         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11469         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11470         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
11471         return arg_arr;
11472 }
11473
11474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11475         LDKTxCreationKeys this_ptr_conv;
11476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11477         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11478         LDKPublicKey val_ref;
11479         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11480         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11481         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
11482 }
11483
11484 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1new(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point_arg, jbyteArray revocation_key_arg, jbyteArray broadcaster_htlc_key_arg, jbyteArray countersignatory_htlc_key_arg, jbyteArray broadcaster_delayed_payment_key_arg) {
11485         LDKPublicKey per_commitment_point_arg_ref;
11486         CHECK((*_env)->GetArrayLength (_env, per_commitment_point_arg) == 33);
11487         (*_env)->GetByteArrayRegion (_env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
11488         LDKPublicKey revocation_key_arg_ref;
11489         CHECK((*_env)->GetArrayLength (_env, revocation_key_arg) == 33);
11490         (*_env)->GetByteArrayRegion (_env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
11491         LDKPublicKey broadcaster_htlc_key_arg_ref;
11492         CHECK((*_env)->GetArrayLength (_env, broadcaster_htlc_key_arg) == 33);
11493         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
11494         LDKPublicKey countersignatory_htlc_key_arg_ref;
11495         CHECK((*_env)->GetArrayLength (_env, countersignatory_htlc_key_arg) == 33);
11496         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
11497         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
11498         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key_arg) == 33);
11499         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
11500         LDKTxCreationKeys ret = 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);
11501         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11502 }
11503
11504 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
11505         LDKTxCreationKeys obj_conv;
11506         obj_conv.inner = (void*)(obj & (~1));
11507         obj_conv.is_owned = (obj & 1) || (obj == 0);
11508         LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
11509         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11510         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11511         CVec_u8Z_free(arg_var);
11512         return arg_arr;
11513 }
11514
11515 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11516         LDKu8slice ser_ref;
11517         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11518         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11519         LDKTxCreationKeys ret = TxCreationKeys_read(ser_ref);
11520         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11521         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11522 }
11523
11524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11525         LDKPreCalculatedTxCreationKeys this_ptr_conv;
11526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11527         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11528         PreCalculatedTxCreationKeys_free(this_ptr_conv);
11529 }
11530
11531 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1new(JNIEnv * _env, jclass _b, jlong keys) {
11532         LDKTxCreationKeys keys_conv;
11533         keys_conv.inner = (void*)(keys & (~1));
11534         keys_conv.is_owned = (keys & 1) || (keys == 0);
11535         if (keys_conv.inner != NULL)
11536                 keys_conv = TxCreationKeys_clone(&keys_conv);
11537         LDKPreCalculatedTxCreationKeys ret = PreCalculatedTxCreationKeys_new(keys_conv);
11538         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11539 }
11540
11541 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
11542         LDKPreCalculatedTxCreationKeys this_arg_conv;
11543         this_arg_conv.inner = (void*)(this_arg & (~1));
11544         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11545         LDKTxCreationKeys ret = PreCalculatedTxCreationKeys_trust_key_derivation(&this_arg_conv);
11546         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11547 }
11548
11549 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg) {
11550         LDKPreCalculatedTxCreationKeys this_arg_conv;
11551         this_arg_conv.inner = (void*)(this_arg & (~1));
11552         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11553         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11554         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, PreCalculatedTxCreationKeys_per_commitment_point(&this_arg_conv).compressed_form);
11555         return arg_arr;
11556 }
11557
11558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11559         LDKChannelPublicKeys this_ptr_conv;
11560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11561         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11562         ChannelPublicKeys_free(this_ptr_conv);
11563 }
11564
11565 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11566         LDKChannelPublicKeys orig_conv;
11567         orig_conv.inner = (void*)(orig & (~1));
11568         orig_conv.is_owned = (orig & 1) || (orig == 0);
11569         LDKChannelPublicKeys ret = ChannelPublicKeys_clone(&orig_conv);
11570         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11571 }
11572
11573 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
11574         LDKChannelPublicKeys this_ptr_conv;
11575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11576         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11577         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11578         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
11579         return arg_arr;
11580 }
11581
11582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11583         LDKChannelPublicKeys this_ptr_conv;
11584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11585         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11586         LDKPublicKey val_ref;
11587         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11588         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11589         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
11590 }
11591
11592 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
11593         LDKChannelPublicKeys 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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11597         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
11598         return arg_arr;
11599 }
11600
11601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11602         LDKChannelPublicKeys this_ptr_conv;
11603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11604         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11605         LDKPublicKey val_ref;
11606         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11607         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11608         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
11609 }
11610
11611 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
11612         LDKChannelPublicKeys this_ptr_conv;
11613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11614         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11615         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11616         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
11617         return arg_arr;
11618 }
11619
11620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11621         LDKChannelPublicKeys this_ptr_conv;
11622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11623         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11624         LDKPublicKey val_ref;
11625         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11626         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11627         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
11628 }
11629
11630 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
11631         LDKChannelPublicKeys this_ptr_conv;
11632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11633         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11634         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11635         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
11636         return arg_arr;
11637 }
11638
11639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11640         LDKChannelPublicKeys this_ptr_conv;
11641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11642         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11643         LDKPublicKey val_ref;
11644         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11645         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11646         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
11647 }
11648
11649 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
11650         LDKChannelPublicKeys this_ptr_conv;
11651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11652         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11653         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11654         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
11655         return arg_arr;
11656 }
11657
11658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11659         LDKChannelPublicKeys this_ptr_conv;
11660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11661         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11662         LDKPublicKey val_ref;
11663         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11664         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11665         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
11666 }
11667
11668 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1new(JNIEnv * _env, jclass _b, jbyteArray funding_pubkey_arg, jbyteArray revocation_basepoint_arg, jbyteArray payment_point_arg, jbyteArray delayed_payment_basepoint_arg, jbyteArray htlc_basepoint_arg) {
11669         LDKPublicKey funding_pubkey_arg_ref;
11670         CHECK((*_env)->GetArrayLength (_env, funding_pubkey_arg) == 33);
11671         (*_env)->GetByteArrayRegion (_env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
11672         LDKPublicKey revocation_basepoint_arg_ref;
11673         CHECK((*_env)->GetArrayLength (_env, revocation_basepoint_arg) == 33);
11674         (*_env)->GetByteArrayRegion (_env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
11675         LDKPublicKey payment_point_arg_ref;
11676         CHECK((*_env)->GetArrayLength (_env, payment_point_arg) == 33);
11677         (*_env)->GetByteArrayRegion (_env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
11678         LDKPublicKey delayed_payment_basepoint_arg_ref;
11679         CHECK((*_env)->GetArrayLength (_env, delayed_payment_basepoint_arg) == 33);
11680         (*_env)->GetByteArrayRegion (_env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
11681         LDKPublicKey htlc_basepoint_arg_ref;
11682         CHECK((*_env)->GetArrayLength (_env, htlc_basepoint_arg) == 33);
11683         (*_env)->GetByteArrayRegion (_env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
11684         LDKChannelPublicKeys ret = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
11685         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11686 }
11687
11688 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
11689         LDKChannelPublicKeys obj_conv;
11690         obj_conv.inner = (void*)(obj & (~1));
11691         obj_conv.is_owned = (obj & 1) || (obj == 0);
11692         LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
11693         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11694         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11695         CVec_u8Z_free(arg_var);
11696         return arg_arr;
11697 }
11698
11699 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11700         LDKu8slice ser_ref;
11701         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11702         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11703         LDKChannelPublicKeys ret = ChannelPublicKeys_read(ser_ref);
11704         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11705         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11706 }
11707
11708 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1derive_1new(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray broadcaster_delayed_payment_base, jbyteArray broadcaster_htlc_base, jbyteArray countersignatory_revocation_base, jbyteArray countersignatory_htlc_base) {
11709         LDKPublicKey per_commitment_point_ref;
11710         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11711         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11712         LDKPublicKey broadcaster_delayed_payment_base_ref;
11713         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_base) == 33);
11714         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
11715         LDKPublicKey broadcaster_htlc_base_ref;
11716         CHECK((*_env)->GetArrayLength (_env, broadcaster_htlc_base) == 33);
11717         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
11718         LDKPublicKey countersignatory_revocation_base_ref;
11719         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base) == 33);
11720         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
11721         LDKPublicKey countersignatory_htlc_base_ref;
11722         CHECK((*_env)->GetArrayLength (_env, countersignatory_htlc_base) == 33);
11723         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
11724         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
11725         *ret = TxCreationKeys_derive_new(per_commitment_point_ref, broadcaster_delayed_payment_base_ref, broadcaster_htlc_base_ref, countersignatory_revocation_base_ref, countersignatory_htlc_base_ref);
11726         return (long)ret;
11727 }
11728
11729 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1revokeable_1redeemscript(JNIEnv * _env, jclass _b, jbyteArray revocation_key, jshort contest_delay, jbyteArray broadcaster_delayed_payment_key) {
11730         LDKPublicKey revocation_key_ref;
11731         CHECK((*_env)->GetArrayLength (_env, revocation_key) == 33);
11732         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
11733         LDKPublicKey broadcaster_delayed_payment_key_ref;
11734         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key) == 33);
11735         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
11736         LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
11737         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11738         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11739         CVec_u8Z_free(arg_var);
11740         return arg_arr;
11741 }
11742
11743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11744         LDKHTLCOutputInCommitment this_ptr_conv;
11745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11746         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11747         HTLCOutputInCommitment_free(this_ptr_conv);
11748 }
11749
11750 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11751         LDKHTLCOutputInCommitment orig_conv;
11752         orig_conv.inner = (void*)(orig & (~1));
11753         orig_conv.is_owned = (orig & 1) || (orig == 0);
11754         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_clone(&orig_conv);
11755         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11756 }
11757
11758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv * _env, jclass _b, jlong this_ptr) {
11759         LDKHTLCOutputInCommitment this_ptr_conv;
11760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11761         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11762         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
11763         return ret_val;
11764 }
11765
11766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
11767         LDKHTLCOutputInCommitment this_ptr_conv;
11768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11769         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11770         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
11771 }
11772
11773 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
11774         LDKHTLCOutputInCommitment this_ptr_conv;
11775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11776         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11777         jlong ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
11778         return ret_val;
11779 }
11780
11781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11782         LDKHTLCOutputInCommitment this_ptr_conv;
11783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11784         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11785         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
11786 }
11787
11788 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
11789         LDKHTLCOutputInCommitment this_ptr_conv;
11790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11791         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11792         jint ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
11793         return ret_val;
11794 }
11795
11796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11797         LDKHTLCOutputInCommitment this_ptr_conv;
11798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11799         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11800         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
11801 }
11802
11803 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
11804         LDKHTLCOutputInCommitment this_ptr_conv;
11805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11806         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11807         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
11808         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
11809         return ret_arr;
11810 }
11811
11812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11813         LDKHTLCOutputInCommitment this_ptr_conv;
11814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11815         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11816         LDKThirtyTwoBytes val_ref;
11817         CHECK((*_env)->GetArrayLength (_env, val) == 32);
11818         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
11819         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
11820 }
11821
11822 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv * _env, jclass _b, jlong obj) {
11823         LDKHTLCOutputInCommitment obj_conv;
11824         obj_conv.inner = (void*)(obj & (~1));
11825         obj_conv.is_owned = (obj & 1) || (obj == 0);
11826         LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
11827         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11828         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11829         CVec_u8Z_free(arg_var);
11830         return arg_arr;
11831 }
11832
11833 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11834         LDKu8slice ser_ref;
11835         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11836         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11837         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_read(ser_ref);
11838         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11839         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11840 }
11841
11842 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv * _env, jclass _b, jlong htlc, jlong keys) {
11843         LDKHTLCOutputInCommitment htlc_conv;
11844         htlc_conv.inner = (void*)(htlc & (~1));
11845         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
11846         LDKTxCreationKeys keys_conv;
11847         keys_conv.inner = (void*)(keys & (~1));
11848         keys_conv.is_owned = (keys & 1) || (keys == 0);
11849         LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
11850         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11851         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11852         CVec_u8Z_free(arg_var);
11853         return arg_arr;
11854 }
11855
11856 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv * _env, jclass _b, jbyteArray broadcaster, jbyteArray countersignatory) {
11857         LDKPublicKey broadcaster_ref;
11858         CHECK((*_env)->GetArrayLength (_env, broadcaster) == 33);
11859         (*_env)->GetByteArrayRegion (_env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
11860         LDKPublicKey countersignatory_ref;
11861         CHECK((*_env)->GetArrayLength (_env, countersignatory) == 33);
11862         (*_env)->GetByteArrayRegion (_env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
11863         LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
11864         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11865         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11866         CVec_u8Z_free(arg_var);
11867         return arg_arr;
11868 }
11869
11870 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_build_1htlc_1transaction(JNIEnv * _env, jclass _b, jbyteArray prev_hash, jint feerate_per_kw, jshort contest_delay, jlong htlc, jbyteArray broadcaster_delayed_payment_key, jbyteArray revocation_key) {
11871         unsigned char prev_hash_arr[32];
11872         CHECK((*_env)->GetArrayLength (_env, prev_hash) == 32);
11873         (*_env)->GetByteArrayRegion (_env, prev_hash, 0, 32, prev_hash_arr);
11874         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
11875         LDKHTLCOutputInCommitment htlc_conv;
11876         htlc_conv.inner = (void*)(htlc & (~1));
11877         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
11878         LDKPublicKey broadcaster_delayed_payment_key_ref;
11879         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key) == 33);
11880         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
11881         LDKPublicKey revocation_key_ref;
11882         CHECK((*_env)->GetArrayLength (_env, revocation_key) == 33);
11883         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
11884         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
11885         *ret = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
11886         return (long)ret;
11887 }
11888
11889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11890         LDKHolderCommitmentTransaction this_ptr_conv;
11891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11892         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11893         HolderCommitmentTransaction_free(this_ptr_conv);
11894 }
11895
11896 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11897         LDKHolderCommitmentTransaction orig_conv;
11898         orig_conv.inner = (void*)(orig & (~1));
11899         orig_conv.is_owned = (orig & 1) || (orig == 0);
11900         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_clone(&orig_conv);
11901         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11902 }
11903
11904 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr) {
11905         LDKHolderCommitmentTransaction this_ptr_conv;
11906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11907         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11908         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
11909         *ret = HolderCommitmentTransaction_get_unsigned_tx(&this_ptr_conv);
11910         return (long)ret;
11911 }
11912
11913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11914         LDKHolderCommitmentTransaction this_ptr_conv;
11915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11916         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11917         LDKTransaction val_conv = *(LDKTransaction*)val;
11918         HolderCommitmentTransaction_set_unsigned_tx(&this_ptr_conv, val_conv);
11919 }
11920
11921 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr) {
11922         LDKHolderCommitmentTransaction this_ptr_conv;
11923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11924         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11925         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
11926         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
11927         return arg_arr;
11928 }
11929
11930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11931         LDKHolderCommitmentTransaction this_ptr_conv;
11932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11933         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11934         LDKSignature val_ref;
11935         CHECK((*_env)->GetArrayLength (_env, val) == 64);
11936         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
11937         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
11938 }
11939
11940 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
11941         LDKHolderCommitmentTransaction this_ptr_conv;
11942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11943         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11944         jint ret_val = HolderCommitmentTransaction_get_feerate_per_kw(&this_ptr_conv);
11945         return ret_val;
11946 }
11947
11948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11949         LDKHolderCommitmentTransaction this_ptr_conv;
11950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11951         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11952         HolderCommitmentTransaction_set_feerate_per_kw(&this_ptr_conv, val);
11953 }
11954
11955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
11956         LDKHolderCommitmentTransaction this_ptr_conv;
11957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11958         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11959         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_constr;
11960         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
11961         if (val_constr.datalen > 0)
11962                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
11963         else
11964                 val_constr.data = NULL;
11965         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
11966         for (size_t q = 0; q < val_constr.datalen; q++) {
11967                 long arr_conv_42 = val_vals[q];
11968                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
11969                 FREE((void*)arr_conv_42);
11970                 val_constr.data[q] = arr_conv_42_conv;
11971         }
11972         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
11973         HolderCommitmentTransaction_set_per_htlc(&this_ptr_conv, val_constr);
11974 }
11975
11976 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new_1missing_1holder_1sig(JNIEnv * _env, jclass _b, jlong unsigned_tx, jbyteArray counterparty_sig, jbyteArray holder_funding_key, jbyteArray counterparty_funding_key, jlong keys, jint feerate_per_kw, jlongArray htlc_data) {
11977         LDKTransaction unsigned_tx_conv = *(LDKTransaction*)unsigned_tx;
11978         LDKSignature counterparty_sig_ref;
11979         CHECK((*_env)->GetArrayLength (_env, counterparty_sig) == 64);
11980         (*_env)->GetByteArrayRegion (_env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
11981         LDKPublicKey holder_funding_key_ref;
11982         CHECK((*_env)->GetArrayLength (_env, holder_funding_key) == 33);
11983         (*_env)->GetByteArrayRegion (_env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
11984         LDKPublicKey counterparty_funding_key_ref;
11985         CHECK((*_env)->GetArrayLength (_env, counterparty_funding_key) == 33);
11986         (*_env)->GetByteArrayRegion (_env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
11987         LDKTxCreationKeys keys_conv;
11988         keys_conv.inner = (void*)(keys & (~1));
11989         keys_conv.is_owned = (keys & 1) || (keys == 0);
11990         if (keys_conv.inner != NULL)
11991                 keys_conv = TxCreationKeys_clone(&keys_conv);
11992         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_constr;
11993         htlc_data_constr.datalen = (*_env)->GetArrayLength (_env, htlc_data);
11994         if (htlc_data_constr.datalen > 0)
11995                 htlc_data_constr.data = MALLOC(htlc_data_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
11996         else
11997                 htlc_data_constr.data = NULL;
11998         long* htlc_data_vals = (*_env)->GetLongArrayElements (_env, htlc_data, NULL);
11999         for (size_t q = 0; q < htlc_data_constr.datalen; q++) {
12000                 long arr_conv_42 = htlc_data_vals[q];
12001                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
12002                 FREE((void*)arr_conv_42);
12003                 htlc_data_constr.data[q] = arr_conv_42_conv;
12004         }
12005         (*_env)->ReleaseLongArrayElements (_env, htlc_data, htlc_data_vals, 0);
12006         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_new_missing_holder_sig(unsigned_tx_conv, counterparty_sig_ref, holder_funding_key_ref, counterparty_funding_key_ref, keys_conv, feerate_per_kw, htlc_data_constr);
12007         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12008 }
12009
12010 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
12011         LDKHolderCommitmentTransaction this_arg_conv;
12012         this_arg_conv.inner = (void*)(this_arg & (~1));
12013         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12014         LDKTxCreationKeys ret = HolderCommitmentTransaction_trust_key_derivation(&this_arg_conv);
12015         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12016 }
12017
12018 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1txid(JNIEnv * _env, jclass _b, jlong this_arg) {
12019         LDKHolderCommitmentTransaction this_arg_conv;
12020         this_arg_conv.inner = (void*)(this_arg & (~1));
12021         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12022         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
12023         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, HolderCommitmentTransaction_txid(&this_arg_conv).data);
12024         return arg_arr;
12025 }
12026
12027 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1holder_1sig(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray funding_key, jbyteArray funding_redeemscript, jlong channel_value_satoshis) {
12028         LDKHolderCommitmentTransaction this_arg_conv;
12029         this_arg_conv.inner = (void*)(this_arg & (~1));
12030         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12031         unsigned char funding_key_arr[32];
12032         CHECK((*_env)->GetArrayLength (_env, funding_key) == 32);
12033         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_arr);
12034         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
12035         LDKu8slice funding_redeemscript_ref;
12036         funding_redeemscript_ref.data = (*_env)->GetByteArrayElements (_env, funding_redeemscript, NULL);
12037         funding_redeemscript_ref.datalen = (*_env)->GetArrayLength (_env, funding_redeemscript);
12038         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
12039         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, HolderCommitmentTransaction_get_holder_sig(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
12040         (*_env)->ReleaseByteArrayElements(_env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
12041         return arg_arr;
12042 }
12043
12044 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1htlc_1sigs(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray htlc_base_key, jshort counterparty_selected_contest_delay) {
12045         LDKHolderCommitmentTransaction this_arg_conv;
12046         this_arg_conv.inner = (void*)(this_arg & (~1));
12047         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12048         unsigned char htlc_base_key_arr[32];
12049         CHECK((*_env)->GetArrayLength (_env, htlc_base_key) == 32);
12050         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_arr);
12051         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
12052         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12053         *ret = HolderCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, counterparty_selected_contest_delay);
12054         return (long)ret;
12055 }
12056
12057 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv * _env, jclass _b, jlong obj) {
12058         LDKHolderCommitmentTransaction obj_conv;
12059         obj_conv.inner = (void*)(obj & (~1));
12060         obj_conv.is_owned = (obj & 1) || (obj == 0);
12061         LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
12062         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12063         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12064         CVec_u8Z_free(arg_var);
12065         return arg_arr;
12066 }
12067
12068 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12069         LDKu8slice ser_ref;
12070         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12071         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12072         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_read(ser_ref);
12073         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12074         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12075 }
12076
12077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12078         LDKInitFeatures this_ptr_conv;
12079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12080         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12081         InitFeatures_free(this_ptr_conv);
12082 }
12083
12084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12085         LDKNodeFeatures this_ptr_conv;
12086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12087         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12088         NodeFeatures_free(this_ptr_conv);
12089 }
12090
12091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12092         LDKChannelFeatures this_ptr_conv;
12093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12094         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12095         ChannelFeatures_free(this_ptr_conv);
12096 }
12097
12098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12099         LDKRouteHop this_ptr_conv;
12100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12101         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12102         RouteHop_free(this_ptr_conv);
12103 }
12104
12105 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12106         LDKRouteHop orig_conv;
12107         orig_conv.inner = (void*)(orig & (~1));
12108         orig_conv.is_owned = (orig & 1) || (orig == 0);
12109         LDKRouteHop ret = RouteHop_clone(&orig_conv);
12110         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12111 }
12112
12113 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
12114         LDKRouteHop this_ptr_conv;
12115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12116         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12117         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12118         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
12119         return arg_arr;
12120 }
12121
12122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12123         LDKRouteHop this_ptr_conv;
12124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12125         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12126         LDKPublicKey val_ref;
12127         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12128         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12129         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
12130 }
12131
12132 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12133         LDKRouteHop this_ptr_conv;
12134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12135         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12136         LDKNodeFeatures ret = RouteHop_get_node_features(&this_ptr_conv);
12137         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12138 }
12139
12140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12141         LDKRouteHop this_ptr_conv;
12142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12143         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12144         LDKNodeFeatures val_conv;
12145         val_conv.inner = (void*)(val & (~1));
12146         val_conv.is_owned = (val & 1) || (val == 0);
12147         // Warning: we may need a move here but can't clone!
12148         RouteHop_set_node_features(&this_ptr_conv, val_conv);
12149 }
12150
12151 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12152         LDKRouteHop this_ptr_conv;
12153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12154         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12155         jlong ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
12156         return ret_val;
12157 }
12158
12159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12160         LDKRouteHop this_ptr_conv;
12161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12162         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12163         RouteHop_set_short_channel_id(&this_ptr_conv, val);
12164 }
12165
12166 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12167         LDKRouteHop this_ptr_conv;
12168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12169         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12170         LDKChannelFeatures ret = RouteHop_get_channel_features(&this_ptr_conv);
12171         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12172 }
12173
12174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12175         LDKRouteHop this_ptr_conv;
12176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12177         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12178         LDKChannelFeatures val_conv;
12179         val_conv.inner = (void*)(val & (~1));
12180         val_conv.is_owned = (val & 1) || (val == 0);
12181         // Warning: we may need a move here but can't clone!
12182         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
12183 }
12184
12185 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12186         LDKRouteHop this_ptr_conv;
12187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12188         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12189         jlong ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
12190         return ret_val;
12191 }
12192
12193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12194         LDKRouteHop this_ptr_conv;
12195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12196         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12197         RouteHop_set_fee_msat(&this_ptr_conv, val);
12198 }
12199
12200 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
12201         LDKRouteHop this_ptr_conv;
12202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12203         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12204         jint ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
12205         return ret_val;
12206 }
12207
12208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12209         LDKRouteHop this_ptr_conv;
12210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12211         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12212         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
12213 }
12214
12215 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1new(JNIEnv * _env, jclass _b, jbyteArray pubkey_arg, jlong node_features_arg, jlong short_channel_id_arg, jlong channel_features_arg, jlong fee_msat_arg, jint cltv_expiry_delta_arg) {
12216         LDKPublicKey pubkey_arg_ref;
12217         CHECK((*_env)->GetArrayLength (_env, pubkey_arg) == 33);
12218         (*_env)->GetByteArrayRegion (_env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
12219         LDKNodeFeatures node_features_arg_conv;
12220         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
12221         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
12222         // Warning: we may need a move here but can't clone!
12223         LDKChannelFeatures channel_features_arg_conv;
12224         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
12225         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
12226         // Warning: we may need a move here but can't clone!
12227         LDKRouteHop ret = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
12228         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12229 }
12230
12231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12232         LDKRoute this_ptr_conv;
12233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12234         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12235         Route_free(this_ptr_conv);
12236 }
12237
12238 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12239         LDKRoute orig_conv;
12240         orig_conv.inner = (void*)(orig & (~1));
12241         orig_conv.is_owned = (orig & 1) || (orig == 0);
12242         LDKRoute ret = Route_clone(&orig_conv);
12243         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12244 }
12245
12246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jobjectArray val) {
12247         LDKRoute this_ptr_conv;
12248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12249         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12250         LDKCVec_CVec_RouteHopZZ val_constr;
12251         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
12252         if (val_constr.datalen > 0)
12253                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12254         else
12255                 val_constr.data = NULL;
12256         for (size_t m = 0; m < val_constr.datalen; m++) {
12257                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, val, m);
12258                 LDKCVec_RouteHopZ arr_conv_12_constr;
12259                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
12260                 if (arr_conv_12_constr.datalen > 0)
12261                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12262                 else
12263                         arr_conv_12_constr.data = NULL;
12264                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
12265                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
12266                         long arr_conv_10 = arr_conv_12_vals[k];
12267                         LDKRouteHop arr_conv_10_conv;
12268                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
12269                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
12270                         if (arr_conv_10_conv.inner != NULL)
12271                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
12272                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
12273                 }
12274                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
12275                 val_constr.data[m] = arr_conv_12_constr;
12276         }
12277         Route_set_paths(&this_ptr_conv, val_constr);
12278 }
12279
12280 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jobjectArray paths_arg) {
12281         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
12282         paths_arg_constr.datalen = (*_env)->GetArrayLength (_env, paths_arg);
12283         if (paths_arg_constr.datalen > 0)
12284                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12285         else
12286                 paths_arg_constr.data = NULL;
12287         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
12288                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, paths_arg, m);
12289                 LDKCVec_RouteHopZ arr_conv_12_constr;
12290                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
12291                 if (arr_conv_12_constr.datalen > 0)
12292                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12293                 else
12294                         arr_conv_12_constr.data = NULL;
12295                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
12296                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
12297                         long arr_conv_10 = arr_conv_12_vals[k];
12298                         LDKRouteHop arr_conv_10_conv;
12299                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
12300                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
12301                         if (arr_conv_10_conv.inner != NULL)
12302                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
12303                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
12304                 }
12305                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
12306                 paths_arg_constr.data[m] = arr_conv_12_constr;
12307         }
12308         LDKRoute ret = Route_new(paths_arg_constr);
12309         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12310 }
12311
12312 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv * _env, jclass _b, jlong obj) {
12313         LDKRoute obj_conv;
12314         obj_conv.inner = (void*)(obj & (~1));
12315         obj_conv.is_owned = (obj & 1) || (obj == 0);
12316         LDKCVec_u8Z arg_var = Route_write(&obj_conv);
12317         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12318         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12319         CVec_u8Z_free(arg_var);
12320         return arg_arr;
12321 }
12322
12323 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12324         LDKu8slice ser_ref;
12325         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12326         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12327         LDKRoute ret = Route_read(ser_ref);
12328         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12329         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12330 }
12331
12332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12333         LDKRouteHint this_ptr_conv;
12334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12335         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12336         RouteHint_free(this_ptr_conv);
12337 }
12338
12339 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12340         LDKRouteHint orig_conv;
12341         orig_conv.inner = (void*)(orig & (~1));
12342         orig_conv.is_owned = (orig & 1) || (orig == 0);
12343         LDKRouteHint ret = RouteHint_clone(&orig_conv);
12344         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12345 }
12346
12347 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12348         LDKRouteHint this_ptr_conv;
12349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12350         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12351         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12352         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
12353         return arg_arr;
12354 }
12355
12356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12357         LDKRouteHint this_ptr_conv;
12358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12359         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12360         LDKPublicKey val_ref;
12361         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12362         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12363         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
12364 }
12365
12366 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12367         LDKRouteHint this_ptr_conv;
12368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12369         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12370         jlong ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
12371         return ret_val;
12372 }
12373
12374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12375         LDKRouteHint this_ptr_conv;
12376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12377         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12378         RouteHint_set_short_channel_id(&this_ptr_conv, val);
12379 }
12380
12381 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
12382         LDKRouteHint this_ptr_conv;
12383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12384         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12385         LDKRoutingFees ret = RouteHint_get_fees(&this_ptr_conv);
12386         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12387 }
12388
12389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12390         LDKRouteHint this_ptr_conv;
12391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12392         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12393         LDKRoutingFees val_conv;
12394         val_conv.inner = (void*)(val & (~1));
12395         val_conv.is_owned = (val & 1) || (val == 0);
12396         if (val_conv.inner != NULL)
12397                 val_conv = RoutingFees_clone(&val_conv);
12398         RouteHint_set_fees(&this_ptr_conv, val_conv);
12399 }
12400
12401 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
12402         LDKRouteHint this_ptr_conv;
12403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12404         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12405         jshort ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
12406         return ret_val;
12407 }
12408
12409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
12410         LDKRouteHint this_ptr_conv;
12411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12412         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12413         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
12414 }
12415
12416 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12417         LDKRouteHint this_ptr_conv;
12418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12419         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12420         jlong ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
12421         return ret_val;
12422 }
12423
12424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12425         LDKRouteHint this_ptr_conv;
12426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12427         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12428         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
12429 }
12430
12431 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv * _env, jclass _b, jbyteArray src_node_id_arg, jlong short_channel_id_arg, jlong fees_arg, jshort cltv_expiry_delta_arg, jlong htlc_minimum_msat_arg) {
12432         LDKPublicKey src_node_id_arg_ref;
12433         CHECK((*_env)->GetArrayLength (_env, src_node_id_arg) == 33);
12434         (*_env)->GetByteArrayRegion (_env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
12435         LDKRoutingFees fees_arg_conv;
12436         fees_arg_conv.inner = (void*)(fees_arg & (~1));
12437         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
12438         if (fees_arg_conv.inner != NULL)
12439                 fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
12440         LDKRouteHint ret = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
12441         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12442 }
12443
12444 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv * _env, jclass _b, jbyteArray our_node_id, jlong network, jbyteArray target, jlongArray first_hops, jlongArray last_hops, jlong final_value_msat, jint final_cltv, jlong logger) {
12445         LDKPublicKey our_node_id_ref;
12446         CHECK((*_env)->GetArrayLength (_env, our_node_id) == 33);
12447         (*_env)->GetByteArrayRegion (_env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
12448         LDKNetworkGraph network_conv;
12449         network_conv.inner = (void*)(network & (~1));
12450         network_conv.is_owned = (network & 1) || (network == 0);
12451         LDKPublicKey target_ref;
12452         CHECK((*_env)->GetArrayLength (_env, target) == 33);
12453         (*_env)->GetByteArrayRegion (_env, target, 0, 33, target_ref.compressed_form);
12454         LDKCVec_ChannelDetailsZ first_hops_constr;
12455         first_hops_constr.datalen = (*_env)->GetArrayLength (_env, first_hops);
12456         if (first_hops_constr.datalen > 0)
12457                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12458         else
12459                 first_hops_constr.data = NULL;
12460         long* first_hops_vals = (*_env)->GetLongArrayElements (_env, first_hops, NULL);
12461         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
12462                 long arr_conv_16 = first_hops_vals[q];
12463                 LDKChannelDetails arr_conv_16_conv;
12464                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
12465                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
12466                 first_hops_constr.data[q] = arr_conv_16_conv;
12467         }
12468         (*_env)->ReleaseLongArrayElements (_env, first_hops, first_hops_vals, 0);
12469         LDKCVec_RouteHintZ last_hops_constr;
12470         last_hops_constr.datalen = (*_env)->GetArrayLength (_env, last_hops);
12471         if (last_hops_constr.datalen > 0)
12472                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12473         else
12474                 last_hops_constr.data = NULL;
12475         long* last_hops_vals = (*_env)->GetLongArrayElements (_env, last_hops, NULL);
12476         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
12477                 long arr_conv_11 = last_hops_vals[l];
12478                 LDKRouteHint arr_conv_11_conv;
12479                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
12480                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
12481                 if (arr_conv_11_conv.inner != NULL)
12482                         arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
12483                 last_hops_constr.data[l] = arr_conv_11_conv;
12484         }
12485         (*_env)->ReleaseLongArrayElements (_env, last_hops, last_hops_vals, 0);
12486         LDKLogger logger_conv = *(LDKLogger*)logger;
12487         if (logger_conv.free == LDKLogger_JCalls_free) {
12488                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12489                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12490         }
12491         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12492         *ret = get_route(our_node_id_ref, &network_conv, target_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
12493         FREE(first_hops_constr.data);
12494         return (long)ret;
12495 }
12496
12497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12498         LDKNetworkGraph this_ptr_conv;
12499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12500         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12501         NetworkGraph_free(this_ptr_conv);
12502 }
12503
12504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12505         LDKLockedNetworkGraph this_ptr_conv;
12506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12507         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12508         LockedNetworkGraph_free(this_ptr_conv);
12509 }
12510
12511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12512         LDKNetGraphMsgHandler this_ptr_conv;
12513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12514         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12515         NetGraphMsgHandler_free(this_ptr_conv);
12516 }
12517
12518 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger) {
12519         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
12520         LDKLogger logger_conv = *(LDKLogger*)logger;
12521         if (logger_conv.free == LDKLogger_JCalls_free) {
12522                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12523                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12524         }
12525         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_new(chain_access_conv, logger_conv);
12526         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12527 }
12528
12529 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger, jlong network_graph) {
12530         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
12531         LDKLogger logger_conv = *(LDKLogger*)logger;
12532         if (logger_conv.free == LDKLogger_JCalls_free) {
12533                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12534                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12535         }
12536         LDKNetworkGraph network_graph_conv;
12537         network_graph_conv.inner = (void*)(network_graph & (~1));
12538         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
12539         // Warning: we may need a move here but can't clone!
12540         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
12541         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12542 }
12543
12544 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
12545         LDKNetGraphMsgHandler this_arg_conv;
12546         this_arg_conv.inner = (void*)(this_arg & (~1));
12547         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12548         LDKLockedNetworkGraph ret = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
12549         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12550 }
12551
12552 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
12553         LDKLockedNetworkGraph this_arg_conv;
12554         this_arg_conv.inner = (void*)(this_arg & (~1));
12555         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12556         LDKNetworkGraph ret = LockedNetworkGraph_graph(&this_arg_conv);
12557         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12558 }
12559
12560 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
12561         LDKNetGraphMsgHandler this_arg_conv;
12562         this_arg_conv.inner = (void*)(this_arg & (~1));
12563         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12564         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
12565         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
12566         return (long)ret;
12567 }
12568
12569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12570         LDKDirectionalChannelInfo this_ptr_conv;
12571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12572         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12573         DirectionalChannelInfo_free(this_ptr_conv);
12574 }
12575
12576 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
12577         LDKDirectionalChannelInfo this_ptr_conv;
12578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12579         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12580         jint ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
12581         return ret_val;
12582 }
12583
12584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12585         LDKDirectionalChannelInfo this_ptr_conv;
12586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12587         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12588         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
12589 }
12590
12591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr) {
12592         LDKDirectionalChannelInfo this_ptr_conv;
12593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12594         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12595         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
12596         return ret_val;
12597 }
12598
12599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
12600         LDKDirectionalChannelInfo this_ptr_conv;
12601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12602         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12603         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
12604 }
12605
12606 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
12607         LDKDirectionalChannelInfo this_ptr_conv;
12608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12609         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12610         jshort ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
12611         return ret_val;
12612 }
12613
12614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
12615         LDKDirectionalChannelInfo this_ptr_conv;
12616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12617         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12618         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
12619 }
12620
12621 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12622         LDKDirectionalChannelInfo this_ptr_conv;
12623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12624         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12625         jlong ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
12626         return ret_val;
12627 }
12628
12629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12630         LDKDirectionalChannelInfo this_ptr_conv;
12631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12632         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12633         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
12634 }
12635
12636 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
12637         LDKDirectionalChannelInfo this_ptr_conv;
12638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12639         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12640         LDKChannelUpdate ret = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
12641         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12642 }
12643
12644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12645         LDKDirectionalChannelInfo this_ptr_conv;
12646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12647         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12648         LDKChannelUpdate val_conv;
12649         val_conv.inner = (void*)(val & (~1));
12650         val_conv.is_owned = (val & 1) || (val == 0);
12651         if (val_conv.inner != NULL)
12652                 val_conv = ChannelUpdate_clone(&val_conv);
12653         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
12654 }
12655
12656 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
12657         LDKDirectionalChannelInfo obj_conv;
12658         obj_conv.inner = (void*)(obj & (~1));
12659         obj_conv.is_owned = (obj & 1) || (obj == 0);
12660         LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
12661         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12662         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12663         CVec_u8Z_free(arg_var);
12664         return arg_arr;
12665 }
12666
12667 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12668         LDKu8slice ser_ref;
12669         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12670         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12671         LDKDirectionalChannelInfo ret = DirectionalChannelInfo_read(ser_ref);
12672         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12673         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12674 }
12675
12676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12677         LDKChannelInfo this_ptr_conv;
12678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12679         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12680         ChannelInfo_free(this_ptr_conv);
12681 }
12682
12683 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12684         LDKChannelInfo this_ptr_conv;
12685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12686         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12687         LDKChannelFeatures ret = ChannelInfo_get_features(&this_ptr_conv);
12688         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12689 }
12690
12691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12692         LDKChannelInfo this_ptr_conv;
12693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12694         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12695         LDKChannelFeatures val_conv;
12696         val_conv.inner = (void*)(val & (~1));
12697         val_conv.is_owned = (val & 1) || (val == 0);
12698         // Warning: we may need a move here but can't clone!
12699         ChannelInfo_set_features(&this_ptr_conv, val_conv);
12700 }
12701
12702 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
12703         LDKChannelInfo this_ptr_conv;
12704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12705         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12706         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12707         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
12708         return arg_arr;
12709 }
12710
12711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12712         LDKChannelInfo this_ptr_conv;
12713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12715         LDKPublicKey val_ref;
12716         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12717         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12718         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
12719 }
12720
12721 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
12722         LDKChannelInfo this_ptr_conv;
12723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12724         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12725         LDKDirectionalChannelInfo ret = ChannelInfo_get_one_to_two(&this_ptr_conv);
12726         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12727 }
12728
12729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12730         LDKChannelInfo this_ptr_conv;
12731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12732         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12733         LDKDirectionalChannelInfo val_conv;
12734         val_conv.inner = (void*)(val & (~1));
12735         val_conv.is_owned = (val & 1) || (val == 0);
12736         // Warning: we may need a move here but can't clone!
12737         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
12738 }
12739
12740 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
12741         LDKChannelInfo this_ptr_conv;
12742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12743         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12744         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12745         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
12746         return arg_arr;
12747 }
12748
12749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12750         LDKChannelInfo this_ptr_conv;
12751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12752         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12753         LDKPublicKey val_ref;
12754         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12755         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12756         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
12757 }
12758
12759 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
12760         LDKChannelInfo this_ptr_conv;
12761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12762         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12763         LDKDirectionalChannelInfo ret = ChannelInfo_get_two_to_one(&this_ptr_conv);
12764         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12765 }
12766
12767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12768         LDKChannelInfo this_ptr_conv;
12769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12770         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12771         LDKDirectionalChannelInfo val_conv;
12772         val_conv.inner = (void*)(val & (~1));
12773         val_conv.is_owned = (val & 1) || (val == 0);
12774         // Warning: we may need a move here but can't clone!
12775         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
12776 }
12777
12778 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
12779         LDKChannelInfo this_ptr_conv;
12780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12781         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12782         LDKChannelAnnouncement ret = ChannelInfo_get_announcement_message(&this_ptr_conv);
12783         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12784 }
12785
12786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12787         LDKChannelInfo this_ptr_conv;
12788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12789         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12790         LDKChannelAnnouncement val_conv;
12791         val_conv.inner = (void*)(val & (~1));
12792         val_conv.is_owned = (val & 1) || (val == 0);
12793         if (val_conv.inner != NULL)
12794                 val_conv = ChannelAnnouncement_clone(&val_conv);
12795         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
12796 }
12797
12798 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
12799         LDKChannelInfo obj_conv;
12800         obj_conv.inner = (void*)(obj & (~1));
12801         obj_conv.is_owned = (obj & 1) || (obj == 0);
12802         LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
12803         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12804         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12805         CVec_u8Z_free(arg_var);
12806         return arg_arr;
12807 }
12808
12809 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12810         LDKu8slice ser_ref;
12811         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12812         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12813         LDKChannelInfo ret = ChannelInfo_read(ser_ref);
12814         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12815         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12816 }
12817
12818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12819         LDKRoutingFees this_ptr_conv;
12820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12821         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12822         RoutingFees_free(this_ptr_conv);
12823 }
12824
12825 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12826         LDKRoutingFees orig_conv;
12827         orig_conv.inner = (void*)(orig & (~1));
12828         orig_conv.is_owned = (orig & 1) || (orig == 0);
12829         LDKRoutingFees ret = RoutingFees_clone(&orig_conv);
12830         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12831 }
12832
12833 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12834         LDKRoutingFees this_ptr_conv;
12835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12836         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12837         jint ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
12838         return ret_val;
12839 }
12840
12841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12842         LDKRoutingFees this_ptr_conv;
12843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12844         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12845         RoutingFees_set_base_msat(&this_ptr_conv, val);
12846 }
12847
12848 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
12849         LDKRoutingFees this_ptr_conv;
12850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12851         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12852         jint ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
12853         return ret_val;
12854 }
12855
12856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12857         LDKRoutingFees this_ptr_conv;
12858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12859         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12860         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
12861 }
12862
12863 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv * _env, jclass _b, jint base_msat_arg, jint proportional_millionths_arg) {
12864         LDKRoutingFees ret = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
12865         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12866 }
12867
12868 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12869         LDKu8slice ser_ref;
12870         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12871         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12872         LDKRoutingFees ret = RoutingFees_read(ser_ref);
12873         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12874         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12875 }
12876
12877 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv * _env, jclass _b, jlong obj) {
12878         LDKRoutingFees obj_conv;
12879         obj_conv.inner = (void*)(obj & (~1));
12880         obj_conv.is_owned = (obj & 1) || (obj == 0);
12881         LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
12882         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12883         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12884         CVec_u8Z_free(arg_var);
12885         return arg_arr;
12886 }
12887
12888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12889         LDKNodeAnnouncementInfo this_ptr_conv;
12890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12891         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12892         NodeAnnouncementInfo_free(this_ptr_conv);
12893 }
12894
12895 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12896         LDKNodeAnnouncementInfo this_ptr_conv;
12897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12898         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12899         LDKNodeFeatures ret = NodeAnnouncementInfo_get_features(&this_ptr_conv);
12900         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12901 }
12902
12903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12904         LDKNodeAnnouncementInfo this_ptr_conv;
12905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12906         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12907         LDKNodeFeatures val_conv;
12908         val_conv.inner = (void*)(val & (~1));
12909         val_conv.is_owned = (val & 1) || (val == 0);
12910         // Warning: we may need a move here but can't clone!
12911         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
12912 }
12913
12914 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
12915         LDKNodeAnnouncementInfo this_ptr_conv;
12916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12917         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12918         jint ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
12919         return ret_val;
12920 }
12921
12922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12923         LDKNodeAnnouncementInfo this_ptr_conv;
12924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12925         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12926         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
12927 }
12928
12929 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
12930         LDKNodeAnnouncementInfo this_ptr_conv;
12931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12932         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12933         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
12934         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
12935         return ret_arr;
12936 }
12937
12938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12939         LDKNodeAnnouncementInfo this_ptr_conv;
12940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12941         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12942         LDKThreeBytes val_ref;
12943         CHECK((*_env)->GetArrayLength (_env, val) == 3);
12944         (*_env)->GetByteArrayRegion (_env, val, 0, 3, val_ref.data);
12945         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
12946 }
12947
12948 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
12949         LDKNodeAnnouncementInfo this_ptr_conv;
12950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12951         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12952         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
12953         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
12954         return ret_arr;
12955 }
12956
12957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12958         LDKNodeAnnouncementInfo this_ptr_conv;
12959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12960         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12961         LDKThirtyTwoBytes val_ref;
12962         CHECK((*_env)->GetArrayLength (_env, val) == 32);
12963         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
12964         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
12965 }
12966
12967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
12968         LDKNodeAnnouncementInfo this_ptr_conv;
12969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12970         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12971         LDKCVec_NetAddressZ val_constr;
12972         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
12973         if (val_constr.datalen > 0)
12974                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12975         else
12976                 val_constr.data = NULL;
12977         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
12978         for (size_t m = 0; m < val_constr.datalen; m++) {
12979                 long arr_conv_12 = val_vals[m];
12980                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
12981                 FREE((void*)arr_conv_12);
12982                 val_constr.data[m] = arr_conv_12_conv;
12983         }
12984         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
12985         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
12986 }
12987
12988 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
12989         LDKNodeAnnouncementInfo this_ptr_conv;
12990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12991         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12992         LDKNodeAnnouncement ret = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
12993         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12994 }
12995
12996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12997         LDKNodeAnnouncementInfo this_ptr_conv;
12998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12999         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13000         LDKNodeAnnouncement val_conv;
13001         val_conv.inner = (void*)(val & (~1));
13002         val_conv.is_owned = (val & 1) || (val == 0);
13003         if (val_conv.inner != NULL)
13004                 val_conv = NodeAnnouncement_clone(&val_conv);
13005         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
13006 }
13007
13008 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv * _env, jclass _b, jlong features_arg, jint last_update_arg, jbyteArray rgb_arg, jbyteArray alias_arg, jlongArray addresses_arg, jlong announcement_message_arg) {
13009         LDKNodeFeatures features_arg_conv;
13010         features_arg_conv.inner = (void*)(features_arg & (~1));
13011         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
13012         // Warning: we may need a move here but can't clone!
13013         LDKThreeBytes rgb_arg_ref;
13014         CHECK((*_env)->GetArrayLength (_env, rgb_arg) == 3);
13015         (*_env)->GetByteArrayRegion (_env, rgb_arg, 0, 3, rgb_arg_ref.data);
13016         LDKThirtyTwoBytes alias_arg_ref;
13017         CHECK((*_env)->GetArrayLength (_env, alias_arg) == 32);
13018         (*_env)->GetByteArrayRegion (_env, alias_arg, 0, 32, alias_arg_ref.data);
13019         LDKCVec_NetAddressZ addresses_arg_constr;
13020         addresses_arg_constr.datalen = (*_env)->GetArrayLength (_env, addresses_arg);
13021         if (addresses_arg_constr.datalen > 0)
13022                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13023         else
13024                 addresses_arg_constr.data = NULL;
13025         long* addresses_arg_vals = (*_env)->GetLongArrayElements (_env, addresses_arg, NULL);
13026         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
13027                 long arr_conv_12 = addresses_arg_vals[m];
13028                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
13029                 FREE((void*)arr_conv_12);
13030                 addresses_arg_constr.data[m] = arr_conv_12_conv;
13031         }
13032         (*_env)->ReleaseLongArrayElements (_env, addresses_arg, addresses_arg_vals, 0);
13033         LDKNodeAnnouncement announcement_message_arg_conv;
13034         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
13035         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
13036         if (announcement_message_arg_conv.inner != NULL)
13037                 announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
13038         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
13039         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13040 }
13041
13042 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
13043         LDKNodeAnnouncementInfo obj_conv;
13044         obj_conv.inner = (void*)(obj & (~1));
13045         obj_conv.is_owned = (obj & 1) || (obj == 0);
13046         LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
13047         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
13048         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
13049         CVec_u8Z_free(arg_var);
13050         return arg_arr;
13051 }
13052
13053 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
13054         LDKu8slice ser_ref;
13055         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
13056         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
13057         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_read(ser_ref);
13058         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
13059         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13060 }
13061
13062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
13063         LDKNodeInfo this_ptr_conv;
13064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13065         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13066         NodeInfo_free(this_ptr_conv);
13067 }
13068
13069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
13070         LDKNodeInfo this_ptr_conv;
13071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13072         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13073         LDKCVec_u64Z val_constr;
13074         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
13075         if (val_constr.datalen > 0)
13076                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
13077         else
13078                 val_constr.data = NULL;
13079         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
13080         for (size_t g = 0; g < val_constr.datalen; g++) {
13081                 long arr_conv_6 = val_vals[g];
13082                 val_constr.data[g] = arr_conv_6;
13083         }
13084         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
13085         NodeInfo_set_channels(&this_ptr_conv, val_constr);
13086 }
13087
13088 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
13089         LDKNodeInfo this_ptr_conv;
13090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13091         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13092         LDKRoutingFees ret = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
13093         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13094 }
13095
13096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
13097         LDKNodeInfo this_ptr_conv;
13098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13099         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13100         LDKRoutingFees val_conv;
13101         val_conv.inner = (void*)(val & (~1));
13102         val_conv.is_owned = (val & 1) || (val == 0);
13103         if (val_conv.inner != NULL)
13104                 val_conv = RoutingFees_clone(&val_conv);
13105         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
13106 }
13107
13108 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr) {
13109         LDKNodeInfo this_ptr_conv;
13110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13111         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13112         LDKNodeAnnouncementInfo ret = NodeInfo_get_announcement_info(&this_ptr_conv);
13113         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13114 }
13115
13116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
13117         LDKNodeInfo this_ptr_conv;
13118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13119         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13120         LDKNodeAnnouncementInfo val_conv;
13121         val_conv.inner = (void*)(val & (~1));
13122         val_conv.is_owned = (val & 1) || (val == 0);
13123         // Warning: we may need a move here but can't clone!
13124         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
13125 }
13126
13127 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv * _env, jclass _b, jlongArray channels_arg, jlong lowest_inbound_channel_fees_arg, jlong announcement_info_arg) {
13128         LDKCVec_u64Z channels_arg_constr;
13129         channels_arg_constr.datalen = (*_env)->GetArrayLength (_env, channels_arg);
13130         if (channels_arg_constr.datalen > 0)
13131                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
13132         else
13133                 channels_arg_constr.data = NULL;
13134         long* channels_arg_vals = (*_env)->GetLongArrayElements (_env, channels_arg, NULL);
13135         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
13136                 long arr_conv_6 = channels_arg_vals[g];
13137                 channels_arg_constr.data[g] = arr_conv_6;
13138         }
13139         (*_env)->ReleaseLongArrayElements (_env, channels_arg, channels_arg_vals, 0);
13140         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
13141         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
13142         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
13143         if (lowest_inbound_channel_fees_arg_conv.inner != NULL)
13144                 lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
13145         LDKNodeAnnouncementInfo announcement_info_arg_conv;
13146         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
13147         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
13148         // Warning: we may need a move here but can't clone!
13149         LDKNodeInfo ret = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
13150         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13151 }
13152
13153 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
13154         LDKNodeInfo obj_conv;
13155         obj_conv.inner = (void*)(obj & (~1));
13156         obj_conv.is_owned = (obj & 1) || (obj == 0);
13157         LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
13158         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
13159         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
13160         CVec_u8Z_free(arg_var);
13161         return arg_arr;
13162 }
13163
13164 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
13165         LDKu8slice ser_ref;
13166         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
13167         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
13168         LDKNodeInfo ret = NodeInfo_read(ser_ref);
13169         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
13170         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13171 }
13172
13173 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv * _env, jclass _b, jlong obj) {
13174         LDKNetworkGraph obj_conv;
13175         obj_conv.inner = (void*)(obj & (~1));
13176         obj_conv.is_owned = (obj & 1) || (obj == 0);
13177         LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
13178         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
13179         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
13180         CVec_u8Z_free(arg_var);
13181         return arg_arr;
13182 }
13183
13184 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
13185         LDKu8slice ser_ref;
13186         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
13187         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
13188         LDKNetworkGraph ret = NetworkGraph_read(ser_ref);
13189         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
13190         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13191 }
13192
13193 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv * _env, jclass _b) {
13194         LDKNetworkGraph ret = NetworkGraph_new();
13195         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13196 }
13197
13198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong short_channel_id, jboolean is_permanent) {
13199         LDKNetworkGraph this_arg_conv;
13200         this_arg_conv.inner = (void*)(this_arg & (~1));
13201         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
13202         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
13203 }
13204