Rewrite the world, with several interdependant changes (but several still WIP)
[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) { p = it; it = it->next; }
58         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
59         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
60         DO_ASSERT(it->ptr == ptr);
61         __real_free(it);
62 }
63 static void FREE(void* ptr) {
64         if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
65         alloc_freed(ptr);
66         __real_free(ptr);
67 }
68
69 void* __wrap_malloc(size_t len) {
70         void* res = __real_malloc(len);
71         new_allocation(res, "malloc call");
72         return res;
73 }
74 void* __wrap_calloc(size_t nmemb, size_t len) {
75         void* res = __real_calloc(nmemb, len);
76         new_allocation(res, "calloc call");
77         return res;
78 }
79 void __wrap_free(void* ptr) {
80         alloc_freed(ptr);
81         __real_free(ptr);
82 }
83
84 void* __real_realloc(void* ptr, size_t newlen);
85 void* __wrap_realloc(void* ptr, size_t len) {
86         alloc_freed(ptr);
87         void* res = __real_realloc(ptr, len);
88         new_allocation(res, "realloc call");
89         return res;
90 }
91 void __wrap_reallocarray(void* ptr, size_t new_sz) {
92         // Rust doesn't seem to use reallocarray currently
93         assert(false);
94 }
95
96 void __attribute__((destructor)) check_leaks() {
97         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
98                 fprintf(stderr, "%s %p remains:\n", a->struct_name, a->ptr);
99                 backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
100                 fprintf(stderr, "\n\n");
101         }
102         DO_ASSERT(allocation_ll == NULL);
103 }
104
105 static jmethodID ordinal_meth = NULL;
106 static jmethodID slicedef_meth = NULL;
107 static jclass slicedef_cls = NULL;
108 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
109         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
110         CHECK(ordinal_meth != NULL);
111         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
112         CHECK(slicedef_meth != NULL);
113         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
114         CHECK(slicedef_cls != NULL);
115 }
116
117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
118         return *((bool*)ptr);
119 }
120 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
121         return *((long*)ptr);
122 }
123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
124         FREE((void*)ptr);
125 }
126 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * _env, jclass _b, jlong ptr, jlong len) {
127         jbyteArray ret_arr = (*_env)->NewByteArray(_env, len);
128         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, len, (unsigned char*)ptr);
129         return ret_arr;
130 }
131 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * _env, jclass _b, jlong slice_ptr) {
132         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
133         jbyteArray ret_arr = (*_env)->NewByteArray(_env, slice->datalen);
134         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, slice->datalen, slice->data);
135         return ret_arr;
136 }
137 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_bytes_1to_1u8_1vec (JNIEnv * _env, jclass _b, jbyteArray bytes) {
138         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
139         vec->datalen = (*_env)->GetArrayLength(_env, bytes);
140         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
141         (*_env)->GetByteArrayRegion (_env, bytes, 0, vec->datalen, vec->data);
142         return (long)vec;
143 }
144 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
145         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
146         txdata->datalen = (*env)->GetArrayLength(env, bytes);
147         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
148         txdata->data_is_owned = true;
149         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
150         return (long)txdata;
151 }
152 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
153         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
154         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
155         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
156         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
157         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
158         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
159         return (long)vec->datalen;
160 }
161 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * _env, jclass _b) {
162         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
163         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
164         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
165         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
166         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
167         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
168         vec->data = NULL;
169         vec->datalen = 0;
170         return (long)vec;
171 }
172
173 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
174 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
175 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
176 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
177
178 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass val) {
179         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
180                 case 0: return LDKAccessError_UnknownChain;
181                 case 1: return LDKAccessError_UnknownTx;
182         }
183         abort();
184 }
185 static jclass LDKAccessError_class = NULL;
186 static jfieldID LDKAccessError_LDKAccessError_UnknownChain = NULL;
187 static jfieldID LDKAccessError_LDKAccessError_UnknownTx = NULL;
188 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKAccessError_init (JNIEnv * env, jclass clz) {
189         LDKAccessError_class = (*env)->NewGlobalRef(env, clz);
190         CHECK(LDKAccessError_class != NULL);
191         LDKAccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/LDKAccessError;");
192         CHECK(LDKAccessError_LDKAccessError_UnknownChain != NULL);
193         LDKAccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/LDKAccessError;");
194         CHECK(LDKAccessError_LDKAccessError_UnknownTx != NULL);
195 }
196 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
197         switch (val) {
198                 case LDKAccessError_UnknownChain:
199                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownChain);
200                 case LDKAccessError_UnknownTx:
201                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownTx);
202                 default: abort();
203         }
204 }
205
206 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass val) {
207         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
208                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
209                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
210         }
211         abort();
212 }
213 static jclass LDKChannelMonitorUpdateErr_class = NULL;
214 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
215 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
216 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKChannelMonitorUpdateErr_init (JNIEnv * env, jclass clz) {
217         LDKChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
218         CHECK(LDKChannelMonitorUpdateErr_class != NULL);
219         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
220         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
221         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
222         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
223 }
224 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
225         switch (val) {
226                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
227                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
228                 case LDKChannelMonitorUpdateErr_PermanentFailure:
229                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
230                 default: abort();
231         }
232 }
233
234 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass val) {
235         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
236                 case 0: return LDKConfirmationTarget_Background;
237                 case 1: return LDKConfirmationTarget_Normal;
238                 case 2: return LDKConfirmationTarget_HighPriority;
239         }
240         abort();
241 }
242 static jclass LDKConfirmationTarget_class = NULL;
243 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Background = NULL;
244 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
245 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
246 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKConfirmationTarget_init (JNIEnv * env, jclass clz) {
247         LDKConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
248         CHECK(LDKConfirmationTarget_class != NULL);
249         LDKConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/LDKConfirmationTarget;");
250         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Background != NULL);
251         LDKConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/LDKConfirmationTarget;");
252         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
253         LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/LDKConfirmationTarget;");
254         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
255 }
256 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
257         switch (val) {
258                 case LDKConfirmationTarget_Background:
259                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Background);
260                 case LDKConfirmationTarget_Normal:
261                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Normal);
262                 case LDKConfirmationTarget_HighPriority:
263                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_HighPriority);
264                 default: abort();
265         }
266 }
267
268 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass val) {
269         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
270                 case 0: return LDKLevel_Off;
271                 case 1: return LDKLevel_Error;
272                 case 2: return LDKLevel_Warn;
273                 case 3: return LDKLevel_Info;
274                 case 4: return LDKLevel_Debug;
275                 case 5: return LDKLevel_Trace;
276         }
277         abort();
278 }
279 static jclass LDKLevel_class = NULL;
280 static jfieldID LDKLevel_LDKLevel_Off = NULL;
281 static jfieldID LDKLevel_LDKLevel_Error = NULL;
282 static jfieldID LDKLevel_LDKLevel_Warn = NULL;
283 static jfieldID LDKLevel_LDKLevel_Info = NULL;
284 static jfieldID LDKLevel_LDKLevel_Debug = NULL;
285 static jfieldID LDKLevel_LDKLevel_Trace = NULL;
286 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKLevel_init (JNIEnv * env, jclass clz) {
287         LDKLevel_class = (*env)->NewGlobalRef(env, clz);
288         CHECK(LDKLevel_class != NULL);
289         LDKLevel_LDKLevel_Off = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
290         CHECK(LDKLevel_LDKLevel_Off != NULL);
291         LDKLevel_LDKLevel_Error = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
292         CHECK(LDKLevel_LDKLevel_Error != NULL);
293         LDKLevel_LDKLevel_Warn = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
294         CHECK(LDKLevel_LDKLevel_Warn != NULL);
295         LDKLevel_LDKLevel_Info = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
296         CHECK(LDKLevel_LDKLevel_Info != NULL);
297         LDKLevel_LDKLevel_Debug = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
298         CHECK(LDKLevel_LDKLevel_Debug != NULL);
299         LDKLevel_LDKLevel_Trace = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
300         CHECK(LDKLevel_LDKLevel_Trace != NULL);
301 }
302 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
303         switch (val) {
304                 case LDKLevel_Off:
305                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Off);
306                 case LDKLevel_Error:
307                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Error);
308                 case LDKLevel_Warn:
309                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Warn);
310                 case LDKLevel_Info:
311                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Info);
312                 case LDKLevel_Debug:
313                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Debug);
314                 case LDKLevel_Trace:
315                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Trace);
316                 default: abort();
317         }
318 }
319
320 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass val) {
321         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
322                 case 0: return LDKNetwork_Bitcoin;
323                 case 1: return LDKNetwork_Testnet;
324                 case 2: return LDKNetwork_Regtest;
325         }
326         abort();
327 }
328 static jclass LDKNetwork_class = NULL;
329 static jfieldID LDKNetwork_LDKNetwork_Bitcoin = NULL;
330 static jfieldID LDKNetwork_LDKNetwork_Testnet = NULL;
331 static jfieldID LDKNetwork_LDKNetwork_Regtest = NULL;
332 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKNetwork_init (JNIEnv * env, jclass clz) {
333         LDKNetwork_class = (*env)->NewGlobalRef(env, clz);
334         CHECK(LDKNetwork_class != NULL);
335         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
336         CHECK(LDKNetwork_LDKNetwork_Bitcoin != NULL);
337         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
338         CHECK(LDKNetwork_LDKNetwork_Testnet != NULL);
339         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
340         CHECK(LDKNetwork_LDKNetwork_Regtest != NULL);
341 }
342 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
343         switch (val) {
344                 case LDKNetwork_Bitcoin:
345                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Bitcoin);
346                 case LDKNetwork_Testnet:
347                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Testnet);
348                 case LDKNetwork_Regtest:
349                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Regtest);
350                 default: abort();
351         }
352 }
353
354 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass val) {
355         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
356                 case 0: return LDKSecp256k1Error_IncorrectSignature;
357                 case 1: return LDKSecp256k1Error_InvalidMessage;
358                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
359                 case 3: return LDKSecp256k1Error_InvalidSignature;
360                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
361                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
362                 case 6: return LDKSecp256k1Error_InvalidTweak;
363                 case 7: return LDKSecp256k1Error_NotEnoughMemory;
364                 case 8: return LDKSecp256k1Error_CallbackPanicked;
365         }
366         abort();
367 }
368 static jclass LDKSecp256k1Error_class = NULL;
369 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
370 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
371 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
372 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
373 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
374 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
375 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
376 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
377 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = NULL;
378 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKSecp256k1Error_init (JNIEnv * env, jclass clz) {
379         LDKSecp256k1Error_class = (*env)->NewGlobalRef(env, clz);
380         CHECK(LDKSecp256k1Error_class != NULL);
381         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
382         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
383         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
384         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
385         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
386         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
387         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
388         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
389         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
390         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
391         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
392         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
393         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
394         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
395         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
396         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
397         LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_CallbackPanicked", "Lorg/ldk/enums/LDKSecp256k1Error;");
398         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked != NULL);
399 }
400 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
401         switch (val) {
402                 case LDKSecp256k1Error_IncorrectSignature:
403                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature);
404                 case LDKSecp256k1Error_InvalidMessage:
405                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage);
406                 case LDKSecp256k1Error_InvalidPublicKey:
407                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
408                 case LDKSecp256k1Error_InvalidSignature:
409                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature);
410                 case LDKSecp256k1Error_InvalidSecretKey:
411                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
412                 case LDKSecp256k1Error_InvalidRecoveryId:
413                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
414                 case LDKSecp256k1Error_InvalidTweak:
415                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak);
416                 case LDKSecp256k1Error_NotEnoughMemory:
417                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
418                 case LDKSecp256k1Error_CallbackPanicked:
419                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked);
420                 default: abort();
421         }
422 }
423
424 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u8_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
425         LDKCVecTempl_u8 *vec = (LDKCVecTempl_u8*)ptr;
426         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint8_t));
427 }
428 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u8_1new(JNIEnv *env, jclass _b, jbyteArray elems){
429         LDKCVecTempl_u8 *ret = MALLOC(sizeof(LDKCVecTempl_u8), "LDKCVecTempl_u8");
430         ret->datalen = (*env)->GetArrayLength(env, elems);
431         if (ret->datalen == 0) {
432                 ret->data = NULL;
433         } else {
434                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVecTempl_u8 Data");
435                 jbyte *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
436                 for (size_t i = 0; i < ret->datalen; i++) {
437                         ret->data[i] = java_elems[i];
438                 }
439                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
440         }
441         return (long)ret;
442 }
443 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
444         LDKC2TupleTempl_usize__Transaction* ret = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction), "LDKC2TupleTempl_usize__Transaction");
445         ret->a = a;
446         LDKTransaction b_conv = *(LDKTransaction*)b;
447         FREE((void*)b);
448         ret->b = b_conv;
449         return (long)ret;
450 }
451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
452         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
453 }
454 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
455         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
456         CHECK(val->result_ok);
457         return *val->contents.result;
458 }
459 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
460         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
461         CHECK(!val->result_ok);
462         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(_env, (*val->contents.err));
463         return err_conv;
464 }
465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
466         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
467 }
468 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
469         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
470         CHECK(val->result_ok);
471         return *val->contents.result;
472 }
473 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
474         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
475         CHECK(!val->result_ok);
476         LDKMonitorUpdateError err_var = (*val->contents.err);
477         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
478         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
479         long err_ref;
480         if (err_var.is_owned) {
481                 err_ref = (long)err_var.inner | 1;
482         } else {
483                 err_ref = (long)&err_var;
484         }
485         return err_ref;
486 }
487 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) {
488         LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z");
489         LDKOutPoint a_conv;
490         a_conv.inner = (void*)(a & (~1));
491         a_conv.is_owned = (a & 1) || (a == 0);
492         if (a_conv.inner != NULL)
493                 a_conv = OutPoint_clone(&a_conv);
494         ret->a = a_conv;
495         LDKCVec_u8Z b_ref;
496         b_ref.data = (*_env)->GetByteArrayElements (_env, b, NULL);
497         b_ref.datalen = (*_env)->GetArrayLength (_env, b);
498         ret->b = b_ref;
499         //TODO: Really need to call (*_env)->ReleaseByteArrayElements(_env, b, (int8_t*)b_ref.data, 0); here
500         return (long)ret;
501 }
502 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
503         LDKCVecTempl_TxOut *vec = (LDKCVecTempl_TxOut*)ptr;
504         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTxOut));
505 }
506 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
507         LDKCVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_TxOut), "LDKCVecTempl_TxOut");
508         ret->datalen = (*env)->GetArrayLength(env, elems);
509         if (ret->datalen == 0) {
510                 ret->data = NULL;
511         } else {
512                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVecTempl_TxOut Data");
513                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
514                 for (size_t i = 0; i < ret->datalen; i++) {
515                         jlong arr_elem = java_elems[i];
516                         LDKTxOut arr_elem_conv = *(LDKTxOut*)arr_elem;
517                         FREE((void*)arr_elem);
518                         ret->data[i] = arr_elem_conv;
519                 }
520                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
521         }
522         return (long)ret;
523 }
524 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlongArray b) {
525         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut* ret = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
526         LDKThirtyTwoBytes a_ref;
527         CHECK((*_env)->GetArrayLength (_env, a) == 32);
528         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
529         ret->a = a_ref;
530         LDKCVecTempl_TxOut b_constr;
531         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
532         if (b_constr.datalen > 0)
533                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKTxOut), "LDKCVecTempl_TxOut Elements");
534         else
535                 b_constr.data = NULL;
536         long* b_vals = (*_env)->GetLongArrayElements (_env, b, NULL);
537         for (size_t h = 0; h < b_constr.datalen; h++) {
538                 long arr_conv_7 = b_vals[h];
539                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
540                 FREE((void*)arr_conv_7);
541                 b_constr.data[h] = arr_conv_7_conv;
542         }
543         (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0);
544         ret->b = b_constr;
545         return (long)ret;
546 }
547 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
548         LDKC2TupleTempl_u64__u64* ret = MALLOC(sizeof(LDKC2TupleTempl_u64__u64), "LDKC2TupleTempl_u64__u64");
549         ret->a = a;
550         ret->b = b;
551         return (long)ret;
552 }
553 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
554         LDKCVecTempl_Signature *vec = (LDKCVecTempl_Signature*)ptr;
555         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSignature));
556 }
557 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jbyteArray a, jobjectArray b) {
558         LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature");
559         LDKSignature a_ref;
560         CHECK((*_env)->GetArrayLength (_env, a) == 64);
561         (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form);
562         ret->a = a_ref;
563         LDKCVecTempl_Signature b_constr;
564         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
565         if (b_constr.datalen > 0)
566                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVecTempl_Signature Elements");
567         else
568                 b_constr.data = NULL;
569         for (size_t i = 0; i < b_constr.datalen; i++) {
570                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, b, i);
571                 LDKSignature arr_conv_8_ref;
572                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
573                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
574                 b_constr.data[i] = arr_conv_8_ref;
575         }
576         ret->b = b_constr;
577         return (long)ret;
578 }
579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
580         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
581 }
582 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
583         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
584         CHECK(val->result_ok);
585         long res_ref = (long)&(*val->contents.result);
586         return res_ref;
587 }
588 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
589         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
590         CHECK(!val->result_ok);
591         return *val->contents.err;
592 }
593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
594         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
595 }
596 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
597         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
598         CHECK(val->result_ok);
599         jbyteArray res_arr = (*_env)->NewByteArray(_env, 64);
600         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 64, (*val->contents.result).compact_form);
601         return res_arr;
602 }
603 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
604         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
605         CHECK(!val->result_ok);
606         return *val->contents.err;
607 }
608 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
609         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
610 }
611 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
612         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
613         CHECK(val->result_ok);
614         LDKCVecTempl_Signature res_var = (*val->contents.result);
615         jobjectArray res_arr = (*_env)->NewObjectArray(_env, res_var.datalen, NULL, NULL);
616         for (size_t i = 0; i < res_var.datalen; i++) {
617                 jbyteArray arr_conv_8_arr = (*_env)->NewByteArray(_env, 64);
618                 (*_env)->SetByteArrayRegion(_env, arr_conv_8_arr, 0, 64, res_var.data[i].compact_form);
619                 (*_env)->SetObjectArrayElement(_env, res_arr, i, arr_conv_8_arr);}
620         return res_arr;
621 }
622 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
623         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
624         CHECK(!val->result_ok);
625         return *val->contents.err;
626 }
627 static jclass LDKAPIError_APIMisuseError_class = NULL;
628 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
629 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
630 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
631 static jclass LDKAPIError_RouteError_class = NULL;
632 static jmethodID LDKAPIError_RouteError_meth = NULL;
633 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
634 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
635 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
636 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv * env, jclass _a) {
638         LDKAPIError_APIMisuseError_class =
639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
640         CHECK(LDKAPIError_APIMisuseError_class != NULL);
641         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
642         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
643         LDKAPIError_FeeRateTooHigh_class =
644                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
645         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
646         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
647         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
648         LDKAPIError_RouteError_class =
649                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
650         CHECK(LDKAPIError_RouteError_class != NULL);
651         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
652         CHECK(LDKAPIError_RouteError_meth != NULL);
653         LDKAPIError_ChannelUnavailable_class =
654                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
655         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
656         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
657         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
658         LDKAPIError_MonitorUpdateFailed_class =
659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
660         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
661         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
662         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
663 }
664 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
665         LDKAPIError *obj = (LDKAPIError*)ptr;
666         switch(obj->tag) {
667                 case LDKAPIError_APIMisuseError: {
668                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
669                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
670                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
671                         return (*_env)->NewObject(_env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
672                 }
673                 case LDKAPIError_FeeRateTooHigh: {
674                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
675                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
676                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
677                         return (*_env)->NewObject(_env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
678                 }
679                 case LDKAPIError_RouteError: {
680                         LDKStr err_str = obj->route_error.err;
681                         char* err_buf = MALLOC(err_str.len + 1, "str conv buf");
682                         memcpy(err_buf, err_str.chars, err_str.len);
683                         err_buf[err_str.len] = 0;
684                         jstring err_conv = (*_env)->NewStringUTF(_env, err_str.chars);
685                         FREE(err_buf);
686                         return (*_env)->NewObject(_env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
687                 }
688                 case LDKAPIError_ChannelUnavailable: {
689                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
690                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
691                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
692                         return (*_env)->NewObject(_env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
693                 }
694                 case LDKAPIError_MonitorUpdateFailed: {
695                         return (*_env)->NewObject(_env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
696                 }
697                 default: abort();
698         }
699 }
700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
701         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
702 }
703 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
704         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
705         CHECK(val->result_ok);
706         return *val->contents.result;
707 }
708 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
709         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
710         CHECK(!val->result_ok);
711         long err_ref = (long)&(*val->contents.err);
712         return err_ref;
713 }
714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
715         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
716 }
717 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
718         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
719         CHECK(val->result_ok);
720         return *val->contents.result;
721 }
722 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
723         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
724         CHECK(!val->result_ok);
725         LDKPaymentSendFailure err_var = (*val->contents.err);
726         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
727         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
728         long err_ref;
729         if (err_var.is_owned) {
730                 err_ref = (long)err_var.inner | 1;
731         } else {
732                 err_ref = (long)&err_var;
733         }
734         return err_ref;
735 }
736 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) {
737         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate* ret = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
738         LDKChannelAnnouncement a_conv;
739         a_conv.inner = (void*)(a & (~1));
740         a_conv.is_owned = (a & 1) || (a == 0);
741         if (a_conv.inner != NULL)
742                 a_conv = ChannelAnnouncement_clone(&a_conv);
743         ret->a = a_conv;
744         LDKChannelUpdate b_conv;
745         b_conv.inner = (void*)(b & (~1));
746         b_conv.is_owned = (b & 1) || (b == 0);
747         if (b_conv.inner != NULL)
748                 b_conv = ChannelUpdate_clone(&b_conv);
749         ret->b = b_conv;
750         LDKChannelUpdate c_conv;
751         c_conv.inner = (void*)(c & (~1));
752         c_conv.is_owned = (c & 1) || (c == 0);
753         if (c_conv.inner != NULL)
754                 c_conv = ChannelUpdate_clone(&c_conv);
755         ret->c = c_conv;
756         return (long)ret;
757 }
758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
759         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
760 }
761 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
762         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
763         CHECK(val->result_ok);
764         return *val->contents.result;
765 }
766 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
767         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
768         CHECK(!val->result_ok);
769         LDKPeerHandleError err_var = (*val->contents.err);
770         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
771         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
772         long err_ref;
773         if (err_var.is_owned) {
774                 err_ref = (long)err_var.inner | 1;
775         } else {
776                 err_ref = (long)&err_var;
777         }
778         return err_ref;
779 }
780 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) {
781         LDKC2TupleTempl_HTLCOutputInCommitment__Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature), "LDKC2TupleTempl_HTLCOutputInCommitment__Signature");
782         LDKHTLCOutputInCommitment a_conv;
783         a_conv.inner = (void*)(a & (~1));
784         a_conv.is_owned = (a & 1) || (a == 0);
785         if (a_conv.inner != NULL)
786                 a_conv = HTLCOutputInCommitment_clone(&a_conv);
787         ret->a = a_conv;
788         LDKSignature b_ref;
789         CHECK((*_env)->GetArrayLength (_env, b) == 64);
790         (*_env)->GetByteArrayRegion (_env, b, 0, 64, b_ref.compact_form);
791         ret->b = b_ref;
792         return (long)ret;
793 }
794 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
795 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
796 static jclass LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class = NULL;
797 static jmethodID LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = NULL;
798 static jclass LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class = NULL;
799 static jmethodID LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = NULL;
800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv * env, jclass _a) {
801         LDKSpendableOutputDescriptor_StaticOutput_class =
802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
803         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
804         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
805         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
806         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class =
807                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DynamicOutputP2WSH;"));
808         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class != NULL);
809         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, "<init>", "(J[BSJJ[B)V");
810         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth != NULL);
811         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class =
812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutputCounterpartyPayment;"));
813         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class != NULL);
814         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, "<init>", "(JJJ)V");
815         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth != NULL);
816 }
817 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
818         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
819         switch(obj->tag) {
820                 case LDKSpendableOutputDescriptor_StaticOutput: {
821                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
822                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
823                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
824                         long outpoint_ref;
825                         if (outpoint_var.is_owned) {
826                                 outpoint_ref = (long)outpoint_var.inner | 1;
827                         } else {
828                                 outpoint_ref = (long)&outpoint_var;
829                         }
830                         long output_ref = (long)&obj->static_output.output;
831                         return (*_env)->NewObject(_env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, output_ref);
832                 }
833                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
834                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
835                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
836                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
837                         long outpoint_ref;
838                         if (outpoint_var.is_owned) {
839                                 outpoint_ref = (long)outpoint_var.inner | 1;
840                         } else {
841                                 outpoint_ref = (long)&outpoint_var;
842                         }
843                         jbyteArray per_commitment_point_arr = (*_env)->NewByteArray(_env, 33);
844                         (*_env)->SetByteArrayRegion(_env, per_commitment_point_arr, 0, 33, obj->dynamic_output_p2wsh.per_commitment_point.compressed_form);
845                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
846                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
847                         jbyteArray revocation_pubkey_arr = (*_env)->NewByteArray(_env, 33);
848                         (*_env)->SetByteArrayRegion(_env, revocation_pubkey_arr, 0, 33, obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form);
849                         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);
850                 }
851                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
852                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
853                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
854                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
855                         long outpoint_ref;
856                         if (outpoint_var.is_owned) {
857                                 outpoint_ref = (long)outpoint_var.inner | 1;
858                         } else {
859                                 outpoint_ref = (long)&outpoint_var;
860                         }
861                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
862                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
863                         return (*_env)->NewObject(_env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth, outpoint_ref, output_ref, key_derivation_params_ref);
864                 }
865                 default: abort();
866         }
867 }
868 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
869         LDKCVecTempl_SpendableOutputDescriptor *vec = (LDKCVecTempl_SpendableOutputDescriptor*)ptr;
870         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSpendableOutputDescriptor));
871 }
872 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1new(JNIEnv *env, jclass _b, jlongArray elems){
873         LDKCVecTempl_SpendableOutputDescriptor *ret = MALLOC(sizeof(LDKCVecTempl_SpendableOutputDescriptor), "LDKCVecTempl_SpendableOutputDescriptor");
874         ret->datalen = (*env)->GetArrayLength(env, elems);
875         if (ret->datalen == 0) {
876                 ret->data = NULL;
877         } else {
878                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVecTempl_SpendableOutputDescriptor Data");
879                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
880                 for (size_t i = 0; i < ret->datalen; i++) {
881                         jlong arr_elem = java_elems[i];
882                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
883                         FREE((void*)arr_elem);
884                         ret->data[i] = arr_elem_conv;
885                 }
886                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
887         }
888         return (long)ret;
889 }
890 static jclass LDKEvent_FundingGenerationReady_class = NULL;
891 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
892 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
893 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
894 static jclass LDKEvent_PaymentReceived_class = NULL;
895 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
896 static jclass LDKEvent_PaymentSent_class = NULL;
897 static jmethodID LDKEvent_PaymentSent_meth = NULL;
898 static jclass LDKEvent_PaymentFailed_class = NULL;
899 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
900 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
901 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
902 static jclass LDKEvent_SpendableOutputs_class = NULL;
903 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv * env, jclass _a) {
905         LDKEvent_FundingGenerationReady_class =
906                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
907         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
908         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
909         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
910         LDKEvent_FundingBroadcastSafe_class =
911                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
912         CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
913         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
914         CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
915         LDKEvent_PaymentReceived_class =
916                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
917         CHECK(LDKEvent_PaymentReceived_class != NULL);
918         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
919         CHECK(LDKEvent_PaymentReceived_meth != NULL);
920         LDKEvent_PaymentSent_class =
921                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
922         CHECK(LDKEvent_PaymentSent_class != NULL);
923         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
924         CHECK(LDKEvent_PaymentSent_meth != NULL);
925         LDKEvent_PaymentFailed_class =
926                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
927         CHECK(LDKEvent_PaymentFailed_class != NULL);
928         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
929         CHECK(LDKEvent_PaymentFailed_meth != NULL);
930         LDKEvent_PendingHTLCsForwardable_class =
931                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
932         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
933         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
934         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
935         LDKEvent_SpendableOutputs_class =
936                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
937         CHECK(LDKEvent_SpendableOutputs_class != NULL);
938         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
939         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
940 }
941 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
942         LDKEvent *obj = (LDKEvent*)ptr;
943         switch(obj->tag) {
944                 case LDKEvent_FundingGenerationReady: {
945                         jbyteArray temporary_channel_id_arr = (*_env)->NewByteArray(_env, 32);
946                         (*_env)->SetByteArrayRegion(_env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
947                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
948                         jbyteArray output_script_arr = (*_env)->NewByteArray(_env, output_script_var.datalen);
949                         (*_env)->SetByteArrayRegion(_env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
950                         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);
951                 }
952                 case LDKEvent_FundingBroadcastSafe: {
953                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
954                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
955                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
956                         long funding_txo_ref;
957                         if (funding_txo_var.is_owned) {
958                                 funding_txo_ref = (long)funding_txo_var.inner | 1;
959                         } else {
960                                 funding_txo_ref = (long)&funding_txo_var;
961                         }
962                         return (*_env)->NewObject(_env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
963                 }
964                 case LDKEvent_PaymentReceived: {
965                         jbyteArray payment_hash_arr = (*_env)->NewByteArray(_env, 32);
966                         (*_env)->SetByteArrayRegion(_env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
967                         jbyteArray payment_secret_arr = (*_env)->NewByteArray(_env, 32);
968                         (*_env)->SetByteArrayRegion(_env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
969                         return (*_env)->NewObject(_env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
970                 }
971                 case LDKEvent_PaymentSent: {
972                         jbyteArray payment_preimage_arr = (*_env)->NewByteArray(_env, 32);
973                         (*_env)->SetByteArrayRegion(_env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
974                         return (*_env)->NewObject(_env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
975                 }
976                 case LDKEvent_PaymentFailed: {
977                         jbyteArray payment_hash_arr = (*_env)->NewByteArray(_env, 32);
978                         (*_env)->SetByteArrayRegion(_env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
979                         return (*_env)->NewObject(_env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
980                 }
981                 case LDKEvent_PendingHTLCsForwardable: {
982                         return (*_env)->NewObject(_env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
983                 }
984                 case LDKEvent_SpendableOutputs: {
985                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
986                         jlongArray outputs_arr = (*_env)->NewLongArray(_env, outputs_var.datalen);
987                         jlong *outputs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, outputs_arr, NULL);
988                         for (size_t b = 0; b < outputs_var.datalen; b++) {
989                                 long arr_conv_27_ref = (long)&outputs_var.data[b];
990                                 outputs_arr_ptr[b] = arr_conv_27_ref;
991                         }
992                         (*_env)->ReleasePrimitiveArrayCritical(_env, outputs_arr, outputs_arr_ptr, 0);
993                         return (*_env)->NewObject(_env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
994                 }
995                 default: abort();
996         }
997 }
998 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
999 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1000 static jclass LDKErrorAction_IgnoreError_class = NULL;
1001 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1002 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1003 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv * env, jclass _a) {
1005         LDKErrorAction_DisconnectPeer_class =
1006                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1007         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1008         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1009         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1010         LDKErrorAction_IgnoreError_class =
1011                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1012         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1013         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1014         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1015         LDKErrorAction_SendErrorMessage_class =
1016                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1017         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1018         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1019         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1020 }
1021 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
1022         LDKErrorAction *obj = (LDKErrorAction*)ptr;
1023         switch(obj->tag) {
1024                 case LDKErrorAction_DisconnectPeer: {
1025                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1026                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1027                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1028                         long msg_ref;
1029                         if (msg_var.is_owned) {
1030                                 msg_ref = (long)msg_var.inner | 1;
1031                         } else {
1032                                 msg_ref = (long)&msg_var;
1033                         }
1034                         return (*_env)->NewObject(_env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1035                 }
1036                 case LDKErrorAction_IgnoreError: {
1037                         return (*_env)->NewObject(_env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1038                 }
1039                 case LDKErrorAction_SendErrorMessage: {
1040                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1041                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1042                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1043                         long msg_ref;
1044                         if (msg_var.is_owned) {
1045                                 msg_ref = (long)msg_var.inner | 1;
1046                         } else {
1047                                 msg_ref = (long)&msg_var;
1048                         }
1049                         return (*_env)->NewObject(_env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1050                 }
1051                 default: abort();
1052         }
1053 }
1054 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1055 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1056 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1057 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1058 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1059 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv * env, jclass _a) {
1061         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1062                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1063         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1064         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1065         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1066         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1067                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1068         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1069         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1070         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1071         LDKHTLCFailChannelUpdate_NodeFailure_class =
1072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1073         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1074         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1075         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1076 }
1077 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
1078         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
1079         switch(obj->tag) {
1080                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1081                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1082                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1083                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1084                         long msg_ref;
1085                         if (msg_var.is_owned) {
1086                                 msg_ref = (long)msg_var.inner | 1;
1087                         } else {
1088                                 msg_ref = (long)&msg_var;
1089                         }
1090                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1091                 }
1092                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1093                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1094                 }
1095                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1096                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1097                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1098                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1099                 }
1100                 default: abort();
1101         }
1102 }
1103 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1104 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1105 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1106 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1107 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1108 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1109 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1110 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1111 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1112 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1113 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1114 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1115 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1116 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1117 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1118 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1119 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1120 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1121 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1122 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1123 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1124 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1125 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1126 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1127 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1128 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1129 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1130 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1131 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1132 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1133 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1134 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv * env, jclass _a) {
1136         LDKMessageSendEvent_SendAcceptChannel_class =
1137                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1138         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1139         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1140         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1141         LDKMessageSendEvent_SendOpenChannel_class =
1142                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1143         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1144         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1145         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1146         LDKMessageSendEvent_SendFundingCreated_class =
1147                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1148         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1149         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1150         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1151         LDKMessageSendEvent_SendFundingSigned_class =
1152                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1153         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1154         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1155         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1156         LDKMessageSendEvent_SendFundingLocked_class =
1157                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1158         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1159         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1160         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1161         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1162                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1163         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1164         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1165         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1166         LDKMessageSendEvent_UpdateHTLCs_class =
1167                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1168         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1169         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1170         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1171         LDKMessageSendEvent_SendRevokeAndACK_class =
1172                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1173         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1174         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1175         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1176         LDKMessageSendEvent_SendClosingSigned_class =
1177                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1178         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1179         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1180         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1181         LDKMessageSendEvent_SendShutdown_class =
1182                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1183         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1184         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1185         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1186         LDKMessageSendEvent_SendChannelReestablish_class =
1187                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1188         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1189         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1190         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1191         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1192                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1193         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1194         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1195         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1196         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1197                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1198         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1199         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1200         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1201         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1202                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1203         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1204         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1205         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1206         LDKMessageSendEvent_HandleError_class =
1207                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1208         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1209         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1210         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1211         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1212                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1213         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1214         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1215         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1216 }
1217 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
1218         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1219         switch(obj->tag) {
1220                 case LDKMessageSendEvent_SendAcceptChannel: {
1221                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1222                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1223                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1224                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1225                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1226                         long msg_ref;
1227                         if (msg_var.is_owned) {
1228                                 msg_ref = (long)msg_var.inner | 1;
1229                         } else {
1230                                 msg_ref = (long)&msg_var;
1231                         }
1232                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1233                 }
1234                 case LDKMessageSendEvent_SendOpenChannel: {
1235                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1236                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1237                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1238                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1239                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1240                         long msg_ref;
1241                         if (msg_var.is_owned) {
1242                                 msg_ref = (long)msg_var.inner | 1;
1243                         } else {
1244                                 msg_ref = (long)&msg_var;
1245                         }
1246                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1247                 }
1248                 case LDKMessageSendEvent_SendFundingCreated: {
1249                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1250                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1251                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1252                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1253                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1254                         long msg_ref;
1255                         if (msg_var.is_owned) {
1256                                 msg_ref = (long)msg_var.inner | 1;
1257                         } else {
1258                                 msg_ref = (long)&msg_var;
1259                         }
1260                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1261                 }
1262                 case LDKMessageSendEvent_SendFundingSigned: {
1263                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1264                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1265                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1266                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1267                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1268                         long msg_ref;
1269                         if (msg_var.is_owned) {
1270                                 msg_ref = (long)msg_var.inner | 1;
1271                         } else {
1272                                 msg_ref = (long)&msg_var;
1273                         }
1274                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1275                 }
1276                 case LDKMessageSendEvent_SendFundingLocked: {
1277                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1278                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1279                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1280                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1281                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1282                         long msg_ref;
1283                         if (msg_var.is_owned) {
1284                                 msg_ref = (long)msg_var.inner | 1;
1285                         } else {
1286                                 msg_ref = (long)&msg_var;
1287                         }
1288                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1289                 }
1290                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1291                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1292                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1293                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1294                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1295                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1296                         long msg_ref;
1297                         if (msg_var.is_owned) {
1298                                 msg_ref = (long)msg_var.inner | 1;
1299                         } else {
1300                                 msg_ref = (long)&msg_var;
1301                         }
1302                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1303                 }
1304                 case LDKMessageSendEvent_UpdateHTLCs: {
1305                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1306                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1307                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1308                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1309                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1310                         long updates_ref;
1311                         if (updates_var.is_owned) {
1312                                 updates_ref = (long)updates_var.inner | 1;
1313                         } else {
1314                                 updates_ref = (long)&updates_var;
1315                         }
1316                         return (*_env)->NewObject(_env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1317                 }
1318                 case LDKMessageSendEvent_SendRevokeAndACK: {
1319                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1320                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1321                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1322                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1323                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1324                         long msg_ref;
1325                         if (msg_var.is_owned) {
1326                                 msg_ref = (long)msg_var.inner | 1;
1327                         } else {
1328                                 msg_ref = (long)&msg_var;
1329                         }
1330                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1331                 }
1332                 case LDKMessageSendEvent_SendClosingSigned: {
1333                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1334                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1335                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1336                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1337                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1338                         long msg_ref;
1339                         if (msg_var.is_owned) {
1340                                 msg_ref = (long)msg_var.inner | 1;
1341                         } else {
1342                                 msg_ref = (long)&msg_var;
1343                         }
1344                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1345                 }
1346                 case LDKMessageSendEvent_SendShutdown: {
1347                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1348                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1349                         LDKShutdown msg_var = obj->send_shutdown.msg;
1350                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1351                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1352                         long msg_ref;
1353                         if (msg_var.is_owned) {
1354                                 msg_ref = (long)msg_var.inner | 1;
1355                         } else {
1356                                 msg_ref = (long)&msg_var;
1357                         }
1358                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1359                 }
1360                 case LDKMessageSendEvent_SendChannelReestablish: {
1361                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1362                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1363                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1364                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1365                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1366                         long msg_ref;
1367                         if (msg_var.is_owned) {
1368                                 msg_ref = (long)msg_var.inner | 1;
1369                         } else {
1370                                 msg_ref = (long)&msg_var;
1371                         }
1372                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1373                 }
1374                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1375                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1376                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1377                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1378                         long msg_ref;
1379                         if (msg_var.is_owned) {
1380                                 msg_ref = (long)msg_var.inner | 1;
1381                         } else {
1382                                 msg_ref = (long)&msg_var;
1383                         }
1384                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1385                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1386                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1387                         long update_msg_ref;
1388                         if (update_msg_var.is_owned) {
1389                                 update_msg_ref = (long)update_msg_var.inner | 1;
1390                         } else {
1391                                 update_msg_ref = (long)&update_msg_var;
1392                         }
1393                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1394                 }
1395                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1396                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1397                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1398                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1399                         long msg_ref;
1400                         if (msg_var.is_owned) {
1401                                 msg_ref = (long)msg_var.inner | 1;
1402                         } else {
1403                                 msg_ref = (long)&msg_var;
1404                         }
1405                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1406                 }
1407                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1408                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1409                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1410                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1411                         long msg_ref;
1412                         if (msg_var.is_owned) {
1413                                 msg_ref = (long)msg_var.inner | 1;
1414                         } else {
1415                                 msg_ref = (long)&msg_var;
1416                         }
1417                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1418                 }
1419                 case LDKMessageSendEvent_HandleError: {
1420                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1421                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1422                         long action_ref = (long)&obj->handle_error.action;
1423                         return (*_env)->NewObject(_env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1424                 }
1425                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1426                         long update_ref = (long)&obj->payment_failure_network_update.update;
1427                         return (*_env)->NewObject(_env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1428                 }
1429                 default: abort();
1430         }
1431 }
1432 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1433         LDKCVecTempl_MessageSendEvent *vec = (LDKCVecTempl_MessageSendEvent*)ptr;
1434         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKMessageSendEvent));
1435 }
1436 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1437         LDKCVecTempl_MessageSendEvent *ret = MALLOC(sizeof(LDKCVecTempl_MessageSendEvent), "LDKCVecTempl_MessageSendEvent");
1438         ret->datalen = (*env)->GetArrayLength(env, elems);
1439         if (ret->datalen == 0) {
1440                 ret->data = NULL;
1441         } else {
1442                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVecTempl_MessageSendEvent 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                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)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 LDKMessageSendEventsProvider_JCalls {
1455         atomic_size_t refcnt;
1456         JavaVM *vm;
1457         jweak o;
1458         jmethodID get_and_clear_pending_msg_events_meth;
1459 } LDKMessageSendEventsProvider_JCalls;
1460 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
1461         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_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_msg_events_meth);
1467         LDKCVec_MessageSendEventZ 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(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
1471         else
1472                 ret_constr.data = NULL;
1473         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
1474         for (size_t s = 0; s < ret_constr.datalen; s++) {
1475                 long arr_conv_18 = ret_vals[s];
1476                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
1477                 FREE((void*)arr_conv_18);
1478                 ret_constr.data[s] = arr_conv_18_conv;
1479         }
1480         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
1481         return ret_constr;
1482 }
1483 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
1484         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_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* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
1493         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1494         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1495         return (void*) this_arg;
1496 }
1497 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1498         jclass c = (*env)->GetObjectClass(env, o);
1499         CHECK(c != NULL);
1500         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_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_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
1505         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
1506
1507         LDKMessageSendEventsProvider ret = {
1508                 .this_arg = (void*) calls,
1509                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
1510                 .free = LDKMessageSendEventsProvider_JCalls_free,
1511         };
1512         return ret;
1513 }
1514 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1515         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
1516         *res_ptr = LDKMessageSendEventsProvider_init(env, _a, o);
1517         return (long)res_ptr;
1518 }
1519 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1520         jobject ret = (*env)->NewLocalRef(env, ((LDKMessageSendEventsProvider_JCalls*)val)->o);
1521         CHECK(ret != NULL);
1522         return ret;
1523 }
1524 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
1525         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
1526         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_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 s = 0; s < ret_var.datalen; s++) {
1530                 long arr_conv_18_ref = (long)&ret_var.data[s];
1531                 ret_arr_ptr[s] = arr_conv_18_ref;
1532         }
1533         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
1534         return ret_arr;
1535 }
1536
1537 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1538         LDKCVecTempl_Event *vec = (LDKCVecTempl_Event*)ptr;
1539         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKEvent));
1540 }
1541 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1new(JNIEnv *env, jclass _b, jlongArray elems){
1542         LDKCVecTempl_Event *ret = MALLOC(sizeof(LDKCVecTempl_Event), "LDKCVecTempl_Event");
1543         ret->datalen = (*env)->GetArrayLength(env, elems);
1544         if (ret->datalen == 0) {
1545                 ret->data = NULL;
1546         } else {
1547                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVecTempl_Event Data");
1548                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1549                 for (size_t i = 0; i < ret->datalen; i++) {
1550                         jlong arr_elem = java_elems[i];
1551                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
1552                         FREE((void*)arr_elem);
1553                         ret->data[i] = arr_elem_conv;
1554                 }
1555                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1556         }
1557         return (long)ret;
1558 }
1559 typedef struct LDKEventsProvider_JCalls {
1560         atomic_size_t refcnt;
1561         JavaVM *vm;
1562         jweak o;
1563         jmethodID get_and_clear_pending_events_meth;
1564 } LDKEventsProvider_JCalls;
1565 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
1566         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1567         JNIEnv *_env;
1568         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1569         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1570         CHECK(obj != NULL);
1571         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_and_clear_pending_events_meth);
1572         LDKCVec_EventZ ret_constr;
1573         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
1574         if (ret_constr.datalen > 0)
1575                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
1576         else
1577                 ret_constr.data = NULL;
1578         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
1579         for (size_t h = 0; h < ret_constr.datalen; h++) {
1580                 long arr_conv_7 = ret_vals[h];
1581                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
1582                 FREE((void*)arr_conv_7);
1583                 ret_constr.data[h] = arr_conv_7_conv;
1584         }
1585         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
1586         return ret_constr;
1587 }
1588 static void LDKEventsProvider_JCalls_free(void* this_arg) {
1589         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1590         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1591                 JNIEnv *env;
1592                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1593                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1594                 FREE(j_calls);
1595         }
1596 }
1597 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
1598         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1599         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1600         return (void*) this_arg;
1601 }
1602 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1603         jclass c = (*env)->GetObjectClass(env, o);
1604         CHECK(c != NULL);
1605         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
1606         atomic_init(&calls->refcnt, 1);
1607         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1608         calls->o = (*env)->NewWeakGlobalRef(env, o);
1609         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
1610         CHECK(calls->get_and_clear_pending_events_meth != NULL);
1611
1612         LDKEventsProvider ret = {
1613                 .this_arg = (void*) calls,
1614                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
1615                 .free = LDKEventsProvider_JCalls_free,
1616         };
1617         return ret;
1618 }
1619 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1620         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
1621         *res_ptr = LDKEventsProvider_init(env, _a, o);
1622         return (long)res_ptr;
1623 }
1624 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1625         jobject ret = (*env)->NewLocalRef(env, ((LDKEventsProvider_JCalls*)val)->o);
1626         CHECK(ret != NULL);
1627         return ret;
1628 }
1629 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
1630         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
1631         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
1632         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
1633         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
1634         for (size_t h = 0; h < ret_var.datalen; h++) {
1635                 long arr_conv_7_ref = (long)&ret_var.data[h];
1636                 ret_arr_ptr[h] = arr_conv_7_ref;
1637         }
1638         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
1639         return ret_arr;
1640 }
1641
1642 typedef struct LDKLogger_JCalls {
1643         atomic_size_t refcnt;
1644         JavaVM *vm;
1645         jweak o;
1646         jmethodID log_meth;
1647 } LDKLogger_JCalls;
1648 void log_jcall(const void* this_arg, const char *record) {
1649         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1650         JNIEnv *_env;
1651         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1652         jstring record_conv = (*_env)->NewStringUTF(_env, record);
1653         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1654         CHECK(obj != NULL);
1655         return (*_env)->CallVoidMethod(_env, obj, j_calls->log_meth, record_conv);
1656 }
1657 static void LDKLogger_JCalls_free(void* this_arg) {
1658         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1659         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1660                 JNIEnv *env;
1661                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1662                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1663                 FREE(j_calls);
1664         }
1665 }
1666 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1667         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1668         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1669         return (void*) this_arg;
1670 }
1671 static inline LDKLogger LDKLogger_init (JNIEnv * env, jclass _a, jobject o) {
1672         jclass c = (*env)->GetObjectClass(env, o);
1673         CHECK(c != NULL);
1674         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1675         atomic_init(&calls->refcnt, 1);
1676         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1677         calls->o = (*env)->NewWeakGlobalRef(env, o);
1678         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
1679         CHECK(calls->log_meth != NULL);
1680
1681         LDKLogger ret = {
1682                 .this_arg = (void*) calls,
1683                 .log = log_jcall,
1684                 .free = LDKLogger_JCalls_free,
1685         };
1686         return ret;
1687 }
1688 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new (JNIEnv * env, jclass _a, jobject o) {
1689         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1690         *res_ptr = LDKLogger_init(env, _a, o);
1691         return (long)res_ptr;
1692 }
1693 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1694         jobject ret = (*env)->NewLocalRef(env, ((LDKLogger_JCalls*)val)->o);
1695         CHECK(ret != NULL);
1696         return ret;
1697 }
1698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
1699         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1700 }
1701 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
1702         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1703         CHECK(val->result_ok);
1704         long res_ref = (long)&(*val->contents.result);
1705         return res_ref;
1706 }
1707 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
1708         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1709         CHECK(!val->result_ok);
1710         jclass err_conv = LDKAccessError_to_java(_env, (*val->contents.err));
1711         return err_conv;
1712 }
1713 typedef struct LDKAccess_JCalls {
1714         atomic_size_t refcnt;
1715         JavaVM *vm;
1716         jweak o;
1717         jmethodID get_utxo_meth;
1718 } LDKAccess_JCalls;
1719 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) {
1720         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1721         JNIEnv *_env;
1722         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1723         jbyteArray genesis_hash_arr = (*_env)->NewByteArray(_env, 32);
1724         (*_env)->SetByteArrayRegion(_env, genesis_hash_arr, 0, 32, *genesis_hash);
1725         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1726         CHECK(obj != NULL);
1727         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
1728         LDKCResult_TxOutAccessErrorZ res = *ret;
1729         FREE(ret);
1730         return res;
1731 }
1732 static void LDKAccess_JCalls_free(void* this_arg) {
1733         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1734         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1735                 JNIEnv *env;
1736                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1737                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1738                 FREE(j_calls);
1739         }
1740 }
1741 static void* LDKAccess_JCalls_clone(const void* this_arg) {
1742         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1743         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1744         return (void*) this_arg;
1745 }
1746 static inline LDKAccess LDKAccess_init (JNIEnv * env, jclass _a, jobject o) {
1747         jclass c = (*env)->GetObjectClass(env, o);
1748         CHECK(c != NULL);
1749         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
1750         atomic_init(&calls->refcnt, 1);
1751         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1752         calls->o = (*env)->NewWeakGlobalRef(env, o);
1753         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
1754         CHECK(calls->get_utxo_meth != NULL);
1755
1756         LDKAccess ret = {
1757                 .this_arg = (void*) calls,
1758                 .get_utxo = get_utxo_jcall,
1759                 .free = LDKAccess_JCalls_free,
1760         };
1761         return ret;
1762 }
1763 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new (JNIEnv * env, jclass _a, jobject o) {
1764         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
1765         *res_ptr = LDKAccess_init(env, _a, o);
1766         return (long)res_ptr;
1767 }
1768 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAccess_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1769         jobject ret = (*env)->NewLocalRef(env, ((LDKAccess_JCalls*)val)->o);
1770         CHECK(ret != NULL);
1771         return ret;
1772 }
1773 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) {
1774         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
1775         unsigned char genesis_hash_arr[32];
1776         CHECK((*_env)->GetArrayLength (_env, genesis_hash) == 32);
1777         (*_env)->GetByteArrayRegion (_env, genesis_hash, 0, 32, genesis_hash_arr);
1778         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
1779         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
1780         *ret = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
1781         return (long)ret;
1782 }
1783
1784 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1785         LDKCVecTempl_HTLCOutputInCommitment *vec = (LDKCVecTempl_HTLCOutputInCommitment*)ptr;
1786         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
1787         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
1788         for (size_t i = 0; i < vec->datalen; i++) {
1789                 CHECK((((long)vec->data[i].inner) & 1) == 0);
1790                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
1791         }
1792         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
1793         return ret;
1794 }
1795 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1new(JNIEnv *env, jclass _b, jlongArray elems){
1796         LDKCVecTempl_HTLCOutputInCommitment *ret = MALLOC(sizeof(LDKCVecTempl_HTLCOutputInCommitment), "LDKCVecTempl_HTLCOutputInCommitment");
1797         ret->datalen = (*env)->GetArrayLength(env, elems);
1798         if (ret->datalen == 0) {
1799                 ret->data = NULL;
1800         } else {
1801                 ret->data = MALLOC(sizeof(LDKHTLCOutputInCommitment) * ret->datalen, "LDKCVecTempl_HTLCOutputInCommitment Data");
1802                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1803                 for (size_t i = 0; i < ret->datalen; i++) {
1804                         jlong arr_elem = java_elems[i];
1805                         LDKHTLCOutputInCommitment arr_elem_conv;
1806                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1807                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1808                         if (arr_elem_conv.inner != NULL)
1809                                 arr_elem_conv = HTLCOutputInCommitment_clone(&arr_elem_conv);
1810                         ret->data[i] = arr_elem_conv;
1811                 }
1812                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1813         }
1814         return (long)ret;
1815 }
1816 typedef struct LDKChannelKeys_JCalls {
1817         atomic_size_t refcnt;
1818         JavaVM *vm;
1819         jweak o;
1820         jmethodID get_per_commitment_point_meth;
1821         jmethodID release_commitment_secret_meth;
1822         jmethodID key_derivation_params_meth;
1823         jmethodID sign_counterparty_commitment_meth;
1824         jmethodID sign_holder_commitment_meth;
1825         jmethodID sign_holder_commitment_htlc_transactions_meth;
1826         jmethodID sign_justice_transaction_meth;
1827         jmethodID sign_counterparty_htlc_transaction_meth;
1828         jmethodID sign_closing_transaction_meth;
1829         jmethodID sign_channel_announcement_meth;
1830         jmethodID on_accept_meth;
1831 } LDKChannelKeys_JCalls;
1832 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1833         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1834         JNIEnv *_env;
1835         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1836         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1837         CHECK(obj != NULL);
1838         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_per_commitment_point_meth, idx);
1839         LDKPublicKey ret_ref;
1840         CHECK((*_env)->GetArrayLength (_env, ret) == 33);
1841         (*_env)->GetByteArrayRegion (_env, ret, 0, 33, ret_ref.compressed_form);
1842         return ret_ref;
1843 }
1844 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1845         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1846         JNIEnv *_env;
1847         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1848         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1849         CHECK(obj != NULL);
1850         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->release_commitment_secret_meth, idx);
1851         LDKThirtyTwoBytes ret_ref;
1852         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
1853         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.data);
1854         return ret_ref;
1855 }
1856 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1857         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1858         JNIEnv *_env;
1859         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1860         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1861         CHECK(obj != NULL);
1862         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*_env)->CallLongMethod(_env, obj, j_calls->key_derivation_params_meth);
1863         LDKC2Tuple_u64u64Z res = *ret;
1864         FREE(ret);
1865         return res;
1866 }
1867 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) {
1868         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1869         JNIEnv *_env;
1870         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1871         long commitment_tx_ref = (long)&commitment_tx;
1872         LDKCVec_HTLCOutputInCommitmentZ htlcs_var = htlcs;
1873         jlongArray htlcs_arr = (*_env)->NewLongArray(_env, htlcs_var.datalen);
1874         jlong *htlcs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, htlcs_arr, NULL);
1875         for (size_t y = 0; y < htlcs_var.datalen; y++) {
1876                 LDKHTLCOutputInCommitment arr_conv_24_var = htlcs_var.data[y];
1877                 CHECK((((long)arr_conv_24_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1878                 CHECK((((long)&arr_conv_24_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1879                 long arr_conv_24_ref;
1880                 if (arr_conv_24_var.is_owned) {
1881                         arr_conv_24_ref = (long)arr_conv_24_var.inner | 1;
1882                 } else {
1883                         arr_conv_24_ref = (long)&arr_conv_24_var;
1884                 }
1885                 htlcs_arr_ptr[y] = arr_conv_24_ref;
1886         }
1887         (*_env)->ReleasePrimitiveArrayCritical(_env, htlcs_arr, htlcs_arr_ptr, 0);
1888         FREE(htlcs_var.data);
1889         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1890         CHECK(obj != NULL);
1891         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, keys, htlcs_arr);
1892         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret;
1893         FREE(ret);
1894         return res;
1895 }
1896 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1897         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1898         JNIEnv *_env;
1899         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1900         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1901         CHECK(obj != NULL);
1902         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_meth, holder_commitment_tx);
1903         LDKCResult_SignatureNoneZ res = *ret;
1904         FREE(ret);
1905         return res;
1906 }
1907 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1908         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1909         JNIEnv *_env;
1910         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1911         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1912         CHECK(obj != NULL);
1913         LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx);
1914         LDKCResult_CVec_SignatureZNoneZ res = *ret;
1915         FREE(ret);
1916         return res;
1917 }
1918 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) {
1919         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1920         JNIEnv *_env;
1921         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1922         long justice_tx_ref = (long)&justice_tx;
1923         jbyteArray per_commitment_key_arr = (*_env)->NewByteArray(_env, 32);
1924         (*_env)->SetByteArrayRegion(_env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1925         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1926         CHECK(obj != NULL);
1927         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_justice_transaction_meth, justice_tx_ref, input, amount, per_commitment_key_arr, htlc);
1928         LDKCResult_SignatureNoneZ res = *ret;
1929         FREE(ret);
1930         return res;
1931 }
1932 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) {
1933         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1934         JNIEnv *_env;
1935         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1936         long htlc_tx_ref = (long)&htlc_tx;
1937         jbyteArray per_commitment_point_arr = (*_env)->NewByteArray(_env, 33);
1938         (*_env)->SetByteArrayRegion(_env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
1939         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1940         CHECK(obj != NULL);
1941         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, htlc);
1942         LDKCResult_SignatureNoneZ res = *ret;
1943         FREE(ret);
1944         return res;
1945 }
1946 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1947         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1948         JNIEnv *_env;
1949         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1950         long closing_tx_ref = (long)&closing_tx;
1951         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1952         CHECK(obj != NULL);
1953         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
1954         LDKCResult_SignatureNoneZ res = *ret;
1955         FREE(ret);
1956         return res;
1957 }
1958 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement *msg) {
1959         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1960         JNIEnv *_env;
1961         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1962         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1963         CHECK(obj != NULL);
1964         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_channel_announcement_meth, msg);
1965         LDKCResult_SignatureNoneZ res = *ret;
1966         FREE(ret);
1967         return res;
1968 }
1969 void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay) {
1970         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1971         JNIEnv *_env;
1972         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1973         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1974         CHECK(obj != NULL);
1975         return (*_env)->CallVoidMethod(_env, obj, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay);
1976 }
1977 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1978         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1979         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1980                 JNIEnv *env;
1981                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1982                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1983                 FREE(j_calls);
1984         }
1985 }
1986 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1987         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1988         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1989         return (void*) this_arg;
1990 }
1991 static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o) {
1992         jclass c = (*env)->GetObjectClass(env, o);
1993         CHECK(c != NULL);
1994         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1995         atomic_init(&calls->refcnt, 1);
1996         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1997         calls->o = (*env)->NewWeakGlobalRef(env, o);
1998         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
1999         CHECK(calls->get_per_commitment_point_meth != NULL);
2000         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2001         CHECK(calls->release_commitment_secret_meth != NULL);
2002         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
2003         CHECK(calls->key_derivation_params_meth != NULL);
2004         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJ[J)J");
2005         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2006         calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
2007         CHECK(calls->sign_holder_commitment_meth != NULL);
2008         calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
2009         CHECK(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
2010         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "(JJJ[BJ)J");
2011         CHECK(calls->sign_justice_transaction_meth != NULL);
2012         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "(JJJ[BJ)J");
2013         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2014         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
2015         CHECK(calls->sign_closing_transaction_meth != NULL);
2016         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2017         CHECK(calls->sign_channel_announcement_meth != NULL);
2018         calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V");
2019         CHECK(calls->on_accept_meth != NULL);
2020
2021         LDKChannelKeys ret = {
2022                 .this_arg = (void*) calls,
2023                 .get_per_commitment_point = get_per_commitment_point_jcall,
2024                 .release_commitment_secret = release_commitment_secret_jcall,
2025                 .key_derivation_params = key_derivation_params_jcall,
2026                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
2027                 .sign_holder_commitment = sign_holder_commitment_jcall,
2028                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
2029                 .sign_justice_transaction = sign_justice_transaction_jcall,
2030                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
2031                 .sign_closing_transaction = sign_closing_transaction_jcall,
2032                 .sign_channel_announcement = sign_channel_announcement_jcall,
2033                 .on_accept = on_accept_jcall,
2034                 .clone = LDKChannelKeys_JCalls_clone,
2035                 .free = LDKChannelKeys_JCalls_free,
2036         };
2037         return ret;
2038 }
2039 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o) {
2040         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2041         *res_ptr = LDKChannelKeys_init(env, _a, o);
2042         return (long)res_ptr;
2043 }
2044 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2045         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelKeys_JCalls*)val)->o);
2046         CHECK(ret != NULL);
2047         return ret;
2048 }
2049 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg, jlong idx) {
2050         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2051         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
2052         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2053         return arg_arr;
2054 }
2055
2056 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1release_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_arg, jlong idx) {
2057         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2058         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2059         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2060         return arg_arr;
2061 }
2062
2063 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1key_1derivation_1params(JNIEnv * _env, jclass _b, jlong this_arg) {
2064         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2065         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
2066         *ret = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
2067         return (long)ret;
2068 }
2069
2070 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) {
2071         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2072         LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx;
2073         FREE((void*)commitment_tx);
2074         LDKPreCalculatedTxCreationKeys keys_conv;
2075         keys_conv.inner = (void*)(keys & (~1));
2076         keys_conv.is_owned = (keys & 1) || (keys == 0);
2077         LDKCVec_HTLCOutputInCommitmentZ htlcs_constr;
2078         htlcs_constr.datalen = (*_env)->GetArrayLength (_env, htlcs);
2079         if (htlcs_constr.datalen > 0)
2080                 htlcs_constr.data = MALLOC(htlcs_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
2081         else
2082                 htlcs_constr.data = NULL;
2083         long* htlcs_vals = (*_env)->GetLongArrayElements (_env, htlcs, NULL);
2084         for (size_t y = 0; y < htlcs_constr.datalen; y++) {
2085                 long arr_conv_24 = htlcs_vals[y];
2086                 LDKHTLCOutputInCommitment arr_conv_24_conv;
2087                 arr_conv_24_conv.inner = (void*)(arr_conv_24 & (~1));
2088                 arr_conv_24_conv.is_owned = (arr_conv_24 & 1) || (arr_conv_24 == 0);
2089                 if (arr_conv_24_conv.inner != NULL)
2090                         arr_conv_24_conv = HTLCOutputInCommitment_clone(&arr_conv_24_conv);
2091                 htlcs_constr.data[y] = arr_conv_24_conv;
2092         }
2093         (*_env)->ReleaseLongArrayElements (_env, htlcs, htlcs_vals, 0);
2094         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2095         *ret = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, &keys_conv, htlcs_constr);
2096         return (long)ret;
2097 }
2098
2099 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1holder_1commitment(JNIEnv * _env, jclass _b, jlong this_arg, jlong holder_commitment_tx) {
2100         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2101         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
2102         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
2103         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
2104         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2105         *ret = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &holder_commitment_tx_conv);
2106         return (long)ret;
2107 }
2108
2109 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) {
2110         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2111         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
2112         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
2113         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
2114         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
2115         *ret = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &holder_commitment_tx_conv);
2116         return (long)ret;
2117 }
2118
2119 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) {
2120         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2121         LDKTransaction justice_tx_conv = *(LDKTransaction*)justice_tx;
2122         FREE((void*)justice_tx);
2123         unsigned char per_commitment_key_arr[32];
2124         CHECK((*_env)->GetArrayLength (_env, per_commitment_key) == 32);
2125         (*_env)->GetByteArrayRegion (_env, per_commitment_key, 0, 32, per_commitment_key_arr);
2126         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2127         LDKHTLCOutputInCommitment htlc_conv;
2128         htlc_conv.inner = (void*)(htlc & (~1));
2129         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
2130         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2131         *ret = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_conv, input, amount, per_commitment_key_ref, &htlc_conv);
2132         return (long)ret;
2133 }
2134
2135 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) {
2136         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2137         LDKTransaction htlc_tx_conv = *(LDKTransaction*)htlc_tx;
2138         FREE((void*)htlc_tx);
2139         LDKPublicKey per_commitment_point_ref;
2140         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
2141         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2142         LDKHTLCOutputInCommitment htlc_conv;
2143         htlc_conv.inner = (void*)(htlc & (~1));
2144         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
2145         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2146         *ret = (this_arg_conv->sign_counterparty_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_conv, input, amount, per_commitment_point_ref, &htlc_conv);
2147         return (long)ret;
2148 }
2149
2150 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1closing_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong closing_tx) {
2151         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2152         LDKTransaction closing_tx_conv = *(LDKTransaction*)closing_tx;
2153         FREE((void*)closing_tx);
2154         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2155         *ret = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_conv);
2156         return (long)ret;
2157 }
2158
2159 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1channel_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
2160         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2161         LDKUnsignedChannelAnnouncement msg_conv;
2162         msg_conv.inner = (void*)(msg & (~1));
2163         msg_conv.is_owned = (msg & 1) || (msg == 0);
2164         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2165         *ret = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2166         return (long)ret;
2167 }
2168
2169 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) {
2170         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2171         LDKChannelPublicKeys channel_points_conv;
2172         channel_points_conv.inner = (void*)(channel_points & (~1));
2173         channel_points_conv.is_owned = (channel_points & 1) || (channel_points == 0);
2174         (this_arg_conv->on_accept)(this_arg_conv->this_arg, &channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
2175 }
2176
2177 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2178         LDKCVecTempl_MonitorEvent *vec = (LDKCVecTempl_MonitorEvent*)ptr;
2179         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2180         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2181         for (size_t i = 0; i < vec->datalen; i++) {
2182                 CHECK((((long)vec->data[i].inner) & 1) == 0);
2183                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2184         }
2185         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2186         return ret;
2187 }
2188 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
2189         LDKCVecTempl_MonitorEvent *ret = MALLOC(sizeof(LDKCVecTempl_MonitorEvent), "LDKCVecTempl_MonitorEvent");
2190         ret->datalen = (*env)->GetArrayLength(env, elems);
2191         if (ret->datalen == 0) {
2192                 ret->data = NULL;
2193         } else {
2194                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVecTempl_MonitorEvent Data");
2195                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2196                 for (size_t i = 0; i < ret->datalen; i++) {
2197                         jlong arr_elem = java_elems[i];
2198                         LDKMonitorEvent arr_elem_conv;
2199                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2200                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2201                         // Warning: we may need a move here but can't clone!
2202                         ret->data[i] = arr_elem_conv;
2203                 }
2204                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2205         }
2206         return (long)ret;
2207 }
2208 typedef struct LDKWatch_JCalls {
2209         atomic_size_t refcnt;
2210         JavaVM *vm;
2211         jweak o;
2212         jmethodID watch_channel_meth;
2213         jmethodID update_channel_meth;
2214         jmethodID release_pending_monitor_events_meth;
2215 } LDKWatch_JCalls;
2216 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2217         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2218         JNIEnv *_env;
2219         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2220         LDKOutPoint funding_txo_var = funding_txo;
2221         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2222         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2223         long funding_txo_ref;
2224         if (funding_txo_var.is_owned) {
2225                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2226         } else {
2227                 funding_txo_ref = (long)&funding_txo_var;
2228         }
2229         LDKChannelMonitor monitor_var = monitor;
2230         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2231         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2232         long monitor_ref;
2233         if (monitor_var.is_owned) {
2234                 monitor_ref = (long)monitor_var.inner | 1;
2235         } else {
2236                 monitor_ref = (long)&monitor_var;
2237         }
2238         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2239         CHECK(obj != NULL);
2240         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*_env)->CallLongMethod(_env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2241         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2242         FREE(ret);
2243         return res;
2244 }
2245 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2246         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2247         JNIEnv *_env;
2248         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2249         LDKOutPoint funding_txo_var = funding_txo;
2250         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2251         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2252         long funding_txo_ref;
2253         if (funding_txo_var.is_owned) {
2254                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2255         } else {
2256                 funding_txo_ref = (long)&funding_txo_var;
2257         }
2258         LDKChannelMonitorUpdate update_var = update;
2259         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2260         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2261         long update_ref;
2262         if (update_var.is_owned) {
2263                 update_ref = (long)update_var.inner | 1;
2264         } else {
2265                 update_ref = (long)&update_var;
2266         }
2267         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2268         CHECK(obj != NULL);
2269         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*_env)->CallLongMethod(_env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
2270         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2271         FREE(ret);
2272         return res;
2273 }
2274 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2275         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2276         JNIEnv *_env;
2277         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2278         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2279         CHECK(obj != NULL);
2280         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->release_pending_monitor_events_meth);
2281         LDKCVec_MonitorEventZ ret_constr;
2282         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
2283         if (ret_constr.datalen > 0)
2284                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2285         else
2286                 ret_constr.data = NULL;
2287         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
2288         for (size_t o = 0; o < ret_constr.datalen; o++) {
2289                 long arr_conv_14 = ret_vals[o];
2290                 LDKMonitorEvent arr_conv_14_conv;
2291                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
2292                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
2293                 // Warning: we may need a move here but can't clone!
2294                 ret_constr.data[o] = arr_conv_14_conv;
2295         }
2296         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
2297         return ret_constr;
2298 }
2299 static void LDKWatch_JCalls_free(void* this_arg) {
2300         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2301         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2302                 JNIEnv *env;
2303                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2304                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2305                 FREE(j_calls);
2306         }
2307 }
2308 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2309         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2310         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2311         return (void*) this_arg;
2312 }
2313 static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) {
2314         jclass c = (*env)->GetObjectClass(env, o);
2315         CHECK(c != NULL);
2316         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2317         atomic_init(&calls->refcnt, 1);
2318         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2319         calls->o = (*env)->NewWeakGlobalRef(env, o);
2320         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
2321         CHECK(calls->watch_channel_meth != NULL);
2322         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
2323         CHECK(calls->update_channel_meth != NULL);
2324         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
2325         CHECK(calls->release_pending_monitor_events_meth != NULL);
2326
2327         LDKWatch ret = {
2328                 .this_arg = (void*) calls,
2329                 .watch_channel = watch_channel_jcall,
2330                 .update_channel = update_channel_jcall,
2331                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2332                 .free = LDKWatch_JCalls_free,
2333         };
2334         return ret;
2335 }
2336 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new (JNIEnv * env, jclass _a, jobject o) {
2337         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2338         *res_ptr = LDKWatch_init(env, _a, o);
2339         return (long)res_ptr;
2340 }
2341 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2342         jobject ret = (*env)->NewLocalRef(env, ((LDKWatch_JCalls*)val)->o);
2343         CHECK(ret != NULL);
2344         return ret;
2345 }
2346 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong monitor) {
2347         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2348         LDKOutPoint funding_txo_conv;
2349         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2350         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2351         if (funding_txo_conv.inner != NULL)
2352                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2353         LDKChannelMonitor monitor_conv;
2354         monitor_conv.inner = (void*)(monitor & (~1));
2355         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2356         // Warning: we may need a move here but can't clone!
2357         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2358         *ret = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2359         return (long)ret;
2360 }
2361
2362 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong update) {
2363         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2364         LDKOutPoint funding_txo_conv;
2365         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2366         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2367         if (funding_txo_conv.inner != NULL)
2368                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2369         LDKChannelMonitorUpdate update_conv;
2370         update_conv.inner = (void*)(update & (~1));
2371         update_conv.is_owned = (update & 1) || (update == 0);
2372         if (update_conv.inner != NULL)
2373                 update_conv = ChannelMonitorUpdate_clone(&update_conv);
2374         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2375         *ret = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2376         return (long)ret;
2377 }
2378
2379 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
2380         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2381         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2382         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
2383         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
2384         for (size_t o = 0; o < ret_var.datalen; o++) {
2385                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
2386                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2387                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2388                 long arr_conv_14_ref;
2389                 if (arr_conv_14_var.is_owned) {
2390                         arr_conv_14_ref = (long)arr_conv_14_var.inner | 1;
2391                 } else {
2392                         arr_conv_14_ref = (long)&arr_conv_14_var;
2393                 }
2394                 ret_arr_ptr[o] = arr_conv_14_ref;
2395         }
2396         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
2397         FREE(ret_var.data);
2398         return ret_arr;
2399 }
2400
2401 typedef struct LDKFilter_JCalls {
2402         atomic_size_t refcnt;
2403         JavaVM *vm;
2404         jweak o;
2405         jmethodID register_tx_meth;
2406         jmethodID register_output_meth;
2407 } LDKFilter_JCalls;
2408 void register_tx_jcall(const void* this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey) {
2409         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2410         JNIEnv *_env;
2411         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2412         jbyteArray txid_arr = (*_env)->NewByteArray(_env, 32);
2413         (*_env)->SetByteArrayRegion(_env, txid_arr, 0, 32, *txid);
2414         LDKu8slice script_pubkey_var = script_pubkey;
2415         jbyteArray script_pubkey_arr = (*_env)->NewByteArray(_env, script_pubkey_var.datalen);
2416         (*_env)->SetByteArrayRegion(_env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
2417         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2418         CHECK(obj != NULL);
2419         return (*_env)->CallVoidMethod(_env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
2420 }
2421 void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey) {
2422         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2423         JNIEnv *_env;
2424         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2425         LDKu8slice script_pubkey_var = script_pubkey;
2426         jbyteArray script_pubkey_arr = (*_env)->NewByteArray(_env, script_pubkey_var.datalen);
2427         (*_env)->SetByteArrayRegion(_env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
2428         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2429         CHECK(obj != NULL);
2430         return (*_env)->CallVoidMethod(_env, obj, j_calls->register_output_meth, outpoint, script_pubkey_arr);
2431 }
2432 static void LDKFilter_JCalls_free(void* this_arg) {
2433         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2434         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2435                 JNIEnv *env;
2436                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2437                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2438                 FREE(j_calls);
2439         }
2440 }
2441 static void* LDKFilter_JCalls_clone(const void* this_arg) {
2442         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2443         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2444         return (void*) this_arg;
2445 }
2446 static inline LDKFilter LDKFilter_init (JNIEnv * env, jclass _a, jobject o) {
2447         jclass c = (*env)->GetObjectClass(env, o);
2448         CHECK(c != NULL);
2449         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
2450         atomic_init(&calls->refcnt, 1);
2451         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2452         calls->o = (*env)->NewWeakGlobalRef(env, o);
2453         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
2454         CHECK(calls->register_tx_meth != NULL);
2455         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V");
2456         CHECK(calls->register_output_meth != NULL);
2457
2458         LDKFilter ret = {
2459                 .this_arg = (void*) calls,
2460                 .register_tx = register_tx_jcall,
2461                 .register_output = register_output_jcall,
2462                 .free = LDKFilter_JCalls_free,
2463         };
2464         return ret;
2465 }
2466 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new (JNIEnv * env, jclass _a, jobject o) {
2467         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
2468         *res_ptr = LDKFilter_init(env, _a, o);
2469         return (long)res_ptr;
2470 }
2471 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFilter_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2472         jobject ret = (*env)->NewLocalRef(env, ((LDKFilter_JCalls*)val)->o);
2473         CHECK(ret != NULL);
2474         return ret;
2475 }
2476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray txid, jbyteArray script_pubkey) {
2477         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2478         unsigned char txid_arr[32];
2479         CHECK((*_env)->GetArrayLength (_env, txid) == 32);
2480         (*_env)->GetByteArrayRegion (_env, txid, 0, 32, txid_arr);
2481         unsigned char (*txid_ref)[32] = &txid_arr;
2482         LDKu8slice script_pubkey_ref;
2483         script_pubkey_ref.data = (*_env)->GetByteArrayElements (_env, script_pubkey, NULL);
2484         script_pubkey_ref.datalen = (*_env)->GetArrayLength (_env, script_pubkey);
2485         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
2486         (*_env)->ReleaseByteArrayElements(_env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
2487 }
2488
2489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv * _env, jclass _b, jlong this_arg, jlong outpoint, jbyteArray script_pubkey) {
2490         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2491         LDKOutPoint outpoint_conv;
2492         outpoint_conv.inner = (void*)(outpoint & (~1));
2493         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
2494         LDKu8slice script_pubkey_ref;
2495         script_pubkey_ref.data = (*_env)->GetByteArrayElements (_env, script_pubkey, NULL);
2496         script_pubkey_ref.datalen = (*_env)->GetArrayLength (_env, script_pubkey);
2497         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
2498         (*_env)->ReleaseByteArrayElements(_env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
2499 }
2500
2501 typedef struct LDKBroadcasterInterface_JCalls {
2502         atomic_size_t refcnt;
2503         JavaVM *vm;
2504         jweak o;
2505         jmethodID broadcast_transaction_meth;
2506 } LDKBroadcasterInterface_JCalls;
2507 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2508         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2509         JNIEnv *_env;
2510         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2511         long tx_ref = (long)&tx;
2512         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2513         CHECK(obj != NULL);
2514         return (*_env)->CallVoidMethod(_env, obj, j_calls->broadcast_transaction_meth, tx_ref);
2515 }
2516 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2517         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2518         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2519                 JNIEnv *env;
2520                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2521                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2522                 FREE(j_calls);
2523         }
2524 }
2525 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2526         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2527         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2528         return (void*) this_arg;
2529 }
2530 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv * env, jclass _a, jobject o) {
2531         jclass c = (*env)->GetObjectClass(env, o);
2532         CHECK(c != NULL);
2533         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2534         atomic_init(&calls->refcnt, 1);
2535         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2536         calls->o = (*env)->NewWeakGlobalRef(env, o);
2537         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "(J)V");
2538         CHECK(calls->broadcast_transaction_meth != NULL);
2539
2540         LDKBroadcasterInterface ret = {
2541                 .this_arg = (void*) calls,
2542                 .broadcast_transaction = broadcast_transaction_jcall,
2543                 .free = LDKBroadcasterInterface_JCalls_free,
2544         };
2545         return ret;
2546 }
2547 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2548         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2549         *res_ptr = LDKBroadcasterInterface_init(env, _a, o);
2550         return (long)res_ptr;
2551 }
2552 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2553         jobject ret = (*env)->NewLocalRef(env, ((LDKBroadcasterInterface_JCalls*)val)->o);
2554         CHECK(ret != NULL);
2555         return ret;
2556 }
2557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong tx) {
2558         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
2559         LDKTransaction tx_conv = *(LDKTransaction*)tx;
2560         FREE((void*)tx);
2561         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_conv);
2562 }
2563
2564 typedef struct LDKFeeEstimator_JCalls {
2565         atomic_size_t refcnt;
2566         JavaVM *vm;
2567         jweak o;
2568         jmethodID get_est_sat_per_1000_weight_meth;
2569 } LDKFeeEstimator_JCalls;
2570 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2571         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2572         JNIEnv *_env;
2573         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2574         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(_env, confirmation_target);
2575         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2576         CHECK(obj != NULL);
2577         return (*_env)->CallIntMethod(_env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2578 }
2579 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2580         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2581         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2582                 JNIEnv *env;
2583                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2584                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2585                 FREE(j_calls);
2586         }
2587 }
2588 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2589         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2590         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2591         return (void*) this_arg;
2592 }
2593 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv * env, jclass _a, jobject o) {
2594         jclass c = (*env)->GetObjectClass(env, o);
2595         CHECK(c != NULL);
2596         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2597         atomic_init(&calls->refcnt, 1);
2598         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2599         calls->o = (*env)->NewWeakGlobalRef(env, o);
2600         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
2601         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
2602
2603         LDKFeeEstimator ret = {
2604                 .this_arg = (void*) calls,
2605                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2606                 .free = LDKFeeEstimator_JCalls_free,
2607         };
2608         return ret;
2609 }
2610 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new (JNIEnv * env, jclass _a, jobject o) {
2611         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2612         *res_ptr = LDKFeeEstimator_init(env, _a, o);
2613         return (long)res_ptr;
2614 }
2615 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2616         jobject ret = (*env)->NewLocalRef(env, ((LDKFeeEstimator_JCalls*)val)->o);
2617         CHECK(ret != NULL);
2618         return ret;
2619 }
2620 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) {
2621         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
2622         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(_env, confirmation_target);
2623         jint ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2624         return ret_val;
2625 }
2626
2627 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2628         LDKCVecTempl_C2TupleTempl_usize__Transaction *vec = (LDKCVecTempl_C2TupleTempl_usize__Transaction*)ptr;
2629         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_usize__Transaction));
2630 }
2631 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2632         LDKCVecTempl_C2TupleTempl_usize__Transaction *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_usize__Transaction), "LDKCVecTempl_C2TupleTempl_usize__Transaction");
2633         ret->datalen = (*env)->GetArrayLength(env, elems);
2634         if (ret->datalen == 0) {
2635                 ret->data = NULL;
2636         } else {
2637                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction) * ret->datalen, "LDKCVecTempl_C2TupleTempl_usize__Transaction Data");
2638                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2639                 for (size_t i = 0; i < ret->datalen; i++) {
2640                         jlong arr_elem = java_elems[i];
2641                         LDKC2TupleTempl_usize__Transaction arr_elem_conv = *(LDKC2TupleTempl_usize__Transaction*)arr_elem;
2642                         FREE((void*)arr_elem);
2643                         ret->data[i] = arr_elem_conv;
2644                 }
2645                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2646         }
2647         return (long)ret;
2648 }
2649 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2650         LDKCVecTempl_Transaction *vec = (LDKCVecTempl_Transaction*)ptr;
2651         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTransaction));
2652 }
2653 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2654         LDKCVecTempl_Transaction *ret = MALLOC(sizeof(LDKCVecTempl_Transaction), "LDKCVecTempl_Transaction");
2655         ret->datalen = (*env)->GetArrayLength(env, elems);
2656         if (ret->datalen == 0) {
2657                 ret->data = NULL;
2658         } else {
2659                 ret->data = MALLOC(sizeof(LDKTransaction) * ret->datalen, "LDKCVecTempl_Transaction Data");
2660                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2661                 for (size_t i = 0; i < ret->datalen; i++) {
2662                         jlong arr_elem = java_elems[i];
2663                         LDKTransaction arr_elem_conv = *(LDKTransaction*)arr_elem;
2664                         FREE((void*)arr_elem);
2665                         ret->data[i] = arr_elem_conv;
2666                 }
2667                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2668         }
2669         return (long)ret;
2670 }
2671 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2672         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *vec = (LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)ptr;
2673         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut));
2674 }
2675 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
2676         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
2677         ret->datalen = (*env)->GetArrayLength(env, elems);
2678         if (ret->datalen == 0) {
2679                 ret->data = NULL;
2680         } else {
2681                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut) * ret->datalen, "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut Data");
2682                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2683                 for (size_t i = 0; i < ret->datalen; i++) {
2684                         jlong arr_elem = java_elems[i];
2685                         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut arr_elem_conv = *(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)arr_elem;
2686                         FREE((void*)arr_elem);
2687                         ret->data[i] = arr_elem_conv;
2688                 }
2689                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2690         }
2691         return (long)ret;
2692 }
2693 typedef struct LDKKeysInterface_JCalls {
2694         atomic_size_t refcnt;
2695         JavaVM *vm;
2696         jweak o;
2697         jmethodID get_node_secret_meth;
2698         jmethodID get_destination_script_meth;
2699         jmethodID get_shutdown_pubkey_meth;
2700         jmethodID get_channel_keys_meth;
2701         jmethodID get_secure_random_bytes_meth;
2702 } LDKKeysInterface_JCalls;
2703 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2704         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2705         JNIEnv *_env;
2706         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2707         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2708         CHECK(obj != NULL);
2709         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_node_secret_meth);
2710         LDKSecretKey ret_ref;
2711         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
2712         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.bytes);
2713         return ret_ref;
2714 }
2715 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
2716         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2717         JNIEnv *_env;
2718         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2719         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2720         CHECK(obj != NULL);
2721         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_destination_script_meth);
2722         LDKCVec_u8Z ret_ref;
2723         ret_ref.data = (*_env)->GetByteArrayElements (_env, ret, NULL);
2724         ret_ref.datalen = (*_env)->GetArrayLength (_env, ret);
2725         return ret_ref;
2726 }
2727 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
2728         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2729         JNIEnv *_env;
2730         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2731         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2732         CHECK(obj != NULL);
2733         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_shutdown_pubkey_meth);
2734         LDKPublicKey ret_ref;
2735         CHECK((*_env)->GetArrayLength (_env, ret) == 33);
2736         (*_env)->GetByteArrayRegion (_env, ret, 0, 33, ret_ref.compressed_form);
2737         return ret_ref;
2738 }
2739 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2740         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2741         JNIEnv *_env;
2742         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2743         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2744         CHECK(obj != NULL);
2745         LDKChannelKeys* ret = (LDKChannelKeys*)(*_env)->CallLongMethod(_env, obj, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
2746         LDKChannelKeys res = *ret;
2747         FREE(ret);
2748         return res;
2749 }
2750 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2751         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2752         JNIEnv *_env;
2753         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2754         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2755         CHECK(obj != NULL);
2756         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_secure_random_bytes_meth);
2757         LDKThirtyTwoBytes ret_ref;
2758         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
2759         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.data);
2760         return ret_ref;
2761 }
2762 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2763         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2764         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2765                 JNIEnv *env;
2766                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2767                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2768                 FREE(j_calls);
2769         }
2770 }
2771 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2772         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2773         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2774         return (void*) this_arg;
2775 }
2776 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv * env, jclass _a, jobject o) {
2777         jclass c = (*env)->GetObjectClass(env, o);
2778         CHECK(c != NULL);
2779         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2780         atomic_init(&calls->refcnt, 1);
2781         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2782         calls->o = (*env)->NewWeakGlobalRef(env, o);
2783         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
2784         CHECK(calls->get_node_secret_meth != NULL);
2785         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
2786         CHECK(calls->get_destination_script_meth != NULL);
2787         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
2788         CHECK(calls->get_shutdown_pubkey_meth != NULL);
2789         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
2790         CHECK(calls->get_channel_keys_meth != NULL);
2791         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
2792         CHECK(calls->get_secure_random_bytes_meth != NULL);
2793
2794         LDKKeysInterface ret = {
2795                 .this_arg = (void*) calls,
2796                 .get_node_secret = get_node_secret_jcall,
2797                 .get_destination_script = get_destination_script_jcall,
2798                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2799                 .get_channel_keys = get_channel_keys_jcall,
2800                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2801                 .free = LDKKeysInterface_JCalls_free,
2802         };
2803         return ret;
2804 }
2805 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2806         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2807         *res_ptr = LDKKeysInterface_init(env, _a, o);
2808         return (long)res_ptr;
2809 }
2810 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2811         jobject ret = (*env)->NewLocalRef(env, ((LDKKeysInterface_JCalls*)val)->o);
2812         CHECK(ret != NULL);
2813         return ret;
2814 }
2815 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv * _env, jclass _b, jlong this_arg) {
2816         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2817         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2818         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
2819         return arg_arr;
2820 }
2821
2822 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv * _env, jclass _b, jlong this_arg) {
2823         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2824         LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2825         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
2826         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
2827         return arg_arr;
2828 }
2829
2830 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_arg) {
2831         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2832         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
2833         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
2834         return arg_arr;
2835 }
2836
2837 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) {
2838         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2839         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2840         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2841         return (long)ret;
2842 }
2843
2844 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv * _env, jclass _b, jlong this_arg) {
2845         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2846         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2847         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
2848         return arg_arr;
2849 }
2850
2851 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2852         LDKCVecTempl_ChannelDetails *vec = (LDKCVecTempl_ChannelDetails*)ptr;
2853         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2854         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2855         for (size_t i = 0; i < vec->datalen; i++) {
2856                 CHECK((((long)vec->data[i].inner) & 1) == 0);
2857                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2858         }
2859         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2860         return ret;
2861 }
2862 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1new(JNIEnv *env, jclass _b, jlongArray elems){
2863         LDKCVecTempl_ChannelDetails *ret = MALLOC(sizeof(LDKCVecTempl_ChannelDetails), "LDKCVecTempl_ChannelDetails");
2864         ret->datalen = (*env)->GetArrayLength(env, elems);
2865         if (ret->datalen == 0) {
2866                 ret->data = NULL;
2867         } else {
2868                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVecTempl_ChannelDetails Data");
2869                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2870                 for (size_t i = 0; i < ret->datalen; i++) {
2871                         jlong arr_elem = java_elems[i];
2872                         LDKChannelDetails arr_elem_conv;
2873                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2874                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2875                         if (arr_elem_conv.inner != NULL)
2876                                 arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2877                         ret->data[i] = arr_elem_conv;
2878                 }
2879                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2880         }
2881         return (long)ret;
2882 }
2883 static jclass LDKNetAddress_IPv4_class = NULL;
2884 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2885 static jclass LDKNetAddress_IPv6_class = NULL;
2886 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2887 static jclass LDKNetAddress_OnionV2_class = NULL;
2888 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2889 static jclass LDKNetAddress_OnionV3_class = NULL;
2890 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv * env, jclass _a) {
2892         LDKNetAddress_IPv4_class =
2893                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2894         CHECK(LDKNetAddress_IPv4_class != NULL);
2895         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
2896         CHECK(LDKNetAddress_IPv4_meth != NULL);
2897         LDKNetAddress_IPv6_class =
2898                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2899         CHECK(LDKNetAddress_IPv6_class != NULL);
2900         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
2901         CHECK(LDKNetAddress_IPv6_meth != NULL);
2902         LDKNetAddress_OnionV2_class =
2903                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2904         CHECK(LDKNetAddress_OnionV2_class != NULL);
2905         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
2906         CHECK(LDKNetAddress_OnionV2_meth != NULL);
2907         LDKNetAddress_OnionV3_class =
2908                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2909         CHECK(LDKNetAddress_OnionV3_class != NULL);
2910         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2911         CHECK(LDKNetAddress_OnionV3_meth != NULL);
2912 }
2913 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
2914         LDKNetAddress *obj = (LDKNetAddress*)ptr;
2915         switch(obj->tag) {
2916                 case LDKNetAddress_IPv4: {
2917                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 4);
2918                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 4, obj->i_pv4.addr.data);
2919                         return (*_env)->NewObject(_env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
2920                 }
2921                 case LDKNetAddress_IPv6: {
2922                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 16);
2923                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 16, obj->i_pv6.addr.data);
2924                         return (*_env)->NewObject(_env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
2925                 }
2926                 case LDKNetAddress_OnionV2: {
2927                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 10);
2928                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 10, obj->onion_v2.addr.data);
2929                         return (*_env)->NewObject(_env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
2930                 }
2931                 case LDKNetAddress_OnionV3: {
2932                         jbyteArray ed25519_pubkey_arr = (*_env)->NewByteArray(_env, 32);
2933                         (*_env)->SetByteArrayRegion(_env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2934                         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);
2935                 }
2936                 default: abort();
2937         }
2938 }
2939 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2940         LDKCVecTempl_NetAddress *vec = (LDKCVecTempl_NetAddress*)ptr;
2941         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKNetAddress));
2942 }
2943 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1new(JNIEnv *env, jclass _b, jlongArray elems){
2944         LDKCVecTempl_NetAddress *ret = MALLOC(sizeof(LDKCVecTempl_NetAddress), "LDKCVecTempl_NetAddress");
2945         ret->datalen = (*env)->GetArrayLength(env, elems);
2946         if (ret->datalen == 0) {
2947                 ret->data = NULL;
2948         } else {
2949                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVecTempl_NetAddress Data");
2950                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2951                 for (size_t i = 0; i < ret->datalen; i++) {
2952                         jlong arr_elem = java_elems[i];
2953                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
2954                         FREE((void*)arr_elem);
2955                         ret->data[i] = arr_elem_conv;
2956                 }
2957                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2958         }
2959         return (long)ret;
2960 }
2961 typedef struct LDKChannelMessageHandler_JCalls {
2962         atomic_size_t refcnt;
2963         JavaVM *vm;
2964         jweak o;
2965         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
2966         jmethodID handle_open_channel_meth;
2967         jmethodID handle_accept_channel_meth;
2968         jmethodID handle_funding_created_meth;
2969         jmethodID handle_funding_signed_meth;
2970         jmethodID handle_funding_locked_meth;
2971         jmethodID handle_shutdown_meth;
2972         jmethodID handle_closing_signed_meth;
2973         jmethodID handle_update_add_htlc_meth;
2974         jmethodID handle_update_fulfill_htlc_meth;
2975         jmethodID handle_update_fail_htlc_meth;
2976         jmethodID handle_update_fail_malformed_htlc_meth;
2977         jmethodID handle_commitment_signed_meth;
2978         jmethodID handle_revoke_and_ack_meth;
2979         jmethodID handle_update_fee_meth;
2980         jmethodID handle_announcement_signatures_meth;
2981         jmethodID peer_disconnected_meth;
2982         jmethodID peer_connected_meth;
2983         jmethodID handle_channel_reestablish_meth;
2984         jmethodID handle_error_meth;
2985 } LDKChannelMessageHandler_JCalls;
2986 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg) {
2987         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2988         JNIEnv *_env;
2989         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2990         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2991         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2992         LDKInitFeatures their_features_var = their_features;
2993         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2994         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2995         long their_features_ref;
2996         if (their_features_var.is_owned) {
2997                 their_features_ref = (long)their_features_var.inner | 1;
2998         } else {
2999                 their_features_ref = (long)&their_features_var;
3000         }
3001         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3002         CHECK(obj != NULL);
3003         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg);
3004 }
3005 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) {
3006         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3007         JNIEnv *_env;
3008         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3009         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3010         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3011         LDKInitFeatures their_features_var = their_features;
3012         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3013         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3014         long their_features_ref;
3015         if (their_features_var.is_owned) {
3016                 their_features_ref = (long)their_features_var.inner | 1;
3017         } else {
3018                 their_features_ref = (long)&their_features_var;
3019         }
3020         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3021         CHECK(obj != NULL);
3022         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg);
3023 }
3024 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg) {
3025         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3026         JNIEnv *_env;
3027         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3028         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3029         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3030         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3031         CHECK(obj != NULL);
3032         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg);
3033 }
3034 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) {
3035         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3036         JNIEnv *_env;
3037         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3038         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3039         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3040         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3041         CHECK(obj != NULL);
3042         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg);
3043 }
3044 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *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         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3051         CHECK(obj != NULL);
3052         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg);
3053 }
3054 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) {
3055         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3056         JNIEnv *_env;
3057         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3058         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3059         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3060         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3061         CHECK(obj != NULL);
3062         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg);
3063 }
3064 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) {
3065         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3066         JNIEnv *_env;
3067         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3068         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3069         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3070         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3071         CHECK(obj != NULL);
3072         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg);
3073 }
3074 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) {
3075         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3076         JNIEnv *_env;
3077         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3078         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3079         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3080         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3081         CHECK(obj != NULL);
3082         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg);
3083 }
3084 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) {
3085         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3086         JNIEnv *_env;
3087         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3088         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3089         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3090         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3091         CHECK(obj != NULL);
3092         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg);
3093 }
3094 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) {
3095         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3096         JNIEnv *_env;
3097         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3098         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3099         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3100         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3101         CHECK(obj != NULL);
3102         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg);
3103 }
3104 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) {
3105         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3106         JNIEnv *_env;
3107         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3108         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3109         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3110         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3111         CHECK(obj != NULL);
3112         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg);
3113 }
3114 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) {
3115         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3116         JNIEnv *_env;
3117         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3118         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3119         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3120         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3121         CHECK(obj != NULL);
3122         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg);
3123 }
3124 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) {
3125         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3126         JNIEnv *_env;
3127         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3128         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3129         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3130         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3131         CHECK(obj != NULL);
3132         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg);
3133 }
3134 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) {
3135         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3136         JNIEnv *_env;
3137         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3138         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3139         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3140         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3141         CHECK(obj != NULL);
3142         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg);
3143 }
3144 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) {
3145         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3146         JNIEnv *_env;
3147         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3148         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3149         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3150         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3151         CHECK(obj != NULL);
3152         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg);
3153 }
3154 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
3155         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3156         JNIEnv *_env;
3157         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3158         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3159         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3160         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3161         CHECK(obj != NULL);
3162         return (*_env)->CallVoidMethod(_env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
3163 }
3164 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit *msg) {
3165         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3166         JNIEnv *_env;
3167         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3168         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3169         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3170         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3171         CHECK(obj != NULL);
3172         return (*_env)->CallVoidMethod(_env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg);
3173 }
3174 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) {
3175         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3176         JNIEnv *_env;
3177         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3178         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3179         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3180         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3181         CHECK(obj != NULL);
3182         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg);
3183 }
3184 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) {
3185         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3186         JNIEnv *_env;
3187         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3188         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3189         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3190         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3191         CHECK(obj != NULL);
3192         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_error_meth, their_node_id_arr, msg);
3193 }
3194 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
3195         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3196         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3197                 JNIEnv *env;
3198                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3199                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3200                 FREE(j_calls);
3201         }
3202 }
3203 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
3204         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3205         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3206         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
3207         return (void*) this_arg;
3208 }
3209 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
3210         jclass c = (*env)->GetObjectClass(env, o);
3211         CHECK(c != NULL);
3212         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
3213         atomic_init(&calls->refcnt, 1);
3214         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3215         calls->o = (*env)->NewWeakGlobalRef(env, o);
3216         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
3217         CHECK(calls->handle_open_channel_meth != NULL);
3218         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
3219         CHECK(calls->handle_accept_channel_meth != NULL);
3220         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
3221         CHECK(calls->handle_funding_created_meth != NULL);
3222         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
3223         CHECK(calls->handle_funding_signed_meth != NULL);
3224         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
3225         CHECK(calls->handle_funding_locked_meth != NULL);
3226         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
3227         CHECK(calls->handle_shutdown_meth != NULL);
3228         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
3229         CHECK(calls->handle_closing_signed_meth != NULL);
3230         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
3231         CHECK(calls->handle_update_add_htlc_meth != NULL);
3232         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
3233         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
3234         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
3235         CHECK(calls->handle_update_fail_htlc_meth != NULL);
3236         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
3237         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
3238         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
3239         CHECK(calls->handle_commitment_signed_meth != NULL);
3240         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
3241         CHECK(calls->handle_revoke_and_ack_meth != NULL);
3242         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
3243         CHECK(calls->handle_update_fee_meth != NULL);
3244         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
3245         CHECK(calls->handle_announcement_signatures_meth != NULL);
3246         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
3247         CHECK(calls->peer_disconnected_meth != NULL);
3248         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
3249         CHECK(calls->peer_connected_meth != NULL);
3250         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
3251         CHECK(calls->handle_channel_reestablish_meth != NULL);
3252         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
3253         CHECK(calls->handle_error_meth != NULL);
3254
3255         LDKChannelMessageHandler ret = {
3256                 .this_arg = (void*) calls,
3257                 .handle_open_channel = handle_open_channel_jcall,
3258                 .handle_accept_channel = handle_accept_channel_jcall,
3259                 .handle_funding_created = handle_funding_created_jcall,
3260                 .handle_funding_signed = handle_funding_signed_jcall,
3261                 .handle_funding_locked = handle_funding_locked_jcall,
3262                 .handle_shutdown = handle_shutdown_jcall,
3263                 .handle_closing_signed = handle_closing_signed_jcall,
3264                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3265                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3266                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3267                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3268                 .handle_commitment_signed = handle_commitment_signed_jcall,
3269                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3270                 .handle_update_fee = handle_update_fee_jcall,
3271                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3272                 .peer_disconnected = peer_disconnected_jcall,
3273                 .peer_connected = peer_connected_jcall,
3274                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3275                 .handle_error = handle_error_jcall,
3276                 .free = LDKChannelMessageHandler_JCalls_free,
3277                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, _a, MessageSendEventsProvider),
3278         };
3279         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3280         return ret;
3281 }
3282 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
3283         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3284         *res_ptr = LDKChannelMessageHandler_init(env, _a, o, MessageSendEventsProvider);
3285         return (long)res_ptr;
3286 }
3287 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3288         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelMessageHandler_JCalls*)val)->o);
3289         CHECK(ret != NULL);
3290         return ret;
3291 }
3292 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) {
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         LDKInitFeatures their_features_conv;
3298         their_features_conv.inner = (void*)(their_features & (~1));
3299         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3300         // Warning: we may need a move here but can't clone!
3301         LDKOpenChannel msg_conv;
3302         msg_conv.inner = (void*)(msg & (~1));
3303         msg_conv.is_owned = (msg & 1) || (msg == 0);
3304         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3305 }
3306
3307 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) {
3308         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3309         LDKPublicKey their_node_id_ref;
3310         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3311         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3312         LDKInitFeatures their_features_conv;
3313         their_features_conv.inner = (void*)(their_features & (~1));
3314         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3315         // Warning: we may need a move here but can't clone!
3316         LDKAcceptChannel msg_conv;
3317         msg_conv.inner = (void*)(msg & (~1));
3318         msg_conv.is_owned = (msg & 1) || (msg == 0);
3319         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3320 }
3321
3322 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) {
3323         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3324         LDKPublicKey their_node_id_ref;
3325         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3326         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3327         LDKFundingCreated msg_conv;
3328         msg_conv.inner = (void*)(msg & (~1));
3329         msg_conv.is_owned = (msg & 1) || (msg == 0);
3330         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3331 }
3332
3333 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) {
3334         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3335         LDKPublicKey their_node_id_ref;
3336         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3337         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3338         LDKFundingSigned msg_conv;
3339         msg_conv.inner = (void*)(msg & (~1));
3340         msg_conv.is_owned = (msg & 1) || (msg == 0);
3341         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3342 }
3343
3344 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) {
3345         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3346         LDKPublicKey their_node_id_ref;
3347         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3348         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3349         LDKFundingLocked msg_conv;
3350         msg_conv.inner = (void*)(msg & (~1));
3351         msg_conv.is_owned = (msg & 1) || (msg == 0);
3352         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3353 }
3354
3355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3356         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3357         LDKPublicKey their_node_id_ref;
3358         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3359         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3360         LDKShutdown msg_conv;
3361         msg_conv.inner = (void*)(msg & (~1));
3362         msg_conv.is_owned = (msg & 1) || (msg == 0);
3363         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3364 }
3365
3366 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) {
3367         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3368         LDKPublicKey their_node_id_ref;
3369         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3370         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3371         LDKClosingSigned msg_conv;
3372         msg_conv.inner = (void*)(msg & (~1));
3373         msg_conv.is_owned = (msg & 1) || (msg == 0);
3374         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3375 }
3376
3377 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) {
3378         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3379         LDKPublicKey their_node_id_ref;
3380         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3381         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3382         LDKUpdateAddHTLC msg_conv;
3383         msg_conv.inner = (void*)(msg & (~1));
3384         msg_conv.is_owned = (msg & 1) || (msg == 0);
3385         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3386 }
3387
3388 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) {
3389         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3390         LDKPublicKey their_node_id_ref;
3391         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3392         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3393         LDKUpdateFulfillHTLC msg_conv;
3394         msg_conv.inner = (void*)(msg & (~1));
3395         msg_conv.is_owned = (msg & 1) || (msg == 0);
3396         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3397 }
3398
3399 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) {
3400         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3401         LDKPublicKey their_node_id_ref;
3402         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3403         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3404         LDKUpdateFailHTLC msg_conv;
3405         msg_conv.inner = (void*)(msg & (~1));
3406         msg_conv.is_owned = (msg & 1) || (msg == 0);
3407         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3408 }
3409
3410 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) {
3411         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3412         LDKPublicKey their_node_id_ref;
3413         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3414         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3415         LDKUpdateFailMalformedHTLC msg_conv;
3416         msg_conv.inner = (void*)(msg & (~1));
3417         msg_conv.is_owned = (msg & 1) || (msg == 0);
3418         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3419 }
3420
3421 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) {
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         LDKCommitmentSigned msg_conv;
3427         msg_conv.inner = (void*)(msg & (~1));
3428         msg_conv.is_owned = (msg & 1) || (msg == 0);
3429         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3430 }
3431
3432 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) {
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         LDKRevokeAndACK msg_conv;
3438         msg_conv.inner = (void*)(msg & (~1));
3439         msg_conv.is_owned = (msg & 1) || (msg == 0);
3440         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3441 }
3442
3443 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) {
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         LDKUpdateFee msg_conv;
3449         msg_conv.inner = (void*)(msg & (~1));
3450         msg_conv.is_owned = (msg & 1) || (msg == 0);
3451         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3452 }
3453
3454 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) {
3455         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3456         LDKPublicKey their_node_id_ref;
3457         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3458         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3459         LDKAnnouncementSignatures msg_conv;
3460         msg_conv.inner = (void*)(msg & (~1));
3461         msg_conv.is_owned = (msg & 1) || (msg == 0);
3462         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3463 }
3464
3465 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) {
3466         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3467         LDKPublicKey their_node_id_ref;
3468         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3469         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3470         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
3471 }
3472
3473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3474         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3475         LDKPublicKey their_node_id_ref;
3476         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3477         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3478         LDKInit msg_conv;
3479         msg_conv.inner = (void*)(msg & (~1));
3480         msg_conv.is_owned = (msg & 1) || (msg == 0);
3481         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3482 }
3483
3484 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) {
3485         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3486         LDKPublicKey their_node_id_ref;
3487         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3488         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3489         LDKChannelReestablish msg_conv;
3490         msg_conv.inner = (void*)(msg & (~1));
3491         msg_conv.is_owned = (msg & 1) || (msg == 0);
3492         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3493 }
3494
3495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1error(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3496         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3497         LDKPublicKey their_node_id_ref;
3498         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3499         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3500         LDKErrorMessage msg_conv;
3501         msg_conv.inner = (void*)(msg & (~1));
3502         msg_conv.is_owned = (msg & 1) || (msg == 0);
3503         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3504 }
3505
3506 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3507         LDKCVecTempl_ChannelMonitor *vec = (LDKCVecTempl_ChannelMonitor*)ptr;
3508         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3509         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3510         for (size_t i = 0; i < vec->datalen; i++) {
3511                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3512                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3513         }
3514         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3515         return ret;
3516 }
3517 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1new(JNIEnv *env, jclass _b, jlongArray elems){
3518         LDKCVecTempl_ChannelMonitor *ret = MALLOC(sizeof(LDKCVecTempl_ChannelMonitor), "LDKCVecTempl_ChannelMonitor");
3519         ret->datalen = (*env)->GetArrayLength(env, elems);
3520         if (ret->datalen == 0) {
3521                 ret->data = NULL;
3522         } else {
3523                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVecTempl_ChannelMonitor Data");
3524                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3525                 for (size_t i = 0; i < ret->datalen; i++) {
3526                         jlong arr_elem = java_elems[i];
3527                         LDKChannelMonitor arr_elem_conv;
3528                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3529                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3530                         // Warning: we may need a move here but can't clone!
3531                         ret->data[i] = arr_elem_conv;
3532                 }
3533                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3534         }
3535         return (long)ret;
3536 }
3537 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3538         LDKCVecTempl_u64 *vec = (LDKCVecTempl_u64*)ptr;
3539         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint64_t));
3540 }
3541 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1new(JNIEnv *env, jclass _b, jlongArray elems){
3542         LDKCVecTempl_u64 *ret = MALLOC(sizeof(LDKCVecTempl_u64), "LDKCVecTempl_u64");
3543         ret->datalen = (*env)->GetArrayLength(env, elems);
3544         if (ret->datalen == 0) {
3545                 ret->data = NULL;
3546         } else {
3547                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVecTempl_u64 Data");
3548                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3549                 for (size_t i = 0; i < ret->datalen; i++) {
3550                         ret->data[i] = java_elems[i];
3551                 }
3552                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3553         }
3554         return (long)ret;
3555 }
3556 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3557         LDKCVecTempl_UpdateAddHTLC *vec = (LDKCVecTempl_UpdateAddHTLC*)ptr;
3558         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3559         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3560         for (size_t i = 0; i < vec->datalen; i++) {
3561                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3562                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3563         }
3564         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3565         return ret;
3566 }
3567 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3568         LDKCVecTempl_UpdateAddHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateAddHTLC), "LDKCVecTempl_UpdateAddHTLC");
3569         ret->datalen = (*env)->GetArrayLength(env, elems);
3570         if (ret->datalen == 0) {
3571                 ret->data = NULL;
3572         } else {
3573                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVecTempl_UpdateAddHTLC Data");
3574                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3575                 for (size_t i = 0; i < ret->datalen; i++) {
3576                         jlong arr_elem = java_elems[i];
3577                         LDKUpdateAddHTLC arr_elem_conv;
3578                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3579                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3580                         if (arr_elem_conv.inner != NULL)
3581                                 arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3582                         ret->data[i] = arr_elem_conv;
3583                 }
3584                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3585         }
3586         return (long)ret;
3587 }
3588 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3589         LDKCVecTempl_UpdateFulfillHTLC *vec = (LDKCVecTempl_UpdateFulfillHTLC*)ptr;
3590         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3591         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3592         for (size_t i = 0; i < vec->datalen; i++) {
3593                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3594                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3595         }
3596         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3597         return ret;
3598 }
3599 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3600         LDKCVecTempl_UpdateFulfillHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFulfillHTLC), "LDKCVecTempl_UpdateFulfillHTLC");
3601         ret->datalen = (*env)->GetArrayLength(env, elems);
3602         if (ret->datalen == 0) {
3603                 ret->data = NULL;
3604         } else {
3605                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVecTempl_UpdateFulfillHTLC Data");
3606                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3607                 for (size_t i = 0; i < ret->datalen; i++) {
3608                         jlong arr_elem = java_elems[i];
3609                         LDKUpdateFulfillHTLC arr_elem_conv;
3610                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3611                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3612                         if (arr_elem_conv.inner != NULL)
3613                                 arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3614                         ret->data[i] = arr_elem_conv;
3615                 }
3616                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3617         }
3618         return (long)ret;
3619 }
3620 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3621         LDKCVecTempl_UpdateFailHTLC *vec = (LDKCVecTempl_UpdateFailHTLC*)ptr;
3622         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3623         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3624         for (size_t i = 0; i < vec->datalen; i++) {
3625                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3626                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3627         }
3628         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3629         return ret;
3630 }
3631 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3632         LDKCVecTempl_UpdateFailHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailHTLC), "LDKCVecTempl_UpdateFailHTLC");
3633         ret->datalen = (*env)->GetArrayLength(env, elems);
3634         if (ret->datalen == 0) {
3635                 ret->data = NULL;
3636         } else {
3637                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailHTLC Data");
3638                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3639                 for (size_t i = 0; i < ret->datalen; i++) {
3640                         jlong arr_elem = java_elems[i];
3641                         LDKUpdateFailHTLC arr_elem_conv;
3642                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3643                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3644                         if (arr_elem_conv.inner != NULL)
3645                                 arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3646                         ret->data[i] = arr_elem_conv;
3647                 }
3648                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3649         }
3650         return (long)ret;
3651 }
3652 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3653         LDKCVecTempl_UpdateFailMalformedHTLC *vec = (LDKCVecTempl_UpdateFailMalformedHTLC*)ptr;
3654         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3655         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3656         for (size_t i = 0; i < vec->datalen; i++) {
3657                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3658                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3659         }
3660         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3661         return ret;
3662 }
3663 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3664         LDKCVecTempl_UpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailMalformedHTLC), "LDKCVecTempl_UpdateFailMalformedHTLC");
3665         ret->datalen = (*env)->GetArrayLength(env, elems);
3666         if (ret->datalen == 0) {
3667                 ret->data = NULL;
3668         } else {
3669                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailMalformedHTLC Data");
3670                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3671                 for (size_t i = 0; i < ret->datalen; i++) {
3672                         jlong arr_elem = java_elems[i];
3673                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3674                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3675                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3676                         if (arr_elem_conv.inner != NULL)
3677                                 arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3678                         ret->data[i] = arr_elem_conv;
3679                 }
3680                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3681         }
3682         return (long)ret;
3683 }
3684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3685         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3686 }
3687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
3688         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
3689         CHECK(val->result_ok);
3690         return *val->contents.result;
3691 }
3692 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
3693         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
3694         CHECK(!val->result_ok);
3695         LDKLightningError err_var = (*val->contents.err);
3696         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3697         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3698         long err_ref;
3699         if (err_var.is_owned) {
3700                 err_ref = (long)err_var.inner | 1;
3701         } else {
3702                 err_ref = (long)&err_var;
3703         }
3704         return err_ref;
3705 }
3706 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3707         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *vec = (LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)ptr;
3708         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate));
3709 }
3710 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *env, jclass _b, jlongArray elems){
3711         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *ret = MALLOC(sizeof(LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
3712         ret->datalen = (*env)->GetArrayLength(env, elems);
3713         if (ret->datalen == 0) {
3714                 ret->data = NULL;
3715         } else {
3716                 ret->data = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate) * ret->datalen, "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate Data");
3717                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3718                 for (size_t i = 0; i < ret->datalen; i++) {
3719                         jlong arr_elem = java_elems[i];
3720                         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate arr_elem_conv = *(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)arr_elem;
3721                         FREE((void*)arr_elem);
3722                         ret->data[i] = arr_elem_conv;
3723                 }
3724                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3725         }
3726         return (long)ret;
3727 }
3728 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3729         LDKCVecTempl_NodeAnnouncement *vec = (LDKCVecTempl_NodeAnnouncement*)ptr;
3730         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3731         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3732         for (size_t i = 0; i < vec->datalen; i++) {
3733                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3734                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3735         }
3736         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3737         return ret;
3738 }
3739 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1new(JNIEnv *env, jclass _b, jlongArray elems){
3740         LDKCVecTempl_NodeAnnouncement *ret = MALLOC(sizeof(LDKCVecTempl_NodeAnnouncement), "LDKCVecTempl_NodeAnnouncement");
3741         ret->datalen = (*env)->GetArrayLength(env, elems);
3742         if (ret->datalen == 0) {
3743                 ret->data = NULL;
3744         } else {
3745                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVecTempl_NodeAnnouncement Data");
3746                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3747                 for (size_t i = 0; i < ret->datalen; i++) {
3748                         jlong arr_elem = java_elems[i];
3749                         LDKNodeAnnouncement arr_elem_conv;
3750                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3751                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3752                         if (arr_elem_conv.inner != NULL)
3753                                 arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3754                         ret->data[i] = arr_elem_conv;
3755                 }
3756                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3757         }
3758         return (long)ret;
3759 }
3760 typedef struct LDKRoutingMessageHandler_JCalls {
3761         atomic_size_t refcnt;
3762         JavaVM *vm;
3763         jweak o;
3764         jmethodID handle_node_announcement_meth;
3765         jmethodID handle_channel_announcement_meth;
3766         jmethodID handle_channel_update_meth;
3767         jmethodID handle_htlc_fail_channel_update_meth;
3768         jmethodID get_next_channel_announcements_meth;
3769         jmethodID get_next_node_announcements_meth;
3770         jmethodID should_request_full_sync_meth;
3771 } LDKRoutingMessageHandler_JCalls;
3772 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement *msg) {
3773         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3774         JNIEnv *_env;
3775         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3776         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3777         CHECK(obj != NULL);
3778         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_node_announcement_meth, msg);
3779         LDKCResult_boolLightningErrorZ res = *ret;
3780         FREE(ret);
3781         return res;
3782 }
3783 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement *msg) {
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         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3788         CHECK(obj != NULL);
3789         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_announcement_meth, msg);
3790         LDKCResult_boolLightningErrorZ res = *ret;
3791         FREE(ret);
3792         return res;
3793 }
3794 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate *msg) {
3795         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3796         JNIEnv *_env;
3797         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3798         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3799         CHECK(obj != NULL);
3800         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_update_meth, msg);
3801         LDKCResult_boolLightningErrorZ res = *ret;
3802         FREE(ret);
3803         return res;
3804 }
3805 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate *update) {
3806         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3807         JNIEnv *_env;
3808         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3809         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3810         CHECK(obj != NULL);
3811         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_htlc_fail_channel_update_meth, update);
3812 }
3813 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
3814         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3815         JNIEnv *_env;
3816         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3817         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3818         CHECK(obj != NULL);
3819         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
3820         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
3821         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
3822         if (ret_constr.datalen > 0)
3823                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
3824         else
3825                 ret_constr.data = NULL;
3826         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
3827         for (size_t l = 0; l < ret_constr.datalen; l++) {
3828                 long arr_conv_63 = ret_vals[l];
3829                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
3830                 FREE((void*)arr_conv_63);
3831                 ret_constr.data[l] = arr_conv_63_conv;
3832         }
3833         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
3834         return ret_constr;
3835 }
3836 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
3837         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3838         JNIEnv *_env;
3839         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3840         jbyteArray starting_point_arr = (*_env)->NewByteArray(_env, 33);
3841         (*_env)->SetByteArrayRegion(_env, starting_point_arr, 0, 33, starting_point.compressed_form);
3842         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3843         CHECK(obj != NULL);
3844         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
3845         LDKCVec_NodeAnnouncementZ ret_constr;
3846         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
3847         if (ret_constr.datalen > 0)
3848                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
3849         else
3850                 ret_constr.data = NULL;
3851         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
3852         for (size_t s = 0; s < ret_constr.datalen; s++) {
3853                 long arr_conv_18 = ret_vals[s];
3854                 LDKNodeAnnouncement arr_conv_18_conv;
3855                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
3856                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
3857                 if (arr_conv_18_conv.inner != NULL)
3858                         arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv);
3859                 ret_constr.data[s] = arr_conv_18_conv;
3860         }
3861         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
3862         return ret_constr;
3863 }
3864 bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) {
3865         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3866         JNIEnv *_env;
3867         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3868         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
3869         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, node_id.compressed_form);
3870         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3871         CHECK(obj != NULL);
3872         return (*_env)->CallBooleanMethod(_env, obj, j_calls->should_request_full_sync_meth, node_id_arr);
3873 }
3874 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
3875         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3876         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3877                 JNIEnv *env;
3878                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3879                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3880                 FREE(j_calls);
3881         }
3882 }
3883 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
3884         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3885         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3886         return (void*) this_arg;
3887 }
3888 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * env, jclass _a, jobject o) {
3889         jclass c = (*env)->GetObjectClass(env, o);
3890         CHECK(c != NULL);
3891         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
3892         atomic_init(&calls->refcnt, 1);
3893         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3894         calls->o = (*env)->NewWeakGlobalRef(env, o);
3895         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
3896         CHECK(calls->handle_node_announcement_meth != NULL);
3897         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
3898         CHECK(calls->handle_channel_announcement_meth != NULL);
3899         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
3900         CHECK(calls->handle_channel_update_meth != NULL);
3901         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
3902         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
3903         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
3904         CHECK(calls->get_next_channel_announcements_meth != NULL);
3905         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
3906         CHECK(calls->get_next_node_announcements_meth != NULL);
3907         calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "([B)Z");
3908         CHECK(calls->should_request_full_sync_meth != NULL);
3909
3910         LDKRoutingMessageHandler ret = {
3911                 .this_arg = (void*) calls,
3912                 .handle_node_announcement = handle_node_announcement_jcall,
3913                 .handle_channel_announcement = handle_channel_announcement_jcall,
3914                 .handle_channel_update = handle_channel_update_jcall,
3915                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
3916                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
3917                 .get_next_node_announcements = get_next_node_announcements_jcall,
3918                 .should_request_full_sync = should_request_full_sync_jcall,
3919                 .free = LDKRoutingMessageHandler_JCalls_free,
3920         };
3921         return ret;
3922 }
3923 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new (JNIEnv * env, jclass _a, jobject o) {
3924         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
3925         *res_ptr = LDKRoutingMessageHandler_init(env, _a, o);
3926         return (long)res_ptr;
3927 }
3928 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3929         jobject ret = (*env)->NewLocalRef(env, ((LDKRoutingMessageHandler_JCalls*)val)->o);
3930         CHECK(ret != NULL);
3931         return ret;
3932 }
3933 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3934         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3935         LDKNodeAnnouncement msg_conv;
3936         msg_conv.inner = (void*)(msg & (~1));
3937         msg_conv.is_owned = (msg & 1) || (msg == 0);
3938         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3939         *ret = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
3940         return (long)ret;
3941 }
3942
3943 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3944         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3945         LDKChannelAnnouncement msg_conv;
3946         msg_conv.inner = (void*)(msg & (~1));
3947         msg_conv.is_owned = (msg & 1) || (msg == 0);
3948         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3949         *ret = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3950         return (long)ret;
3951 }
3952
3953 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3954         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3955         LDKChannelUpdate msg_conv;
3956         msg_conv.inner = (void*)(msg & (~1));
3957         msg_conv.is_owned = (msg & 1) || (msg == 0);
3958         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3959         *ret = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
3960         return (long)ret;
3961 }
3962
3963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong update) {
3964         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3965         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
3966         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
3967 }
3968
3969 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) {
3970         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3971         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
3972         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
3973         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
3974         for (size_t l = 0; l < ret_var.datalen; l++) {
3975                 long arr_conv_63_ref = (long)&ret_var.data[l];
3976                 ret_arr_ptr[l] = arr_conv_63_ref;
3977         }
3978         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
3979         return ret_arr;
3980 }
3981
3982 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) {
3983         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3984         LDKPublicKey starting_point_ref;
3985         CHECK((*_env)->GetArrayLength (_env, starting_point) == 33);
3986         (*_env)->GetByteArrayRegion (_env, starting_point, 0, 33, starting_point_ref.compressed_form);
3987         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
3988         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
3989         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
3990         for (size_t s = 0; s < ret_var.datalen; s++) {
3991                 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
3992                 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3993                 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3994                 long arr_conv_18_ref;
3995                 if (arr_conv_18_var.is_owned) {
3996                         arr_conv_18_ref = (long)arr_conv_18_var.inner | 1;
3997                 } else {
3998                         arr_conv_18_ref = (long)&arr_conv_18_var;
3999                 }
4000                 ret_arr_ptr[s] = arr_conv_18_ref;
4001         }
4002         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
4003         FREE(ret_var.data);
4004         return ret_arr;
4005 }
4006
4007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray node_id) {
4008         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4009         LDKPublicKey node_id_ref;
4010         CHECK((*_env)->GetArrayLength (_env, node_id) == 33);
4011         (*_env)->GetByteArrayRegion (_env, node_id, 0, 33, node_id_ref.compressed_form);
4012         jboolean ret_val = (this_arg_conv->should_request_full_sync)(this_arg_conv->this_arg, node_id_ref);
4013         return ret_val;
4014 }
4015
4016 typedef struct LDKSocketDescriptor_JCalls {
4017         atomic_size_t refcnt;
4018         JavaVM *vm;
4019         jweak o;
4020         jmethodID send_data_meth;
4021         jmethodID disconnect_socket_meth;
4022         jmethodID eq_meth;
4023         jmethodID hash_meth;
4024 } LDKSocketDescriptor_JCalls;
4025 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
4026         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4027         JNIEnv *_env;
4028         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
4029         LDKu8slice data_var = data;
4030         jbyteArray data_arr = (*_env)->NewByteArray(_env, data_var.datalen);
4031         (*_env)->SetByteArrayRegion(_env, data_arr, 0, data_var.datalen, data_var.data);
4032         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
4033         CHECK(obj != NULL);
4034         return (*_env)->CallLongMethod(_env, obj, j_calls->send_data_meth, data_arr, resume_read);
4035 }
4036 void disconnect_socket_jcall(void* this_arg) {
4037         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4038         JNIEnv *_env;
4039         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
4040         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
4041         CHECK(obj != NULL);
4042         return (*_env)->CallVoidMethod(_env, obj, j_calls->disconnect_socket_meth);
4043 }
4044 bool eq_jcall(const void* this_arg, const void *other_arg) {
4045         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4046         JNIEnv *_env;
4047         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
4048         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
4049         CHECK(obj != NULL);
4050         return (*_env)->CallBooleanMethod(_env, obj, j_calls->eq_meth, other_arg);
4051 }
4052 uint64_t hash_jcall(const void* this_arg) {
4053         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4054         JNIEnv *_env;
4055         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
4056         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
4057         CHECK(obj != NULL);
4058         return (*_env)->CallLongMethod(_env, obj, j_calls->hash_meth);
4059 }
4060 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
4061         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4062         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4063                 JNIEnv *env;
4064                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
4065                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4066                 FREE(j_calls);
4067         }
4068 }
4069 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
4070         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4071         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4072         return (void*) this_arg;
4073 }
4074 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv * env, jclass _a, jobject o) {
4075         jclass c = (*env)->GetObjectClass(env, o);
4076         CHECK(c != NULL);
4077         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
4078         atomic_init(&calls->refcnt, 1);
4079         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4080         calls->o = (*env)->NewWeakGlobalRef(env, o);
4081         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
4082         CHECK(calls->send_data_meth != NULL);
4083         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
4084         CHECK(calls->disconnect_socket_meth != NULL);
4085         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
4086         CHECK(calls->eq_meth != NULL);
4087         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
4088         CHECK(calls->hash_meth != NULL);
4089
4090         LDKSocketDescriptor ret = {
4091                 .this_arg = (void*) calls,
4092                 .send_data = send_data_jcall,
4093                 .disconnect_socket = disconnect_socket_jcall,
4094                 .eq = eq_jcall,
4095                 .hash = hash_jcall,
4096                 .clone = LDKSocketDescriptor_JCalls_clone,
4097                 .free = LDKSocketDescriptor_JCalls_free,
4098         };
4099         return ret;
4100 }
4101 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new (JNIEnv * env, jclass _a, jobject o) {
4102         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
4103         *res_ptr = LDKSocketDescriptor_init(env, _a, o);
4104         return (long)res_ptr;
4105 }
4106 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
4107         jobject ret = (*env)->NewLocalRef(env, ((LDKSocketDescriptor_JCalls*)val)->o);
4108         CHECK(ret != NULL);
4109         return ret;
4110 }
4111 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray data, jboolean resume_read) {
4112         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4113         LDKu8slice data_ref;
4114         data_ref.data = (*_env)->GetByteArrayElements (_env, data, NULL);
4115         data_ref.datalen = (*_env)->GetArrayLength (_env, data);
4116         jlong ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
4117         (*_env)->ReleaseByteArrayElements(_env, data, (int8_t*)data_ref.data, 0);
4118         return ret_val;
4119 }
4120
4121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv * _env, jclass _b, jlong this_arg) {
4122         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4123         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
4124 }
4125
4126 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv * _env, jclass _b, jlong this_arg) {
4127         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4128         jlong ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
4129         return ret_val;
4130 }
4131
4132 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4133         LDKCVecTempl_PublicKey *vec = (LDKCVecTempl_PublicKey*)ptr;
4134         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKPublicKey));
4135 }
4136 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4137         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4138 }
4139 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4140         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4141         CHECK(val->result_ok);
4142         LDKCVecTempl_u8 res_var = (*val->contents.result);
4143         jbyteArray res_arr = (*_env)->NewByteArray(_env, res_var.datalen);
4144         (*_env)->SetByteArrayRegion(_env, res_arr, 0, res_var.datalen, res_var.data);
4145         return res_arr;
4146 }
4147 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4148         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4149         CHECK(!val->result_ok);
4150         LDKPeerHandleError err_var = (*val->contents.err);
4151         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4152         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4153         long err_ref;
4154         if (err_var.is_owned) {
4155                 err_ref = (long)err_var.inner | 1;
4156         } else {
4157                 err_ref = (long)&err_var;
4158         }
4159         return err_ref;
4160 }
4161 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4162         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4163 }
4164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4165         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
4166         CHECK(val->result_ok);
4167         return *val->contents.result;
4168 }
4169 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4170         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
4171         CHECK(!val->result_ok);
4172         LDKPeerHandleError err_var = (*val->contents.err);
4173         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4174         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4175         long err_ref;
4176         if (err_var.is_owned) {
4177                 err_ref = (long)err_var.inner | 1;
4178         } else {
4179                 err_ref = (long)&err_var;
4180         }
4181         return err_ref;
4182 }
4183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4184         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
4185 }
4186 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4187         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
4188         CHECK(val->result_ok);
4189         jbyteArray res_arr = (*_env)->NewByteArray(_env, 32);
4190         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 32, (*val->contents.result).bytes);
4191         return res_arr;
4192 }
4193 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4194         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
4195         CHECK(!val->result_ok);
4196         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4197         return err_conv;
4198 }
4199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4200         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
4201 }
4202 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4203         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
4204         CHECK(val->result_ok);
4205         jbyteArray res_arr = (*_env)->NewByteArray(_env, 33);
4206         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 33, (*val->contents.result).compressed_form);
4207         return res_arr;
4208 }
4209 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4210         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
4211         CHECK(!val->result_ok);
4212         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4213         return err_conv;
4214 }
4215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4216         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
4217 }
4218 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4219         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4220         CHECK(val->result_ok);
4221         LDKTxCreationKeys res_var = (*val->contents.result);
4222         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4223         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4224         long res_ref;
4225         if (res_var.is_owned) {
4226                 res_ref = (long)res_var.inner | 1;
4227         } else {
4228                 res_ref = (long)&res_var;
4229         }
4230         return res_ref;
4231 }
4232 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4233         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4234         CHECK(!val->result_ok);
4235         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4236         return err_conv;
4237 }
4238 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4239         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *vec = (LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature*)ptr;
4240         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature));
4241 }
4242 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
4243         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature), "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature");
4244         ret->datalen = (*env)->GetArrayLength(env, elems);
4245         if (ret->datalen == 0) {
4246                 ret->data = NULL;
4247         } else {
4248                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature) * ret->datalen, "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature Data");
4249                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4250                 for (size_t i = 0; i < ret->datalen; i++) {
4251                         jlong arr_elem = java_elems[i];
4252                         LDKC2TupleTempl_HTLCOutputInCommitment__Signature arr_elem_conv = *(LDKC2TupleTempl_HTLCOutputInCommitment__Signature*)arr_elem;
4253                         FREE((void*)arr_elem);
4254                         ret->data[i] = arr_elem_conv;
4255                 }
4256                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4257         }
4258         return (long)ret;
4259 }
4260 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4261         LDKCVecTempl_RouteHop *vec = (LDKCVecTempl_RouteHop*)ptr;
4262         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
4263         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
4264         for (size_t i = 0; i < vec->datalen; i++) {
4265                 CHECK((((long)vec->data[i].inner) & 1) == 0);
4266                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
4267         }
4268         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
4269         return ret;
4270 }
4271 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
4272         LDKCVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_RouteHop), "LDKCVecTempl_RouteHop");
4273         ret->datalen = (*env)->GetArrayLength(env, elems);
4274         if (ret->datalen == 0) {
4275                 ret->data = NULL;
4276         } else {
4277                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVecTempl_RouteHop Data");
4278                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4279                 for (size_t i = 0; i < ret->datalen; i++) {
4280                         jlong arr_elem = java_elems[i];
4281                         LDKRouteHop arr_elem_conv;
4282                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4283                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4284                         if (arr_elem_conv.inner != NULL)
4285                                 arr_elem_conv = RouteHop_clone(&arr_elem_conv);
4286                         ret->data[i] = arr_elem_conv;
4287                 }
4288                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4289         }
4290         return (long)ret;
4291 }
4292 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4293         LDKCVecTempl_CVecTempl_RouteHop *vec = (LDKCVecTempl_CVecTempl_RouteHop*)ptr;
4294         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVecTempl_RouteHop));
4295 }
4296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4297         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
4298 }
4299 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4300         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
4301         CHECK(val->result_ok);
4302         LDKRoute res_var = (*val->contents.result);
4303         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4304         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4305         long res_ref;
4306         if (res_var.is_owned) {
4307                 res_ref = (long)res_var.inner | 1;
4308         } else {
4309                 res_ref = (long)&res_var;
4310         }
4311         return res_ref;
4312 }
4313 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4314         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
4315         CHECK(!val->result_ok);
4316         LDKLightningError err_var = (*val->contents.err);
4317         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4318         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4319         long err_ref;
4320         if (err_var.is_owned) {
4321                 err_ref = (long)err_var.inner | 1;
4322         } else {
4323                 err_ref = (long)&err_var;
4324         }
4325         return err_ref;
4326 }
4327 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4328         LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr;
4329         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
4330         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
4331         for (size_t i = 0; i < vec->datalen; i++) {
4332                 CHECK((((long)vec->data[i].inner) & 1) == 0);
4333                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
4334         }
4335         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
4336         return ret;
4337 }
4338 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1new(JNIEnv *env, jclass _b, jlongArray elems){
4339         LDKCVecTempl_RouteHint *ret = MALLOC(sizeof(LDKCVecTempl_RouteHint), "LDKCVecTempl_RouteHint");
4340         ret->datalen = (*env)->GetArrayLength(env, elems);
4341         if (ret->datalen == 0) {
4342                 ret->data = NULL;
4343         } else {
4344                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVecTempl_RouteHint Data");
4345                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4346                 for (size_t i = 0; i < ret->datalen; i++) {
4347                         jlong arr_elem = java_elems[i];
4348                         LDKRouteHint arr_elem_conv;
4349                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4350                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4351                         if (arr_elem_conv.inner != NULL)
4352                                 arr_elem_conv = RouteHint_clone(&arr_elem_conv);
4353                         ret->data[i] = arr_elem_conv;
4354                 }
4355                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4356         }
4357         return (long)ret;
4358 }
4359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4360         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arg_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arg;
4361         FREE((void*)arg);
4362         C2Tuple_HTLCOutputInCommitmentSignatureZ_free(arg_conv);
4363 }
4364
4365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4366         LDKC2Tuple_OutPointScriptZ arg_conv = *(LDKC2Tuple_OutPointScriptZ*)arg;
4367         FREE((void*)arg);
4368         C2Tuple_OutPointScriptZ_free(arg_conv);
4369 }
4370
4371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4372         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4373         FREE((void*)arg);
4374         C2Tuple_SignatureCVec_SignatureZZ_free(arg_conv);
4375 }
4376
4377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4378         LDKC2Tuple_TxidCVec_TxOutZZ arg_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arg;
4379         FREE((void*)arg);
4380         C2Tuple_TxidCVec_TxOutZZ_free(arg_conv);
4381 }
4382
4383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4384         LDKC2Tuple_u64u64Z arg_conv = *(LDKC2Tuple_u64u64Z*)arg;
4385         FREE((void*)arg);
4386         C2Tuple_u64u64Z_free(arg_conv);
4387 }
4388
4389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4390         LDKC2Tuple_usizeTransactionZ arg_conv = *(LDKC2Tuple_usizeTransactionZ*)arg;
4391         FREE((void*)arg);
4392         C2Tuple_usizeTransactionZ_free(arg_conv);
4393 }
4394
4395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4396         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arg_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arg;
4397         FREE((void*)arg);
4398         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(arg_conv);
4399 }
4400
4401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4402         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ arg_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
4403         FREE((void*)arg);
4404         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(arg_conv);
4405 }
4406
4407 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4408         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4409         FREE((void*)arg);
4410         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4411         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(arg_conv);
4412         return (long)ret;
4413 }
4414
4415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4416         LDKCResult_CVec_SignatureZNoneZ arg_conv = *(LDKCResult_CVec_SignatureZNoneZ*)arg;
4417         FREE((void*)arg);
4418         CResult_CVec_SignatureZNoneZ_free(arg_conv);
4419 }
4420
4421 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jobjectArray arg) {
4422         LDKCVec_SignatureZ arg_constr;
4423         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4424         if (arg_constr.datalen > 0)
4425                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4426         else
4427                 arg_constr.data = NULL;
4428         for (size_t i = 0; i < arg_constr.datalen; i++) {
4429                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
4430                 LDKSignature arr_conv_8_ref;
4431                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
4432                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
4433                 arg_constr.data[i] = arr_conv_8_ref;
4434         }
4435         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4436         *ret = CResult_CVec_SignatureZNoneZ_ok(arg_constr);
4437         return (long)ret;
4438 }
4439
4440 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4441         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4442         FREE((void*)arg);
4443         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4444         *ret = CResult_CVec_u8ZPeerHandleErrorZ_err(arg_conv);
4445         return (long)ret;
4446 }
4447
4448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4449         LDKCResult_CVec_u8ZPeerHandleErrorZ arg_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4450         FREE((void*)arg);
4451         CResult_CVec_u8ZPeerHandleErrorZ_free(arg_conv);
4452 }
4453
4454 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4455         LDKCVec_u8Z arg_ref;
4456         arg_ref.data = (*_env)->GetByteArrayElements (_env, arg, NULL);
4457         arg_ref.datalen = (*_env)->GetArrayLength (_env, arg);
4458         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4459         *ret = CResult_CVec_u8ZPeerHandleErrorZ_ok(arg_ref);
4460         (*_env)->ReleaseByteArrayElements(_env, arg, (int8_t*)arg_ref.data, 0);
4461         return (long)ret;
4462 }
4463
4464 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4465         LDKAPIError arg_conv = *(LDKAPIError*)arg;
4466         FREE((void*)arg);
4467         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4468         *ret = CResult_NoneAPIErrorZ_err(arg_conv);
4469         return (long)ret;
4470 }
4471
4472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4473         LDKCResult_NoneAPIErrorZ arg_conv = *(LDKCResult_NoneAPIErrorZ*)arg;
4474         FREE((void*)arg);
4475         CResult_NoneAPIErrorZ_free(arg_conv);
4476 }
4477
4478 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4479         LDKChannelMonitorUpdateErr arg_conv = *(LDKChannelMonitorUpdateErr*)arg;
4480         FREE((void*)arg);
4481         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4482         *ret = CResult_NoneChannelMonitorUpdateErrZ_err(arg_conv);
4483         return (long)ret;
4484 }
4485
4486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4487         LDKCResult_NoneChannelMonitorUpdateErrZ arg_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
4488         FREE((void*)arg);
4489         CResult_NoneChannelMonitorUpdateErrZ_free(arg_conv);
4490 }
4491
4492 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4493         LDKMonitorUpdateError arg_conv = *(LDKMonitorUpdateError*)arg;
4494         FREE((void*)arg);
4495         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4496         *ret = CResult_NoneMonitorUpdateErrorZ_err(arg_conv);
4497         return (long)ret;
4498 }
4499
4500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4501         LDKCResult_NoneMonitorUpdateErrorZ arg_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)arg;
4502         FREE((void*)arg);
4503         CResult_NoneMonitorUpdateErrorZ_free(arg_conv);
4504 }
4505
4506 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4507         LDKPaymentSendFailure arg_conv = *(LDKPaymentSendFailure*)arg;
4508         FREE((void*)arg);
4509         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4510         *ret = CResult_NonePaymentSendFailureZ_err(arg_conv);
4511         return (long)ret;
4512 }
4513
4514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4515         LDKCResult_NonePaymentSendFailureZ arg_conv = *(LDKCResult_NonePaymentSendFailureZ*)arg;
4516         FREE((void*)arg);
4517         CResult_NonePaymentSendFailureZ_free(arg_conv);
4518 }
4519
4520 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4521         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4522         FREE((void*)arg);
4523         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4524         *ret = CResult_NonePeerHandleErrorZ_err(arg_conv);
4525         return (long)ret;
4526 }
4527
4528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4529         LDKCResult_NonePeerHandleErrorZ arg_conv = *(LDKCResult_NonePeerHandleErrorZ*)arg;
4530         FREE((void*)arg);
4531         CResult_NonePeerHandleErrorZ_free(arg_conv);
4532 }
4533
4534 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4535         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4536         FREE((void*)arg);
4537         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4538         *ret = CResult_PublicKeySecpErrorZ_err(arg_conv);
4539         return (long)ret;
4540 }
4541
4542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4543         LDKCResult_PublicKeySecpErrorZ arg_conv = *(LDKCResult_PublicKeySecpErrorZ*)arg;
4544         FREE((void*)arg);
4545         CResult_PublicKeySecpErrorZ_free(arg_conv);
4546 }
4547
4548 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4549         LDKPublicKey arg_ref;
4550         CHECK((*_env)->GetArrayLength (_env, arg) == 33);
4551         (*_env)->GetByteArrayRegion (_env, arg, 0, 33, arg_ref.compressed_form);
4552         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4553         *ret = CResult_PublicKeySecpErrorZ_ok(arg_ref);
4554         return (long)ret;
4555 }
4556
4557 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4558         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4559         FREE((void*)arg);
4560         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4561         *ret = CResult_RouteLightningErrorZ_err(arg_conv);
4562         return (long)ret;
4563 }
4564
4565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4566         LDKCResult_RouteLightningErrorZ arg_conv = *(LDKCResult_RouteLightningErrorZ*)arg;
4567         FREE((void*)arg);
4568         CResult_RouteLightningErrorZ_free(arg_conv);
4569 }
4570
4571 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4572         LDKRoute arg_conv = *(LDKRoute*)arg;
4573         FREE((void*)arg);
4574         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4575         *ret = CResult_RouteLightningErrorZ_ok(arg_conv);
4576         return (long)ret;
4577 }
4578
4579 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4580         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4581         FREE((void*)arg);
4582         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4583         *ret = CResult_SecretKeySecpErrorZ_err(arg_conv);
4584         return (long)ret;
4585 }
4586
4587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4588         LDKCResult_SecretKeySecpErrorZ arg_conv = *(LDKCResult_SecretKeySecpErrorZ*)arg;
4589         FREE((void*)arg);
4590         CResult_SecretKeySecpErrorZ_free(arg_conv);
4591 }
4592
4593 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4594         LDKSecretKey arg_ref;
4595         CHECK((*_env)->GetArrayLength (_env, arg) == 32);
4596         (*_env)->GetByteArrayRegion (_env, arg, 0, 32, arg_ref.bytes);
4597         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4598         *ret = CResult_SecretKeySecpErrorZ_ok(arg_ref);
4599         return (long)ret;
4600 }
4601
4602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4603         LDKCResult_SignatureNoneZ arg_conv = *(LDKCResult_SignatureNoneZ*)arg;
4604         FREE((void*)arg);
4605         CResult_SignatureNoneZ_free(arg_conv);
4606 }
4607
4608 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4609         LDKSignature arg_ref;
4610         CHECK((*_env)->GetArrayLength (_env, arg) == 64);
4611         (*_env)->GetByteArrayRegion (_env, arg, 0, 64, arg_ref.compact_form);
4612         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4613         *ret = CResult_SignatureNoneZ_ok(arg_ref);
4614         return (long)ret;
4615 }
4616
4617 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4618         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4619         FREE((void*)arg);
4620         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4621         *ret = CResult_TxCreationKeysSecpErrorZ_err(arg_conv);
4622         return (long)ret;
4623 }
4624
4625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4626         LDKCResult_TxCreationKeysSecpErrorZ arg_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4627         FREE((void*)arg);
4628         CResult_TxCreationKeysSecpErrorZ_free(arg_conv);
4629 }
4630
4631 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4632         LDKTxCreationKeys arg_conv = *(LDKTxCreationKeys*)arg;
4633         FREE((void*)arg);
4634         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4635         *ret = CResult_TxCreationKeysSecpErrorZ_ok(arg_conv);
4636         return (long)ret;
4637 }
4638
4639 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4640         LDKAccessError arg_conv = *(LDKAccessError*)arg;
4641         FREE((void*)arg);
4642         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4643         *ret = CResult_TxOutAccessErrorZ_err(arg_conv);
4644         return (long)ret;
4645 }
4646
4647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4648         LDKCResult_TxOutAccessErrorZ arg_conv = *(LDKCResult_TxOutAccessErrorZ*)arg;
4649         FREE((void*)arg);
4650         CResult_TxOutAccessErrorZ_free(arg_conv);
4651 }
4652
4653 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4654         LDKTxOut arg_conv = *(LDKTxOut*)arg;
4655         FREE((void*)arg);
4656         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4657         *ret = CResult_TxOutAccessErrorZ_ok(arg_conv);
4658         return (long)ret;
4659 }
4660
4661 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4662         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4663         FREE((void*)arg);
4664         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4665         *ret = CResult_boolLightningErrorZ_err(arg_conv);
4666         return (long)ret;
4667 }
4668
4669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4670         LDKCResult_boolLightningErrorZ arg_conv = *(LDKCResult_boolLightningErrorZ*)arg;
4671         FREE((void*)arg);
4672         CResult_boolLightningErrorZ_free(arg_conv);
4673 }
4674
4675 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4676         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4677         *ret = CResult_boolLightningErrorZ_ok(arg);
4678         return (long)ret;
4679 }
4680
4681 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4682         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4683         FREE((void*)arg);
4684         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4685         *ret = CResult_boolPeerHandleErrorZ_err(arg_conv);
4686         return (long)ret;
4687 }
4688
4689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4690         LDKCResult_boolPeerHandleErrorZ arg_conv = *(LDKCResult_boolPeerHandleErrorZ*)arg;
4691         FREE((void*)arg);
4692         CResult_boolPeerHandleErrorZ_free(arg_conv);
4693 }
4694
4695 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4696         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4697         *ret = CResult_boolPeerHandleErrorZ_ok(arg);
4698         return (long)ret;
4699 }
4700
4701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4702         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_constr;
4703         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4704         if (arg_constr.datalen > 0)
4705                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
4706         else
4707                 arg_constr.data = NULL;
4708         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4709         for (size_t q = 0; q < arg_constr.datalen; q++) {
4710                 long arr_conv_42 = arg_vals[q];
4711                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
4712                 FREE((void*)arr_conv_42);
4713                 arg_constr.data[q] = arr_conv_42_conv;
4714         }
4715         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4716         CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_constr);
4717 }
4718
4719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4720         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_constr;
4721         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4722         if (arg_constr.datalen > 0)
4723                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ Elements");
4724         else
4725                 arg_constr.data = NULL;
4726         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4727         for (size_t b = 0; b < arg_constr.datalen; b++) {
4728                 long arr_conv_27 = arg_vals[b];
4729                 LDKC2Tuple_TxidCVec_TxOutZZ arr_conv_27_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arr_conv_27;
4730                 FREE((void*)arr_conv_27);
4731                 arg_constr.data[b] = arr_conv_27_conv;
4732         }
4733         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4734         CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_constr);
4735 }
4736
4737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4738         LDKCVec_C2Tuple_usizeTransactionZZ arg_constr;
4739         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4740         if (arg_constr.datalen > 0)
4741                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
4742         else
4743                 arg_constr.data = NULL;
4744         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4745         for (size_t d = 0; d < arg_constr.datalen; d++) {
4746                 long arr_conv_29 = arg_vals[d];
4747                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
4748                 FREE((void*)arr_conv_29);
4749                 arg_constr.data[d] = arr_conv_29_conv;
4750         }
4751         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4752         CVec_C2Tuple_usizeTransactionZZ_free(arg_constr);
4753 }
4754
4755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4756         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_constr;
4757         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4758         if (arg_constr.datalen > 0)
4759                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
4760         else
4761                 arg_constr.data = NULL;
4762         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4763         for (size_t l = 0; l < arg_constr.datalen; l++) {
4764                 long arr_conv_63 = arg_vals[l];
4765                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
4766                 FREE((void*)arr_conv_63);
4767                 arg_constr.data[l] = arr_conv_63_conv;
4768         }
4769         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4770         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_constr);
4771 }
4772
4773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
4774         LDKCVec_CVec_RouteHopZZ arg_constr;
4775         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4776         if (arg_constr.datalen > 0)
4777                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
4778         else
4779                 arg_constr.data = NULL;
4780         for (size_t m = 0; m < arg_constr.datalen; m++) {
4781                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, arg, m);
4782                 LDKCVec_RouteHopZ arr_conv_12_constr;
4783                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
4784                 if (arr_conv_12_constr.datalen > 0)
4785                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
4786                 else
4787                         arr_conv_12_constr.data = NULL;
4788                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
4789                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
4790                         long arr_conv_10 = arr_conv_12_vals[k];
4791                         LDKRouteHop arr_conv_10_conv;
4792                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
4793                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
4794                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
4795                 }
4796                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
4797                 arg_constr.data[m] = arr_conv_12_constr;
4798         }
4799         CVec_CVec_RouteHopZZ_free(arg_constr);
4800 }
4801
4802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4803         LDKCVec_ChannelDetailsZ arg_constr;
4804         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4805         if (arg_constr.datalen > 0)
4806                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
4807         else
4808                 arg_constr.data = NULL;
4809         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4810         for (size_t q = 0; q < arg_constr.datalen; q++) {
4811                 long arr_conv_16 = arg_vals[q];
4812                 LDKChannelDetails arr_conv_16_conv;
4813                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4814                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4815                 arg_constr.data[q] = arr_conv_16_conv;
4816         }
4817         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4818         CVec_ChannelDetailsZ_free(arg_constr);
4819 }
4820
4821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4822         LDKCVec_ChannelMonitorZ arg_constr;
4823         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4824         if (arg_constr.datalen > 0)
4825                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
4826         else
4827                 arg_constr.data = NULL;
4828         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4829         for (size_t q = 0; q < arg_constr.datalen; q++) {
4830                 long arr_conv_16 = arg_vals[q];
4831                 LDKChannelMonitor arr_conv_16_conv;
4832                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4833                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4834                 arg_constr.data[q] = arr_conv_16_conv;
4835         }
4836         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4837         CVec_ChannelMonitorZ_free(arg_constr);
4838 }
4839
4840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4841         LDKCVec_EventZ arg_constr;
4842         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4843         if (arg_constr.datalen > 0)
4844                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4845         else
4846                 arg_constr.data = NULL;
4847         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4848         for (size_t h = 0; h < arg_constr.datalen; h++) {
4849                 long arr_conv_7 = arg_vals[h];
4850                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
4851                 FREE((void*)arr_conv_7);
4852                 arg_constr.data[h] = arr_conv_7_conv;
4853         }
4854         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4855         CVec_EventZ_free(arg_constr);
4856 }
4857
4858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4859         LDKCVec_HTLCOutputInCommitmentZ arg_constr;
4860         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4861         if (arg_constr.datalen > 0)
4862                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
4863         else
4864                 arg_constr.data = NULL;
4865         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4866         for (size_t y = 0; y < arg_constr.datalen; y++) {
4867                 long arr_conv_24 = arg_vals[y];
4868                 LDKHTLCOutputInCommitment arr_conv_24_conv;
4869                 arr_conv_24_conv.inner = (void*)(arr_conv_24 & (~1));
4870                 arr_conv_24_conv.is_owned = (arr_conv_24 & 1) || (arr_conv_24 == 0);
4871                 arg_constr.data[y] = arr_conv_24_conv;
4872         }
4873         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4874         CVec_HTLCOutputInCommitmentZ_free(arg_constr);
4875 }
4876
4877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4878         LDKCVec_MessageSendEventZ arg_constr;
4879         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4880         if (arg_constr.datalen > 0)
4881                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4882         else
4883                 arg_constr.data = NULL;
4884         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4885         for (size_t s = 0; s < arg_constr.datalen; s++) {
4886                 long arr_conv_18 = arg_vals[s];
4887                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
4888                 FREE((void*)arr_conv_18);
4889                 arg_constr.data[s] = arr_conv_18_conv;
4890         }
4891         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4892         CVec_MessageSendEventZ_free(arg_constr);
4893 }
4894
4895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4896         LDKCVec_MonitorEventZ arg_constr;
4897         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4898         if (arg_constr.datalen > 0)
4899                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4900         else
4901                 arg_constr.data = NULL;
4902         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4903         for (size_t o = 0; o < arg_constr.datalen; o++) {
4904                 long arr_conv_14 = arg_vals[o];
4905                 LDKMonitorEvent arr_conv_14_conv;
4906                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
4907                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
4908                 arg_constr.data[o] = arr_conv_14_conv;
4909         }
4910         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4911         CVec_MonitorEventZ_free(arg_constr);
4912 }
4913
4914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4915         LDKCVec_NetAddressZ arg_constr;
4916         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4917         if (arg_constr.datalen > 0)
4918                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
4919         else
4920                 arg_constr.data = NULL;
4921         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4922         for (size_t m = 0; m < arg_constr.datalen; m++) {
4923                 long arr_conv_12 = arg_vals[m];
4924                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
4925                 FREE((void*)arr_conv_12);
4926                 arg_constr.data[m] = arr_conv_12_conv;
4927         }
4928         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4929         CVec_NetAddressZ_free(arg_constr);
4930 }
4931
4932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4933         LDKCVec_NodeAnnouncementZ arg_constr;
4934         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4935         if (arg_constr.datalen > 0)
4936                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
4937         else
4938                 arg_constr.data = NULL;
4939         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4940         for (size_t s = 0; s < arg_constr.datalen; s++) {
4941                 long arr_conv_18 = arg_vals[s];
4942                 LDKNodeAnnouncement arr_conv_18_conv;
4943                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
4944                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
4945                 arg_constr.data[s] = arr_conv_18_conv;
4946         }
4947         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4948         CVec_NodeAnnouncementZ_free(arg_constr);
4949 }
4950
4951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
4952         LDKCVec_PublicKeyZ arg_constr;
4953         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4954         if (arg_constr.datalen > 0)
4955                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
4956         else
4957                 arg_constr.data = NULL;
4958         for (size_t i = 0; i < arg_constr.datalen; i++) {
4959                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
4960                 LDKPublicKey arr_conv_8_ref;
4961                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 33);
4962                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 33, arr_conv_8_ref.compressed_form);
4963                 arg_constr.data[i] = arr_conv_8_ref;
4964         }
4965         CVec_PublicKeyZ_free(arg_constr);
4966 }
4967
4968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4969         LDKCVec_RouteHintZ arg_constr;
4970         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4971         if (arg_constr.datalen > 0)
4972                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
4973         else
4974                 arg_constr.data = NULL;
4975         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4976         for (size_t l = 0; l < arg_constr.datalen; l++) {
4977                 long arr_conv_11 = arg_vals[l];
4978                 LDKRouteHint arr_conv_11_conv;
4979                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
4980                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
4981                 arg_constr.data[l] = arr_conv_11_conv;
4982         }
4983         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4984         CVec_RouteHintZ_free(arg_constr);
4985 }
4986
4987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4988         LDKCVec_RouteHopZ arg_constr;
4989         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4990         if (arg_constr.datalen > 0)
4991                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
4992         else
4993                 arg_constr.data = NULL;
4994         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4995         for (size_t k = 0; k < arg_constr.datalen; k++) {
4996                 long arr_conv_10 = arg_vals[k];
4997                 LDKRouteHop arr_conv_10_conv;
4998                 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
4999                 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
5000                 arg_constr.data[k] = arr_conv_10_conv;
5001         }
5002         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5003         CVec_RouteHopZ_free(arg_constr);
5004 }
5005
5006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
5007         LDKCVec_SignatureZ arg_constr;
5008         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5009         if (arg_constr.datalen > 0)
5010                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5011         else
5012                 arg_constr.data = NULL;
5013         for (size_t i = 0; i < arg_constr.datalen; i++) {
5014                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
5015                 LDKSignature arr_conv_8_ref;
5016                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
5017                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
5018                 arg_constr.data[i] = arr_conv_8_ref;
5019         }
5020         CVec_SignatureZ_free(arg_constr);
5021 }
5022
5023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5024         LDKCVec_SpendableOutputDescriptorZ arg_constr;
5025         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5026         if (arg_constr.datalen > 0)
5027                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
5028         else
5029                 arg_constr.data = NULL;
5030         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5031         for (size_t b = 0; b < arg_constr.datalen; b++) {
5032                 long arr_conv_27 = arg_vals[b];
5033                 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)arr_conv_27;
5034                 FREE((void*)arr_conv_27);
5035                 arg_constr.data[b] = arr_conv_27_conv;
5036         }
5037         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5038         CVec_SpendableOutputDescriptorZ_free(arg_constr);
5039 }
5040
5041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5042         LDKCVec_TransactionZ arg_constr;
5043         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5044         if (arg_constr.datalen > 0)
5045                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
5046         else
5047                 arg_constr.data = NULL;
5048         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5049         for (size_t n = 0; n < arg_constr.datalen; n++) {
5050                 long arr_conv_13 = arg_vals[n];
5051                 LDKTransaction arr_conv_13_conv = *(LDKTransaction*)arr_conv_13;
5052                 FREE((void*)arr_conv_13);
5053                 arg_constr.data[n] = arr_conv_13_conv;
5054         }
5055         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5056         CVec_TransactionZ_free(arg_constr);
5057 }
5058
5059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5060         LDKCVec_TxOutZ arg_constr;
5061         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5062         if (arg_constr.datalen > 0)
5063                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
5064         else
5065                 arg_constr.data = NULL;
5066         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5067         for (size_t h = 0; h < arg_constr.datalen; h++) {
5068                 long arr_conv_7 = arg_vals[h];
5069                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
5070                 FREE((void*)arr_conv_7);
5071                 arg_constr.data[h] = arr_conv_7_conv;
5072         }
5073         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5074         CVec_TxOutZ_free(arg_constr);
5075 }
5076
5077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5078         LDKCVec_UpdateAddHTLCZ arg_constr;
5079         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5080         if (arg_constr.datalen > 0)
5081                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
5082         else
5083                 arg_constr.data = NULL;
5084         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5085         for (size_t p = 0; p < arg_constr.datalen; p++) {
5086                 long arr_conv_15 = arg_vals[p];
5087                 LDKUpdateAddHTLC arr_conv_15_conv;
5088                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
5089                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
5090                 arg_constr.data[p] = arr_conv_15_conv;
5091         }
5092         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5093         CVec_UpdateAddHTLCZ_free(arg_constr);
5094 }
5095
5096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5097         LDKCVec_UpdateFailHTLCZ arg_constr;
5098         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5099         if (arg_constr.datalen > 0)
5100                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
5101         else
5102                 arg_constr.data = NULL;
5103         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5104         for (size_t q = 0; q < arg_constr.datalen; q++) {
5105                 long arr_conv_16 = arg_vals[q];
5106                 LDKUpdateFailHTLC arr_conv_16_conv;
5107                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5108                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5109                 arg_constr.data[q] = arr_conv_16_conv;
5110         }
5111         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5112         CVec_UpdateFailHTLCZ_free(arg_constr);
5113 }
5114
5115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5116         LDKCVec_UpdateFailMalformedHTLCZ arg_constr;
5117         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5118         if (arg_constr.datalen > 0)
5119                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
5120         else
5121                 arg_constr.data = NULL;
5122         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5123         for (size_t z = 0; z < arg_constr.datalen; z++) {
5124                 long arr_conv_25 = arg_vals[z];
5125                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
5126                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
5127                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
5128                 arg_constr.data[z] = arr_conv_25_conv;
5129         }
5130         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5131         CVec_UpdateFailMalformedHTLCZ_free(arg_constr);
5132 }
5133
5134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5135         LDKCVec_UpdateFulfillHTLCZ arg_constr;
5136         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5137         if (arg_constr.datalen > 0)
5138                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
5139         else
5140                 arg_constr.data = NULL;
5141         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5142         for (size_t t = 0; t < arg_constr.datalen; t++) {
5143                 long arr_conv_19 = arg_vals[t];
5144                 LDKUpdateFulfillHTLC arr_conv_19_conv;
5145                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
5146                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
5147                 arg_constr.data[t] = arr_conv_19_conv;
5148         }
5149         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5150         CVec_UpdateFulfillHTLCZ_free(arg_constr);
5151 }
5152
5153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5154         LDKCVec_u64Z arg_constr;
5155         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5156         if (arg_constr.datalen > 0)
5157                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
5158         else
5159                 arg_constr.data = NULL;
5160         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5161         for (size_t g = 0; g < arg_constr.datalen; g++) {
5162                 long arr_conv_6 = arg_vals[g];
5163                 arg_constr.data[g] = arr_conv_6;
5164         }
5165         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5166         CVec_u64Z_free(arg_constr);
5167 }
5168
5169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv * _env, jclass _b, jbyteArray arg) {
5170         LDKCVec_u8Z arg_ref;
5171         arg_ref.data = (*_env)->GetByteArrayElements (_env, arg, NULL);
5172         arg_ref.datalen = (*_env)->GetArrayLength (_env, arg);
5173         CVec_u8Z_free(arg_ref);
5174         (*_env)->ReleaseByteArrayElements(_env, arg, (int8_t*)arg_ref.data, 0);
5175 }
5176
5177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv * _env, jclass _b, jlong _res) {
5178         LDKTransaction _res_conv = *(LDKTransaction*)_res;
5179         FREE((void*)_res);
5180         Transaction_free(_res_conv);
5181 }
5182
5183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv * _env, jclass _b, jlong _res) {
5184         LDKTxOut _res_conv = *(LDKTxOut*)_res;
5185         FREE((void*)_res);
5186         TxOut_free(_res_conv);
5187 }
5188
5189 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
5190         LDKTransaction b_conv = *(LDKTransaction*)b;
5191         FREE((void*)b);
5192         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5193         *ret = C2Tuple_usizeTransactionZ_new(a, b_conv);
5194         return (long)ret;
5195 }
5196
5197 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv * _env, jclass _b) {
5198         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5199         *ret = CResult_NoneChannelMonitorUpdateErrZ_ok();
5200         return (long)ret;
5201 }
5202
5203 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv * _env, jclass _b) {
5204         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
5205         *ret = CResult_NoneMonitorUpdateErrorZ_ok();
5206         return (long)ret;
5207 }
5208
5209 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv * _env, jclass _b, jlong a, jbyteArray b) {
5210         LDKOutPoint a_conv;
5211         a_conv.inner = (void*)(a & (~1));
5212         a_conv.is_owned = (a & 1) || (a == 0);
5213         if (a_conv.inner != NULL)
5214                 a_conv = OutPoint_clone(&a_conv);
5215         LDKCVec_u8Z b_ref;
5216         b_ref.data = (*_env)->GetByteArrayElements (_env, b, NULL);
5217         b_ref.datalen = (*_env)->GetArrayLength (_env, b);
5218         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5219         *ret = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
5220         (*_env)->ReleaseByteArrayElements(_env, b, (int8_t*)b_ref.data, 0);
5221         return (long)ret;
5222 }
5223
5224 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlongArray b) {
5225         LDKThirtyTwoBytes a_ref;
5226         CHECK((*_env)->GetArrayLength (_env, a) == 32);
5227         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
5228         LDKCVec_TxOutZ b_constr;
5229         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
5230         if (b_constr.datalen > 0)
5231                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
5232         else
5233                 b_constr.data = NULL;
5234         long* b_vals = (*_env)->GetLongArrayElements (_env, b, NULL);
5235         for (size_t h = 0; h < b_constr.datalen; h++) {
5236                 long arr_conv_7 = b_vals[h];
5237                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
5238                 FREE((void*)arr_conv_7);
5239                 b_constr.data[h] = arr_conv_7_conv;
5240         }
5241         (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0);
5242         LDKC2Tuple_TxidCVec_TxOutZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKC2Tuple_TxidCVec_TxOutZZ");
5243         *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_constr);
5244         return (long)ret;
5245 }
5246
5247 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
5248         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
5249         *ret = C2Tuple_u64u64Z_new(a, b);
5250         return (long)ret;
5251 }
5252
5253 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jobjectArray b) {
5254         LDKSignature a_ref;
5255         CHECK((*_env)->GetArrayLength (_env, a) == 64);
5256         (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form);
5257         LDKCVec_SignatureZ b_constr;
5258         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
5259         if (b_constr.datalen > 0)
5260                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5261         else
5262                 b_constr.data = NULL;
5263         for (size_t i = 0; i < b_constr.datalen; i++) {
5264                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, b, i);
5265                 LDKSignature arr_conv_8_ref;
5266                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
5267                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
5268                 b_constr.data[i] = arr_conv_8_ref;
5269         }
5270         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5271         *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
5272         return (long)ret;
5273 }
5274
5275 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv * _env, jclass _b) {
5276         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5277         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
5278         return (long)ret;
5279 }
5280
5281 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv * _env, jclass _b) {
5282         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5283         *ret = CResult_SignatureNoneZ_err();
5284         return (long)ret;
5285 }
5286
5287 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv * _env, jclass _b) {
5288         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5289         *ret = CResult_CVec_SignatureZNoneZ_err();
5290         return (long)ret;
5291 }
5292
5293 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv * _env, jclass _b) {
5294         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5295         *ret = CResult_NoneAPIErrorZ_ok();
5296         return (long)ret;
5297 }
5298
5299 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv * _env, jclass _b) {
5300         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5301         *ret = CResult_NonePaymentSendFailureZ_ok();
5302         return (long)ret;
5303 }
5304
5305 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b, jlong c) {
5306         LDKChannelAnnouncement a_conv;
5307         a_conv.inner = (void*)(a & (~1));
5308         a_conv.is_owned = (a & 1) || (a == 0);
5309         if (a_conv.inner != NULL)
5310                 a_conv = ChannelAnnouncement_clone(&a_conv);
5311         LDKChannelUpdate b_conv;
5312         b_conv.inner = (void*)(b & (~1));
5313         b_conv.is_owned = (b & 1) || (b == 0);
5314         if (b_conv.inner != NULL)
5315                 b_conv = ChannelUpdate_clone(&b_conv);
5316         LDKChannelUpdate c_conv;
5317         c_conv.inner = (void*)(c & (~1));
5318         c_conv.is_owned = (c & 1) || (c == 0);
5319         if (c_conv.inner != NULL)
5320                 c_conv = ChannelUpdate_clone(&c_conv);
5321         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5322         *ret = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5323         return (long)ret;
5324 }
5325
5326 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b) {
5327         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5328         *ret = CResult_NonePeerHandleErrorZ_ok();
5329         return (long)ret;
5330 }
5331
5332 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1new(JNIEnv * _env, jclass _b, jlong a, jbyteArray b) {
5333         LDKHTLCOutputInCommitment a_conv;
5334         a_conv.inner = (void*)(a & (~1));
5335         a_conv.is_owned = (a & 1) || (a == 0);
5336         if (a_conv.inner != NULL)
5337                 a_conv = HTLCOutputInCommitment_clone(&a_conv);
5338         LDKSignature b_ref;
5339         CHECK((*_env)->GetArrayLength (_env, b) == 64);
5340         (*_env)->GetByteArrayRegion (_env, b, 0, 64, b_ref.compact_form);
5341         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* ret = MALLOC(sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKC2Tuple_HTLCOutputInCommitmentSignatureZ");
5342         *ret = C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a_conv, b_ref);
5343         return (long)ret;
5344 }
5345
5346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5347         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
5348         FREE((void*)this_ptr);
5349         Event_free(this_ptr_conv);
5350 }
5351
5352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5353         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
5354         FREE((void*)this_ptr);
5355         MessageSendEvent_free(this_ptr_conv);
5356 }
5357
5358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5359         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
5360         FREE((void*)this_ptr);
5361         MessageSendEventsProvider_free(this_ptr_conv);
5362 }
5363
5364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5365         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
5366         FREE((void*)this_ptr);
5367         EventsProvider_free(this_ptr_conv);
5368 }
5369
5370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5371         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
5372         FREE((void*)this_ptr);
5373         APIError_free(this_ptr_conv);
5374 }
5375
5376 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv * _env, jclass _b) {
5377         jclass ret = LDKLevel_to_java(_env, Level_max());
5378         return ret;
5379 }
5380
5381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5382         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
5383         FREE((void*)this_ptr);
5384         Logger_free(this_ptr_conv);
5385 }
5386
5387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
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_free(this_ptr_conv);
5392 }
5393
5394 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5395         LDKChannelHandshakeConfig orig_conv;
5396         orig_conv.inner = (void*)(orig & (~1));
5397         orig_conv.is_owned = (orig & 1) || (orig == 0);
5398         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_clone(&orig_conv);
5399         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5400 }
5401
5402 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
5403         LDKChannelHandshakeConfig this_ptr_conv;
5404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5405         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5406         jint ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
5407         return ret_val;
5408 }
5409
5410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5411         LDKChannelHandshakeConfig this_ptr_conv;
5412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5413         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5414         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
5415 }
5416
5417 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
5418         LDKChannelHandshakeConfig this_ptr_conv;
5419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5420         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5421         jshort ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
5422         return ret_val;
5423 }
5424
5425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5426         LDKChannelHandshakeConfig this_ptr_conv;
5427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5428         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5429         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
5430 }
5431
5432 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5433         LDKChannelHandshakeConfig this_ptr_conv;
5434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5435         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5436         jlong ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
5437         return ret_val;
5438 }
5439
5440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5441         LDKChannelHandshakeConfig this_ptr_conv;
5442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5443         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5444         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
5445 }
5446
5447 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) {
5448         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
5449         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5450 }
5451
5452 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv * _env, jclass _b) {
5453         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_default();
5454         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5455 }
5456
5457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
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_free(this_ptr_conv);
5462 }
5463
5464 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5465         LDKChannelHandshakeLimits orig_conv;
5466         orig_conv.inner = (void*)(orig & (~1));
5467         orig_conv.is_owned = (orig & 1) || (orig == 0);
5468         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_clone(&orig_conv);
5469         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5470 }
5471
5472 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jlong ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
5477         return ret_val;
5478 }
5479
5480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5481         LDKChannelHandshakeLimits this_ptr_conv;
5482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5483         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5484         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
5485 }
5486
5487 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jlong ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
5492         return ret_val;
5493 }
5494
5495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5496         LDKChannelHandshakeLimits this_ptr_conv;
5497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5498         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5499         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
5500 }
5501
5502 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jlong ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
5507         return ret_val;
5508 }
5509
5510 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) {
5511         LDKChannelHandshakeLimits this_ptr_conv;
5512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5513         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5514         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
5515 }
5516
5517 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jlong ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
5522         return ret_val;
5523 }
5524
5525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5526         LDKChannelHandshakeLimits this_ptr_conv;
5527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5528         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5529         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
5530 }
5531
5532 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jshort ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
5537         return ret_val;
5538 }
5539
5540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5541         LDKChannelHandshakeLimits this_ptr_conv;
5542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5543         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5544         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
5545 }
5546
5547 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jlong ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
5552         return ret_val;
5553 }
5554
5555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5556         LDKChannelHandshakeLimits this_ptr_conv;
5557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5558         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5559         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
5560 }
5561
5562 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jlong ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
5567         return ret_val;
5568 }
5569
5570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5571         LDKChannelHandshakeLimits this_ptr_conv;
5572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5573         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5574         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
5575 }
5576
5577 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
5578         LDKChannelHandshakeLimits this_ptr_conv;
5579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5580         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5581         jint ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
5582         return ret_val;
5583 }
5584
5585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5586         LDKChannelHandshakeLimits this_ptr_conv;
5587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5588         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5589         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
5590 }
5591
5592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr) {
5593         LDKChannelHandshakeLimits this_ptr_conv;
5594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5595         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5596         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
5597         return ret_val;
5598 }
5599
5600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5601         LDKChannelHandshakeLimits this_ptr_conv;
5602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5603         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5604         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
5605 }
5606
5607 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
5608         LDKChannelHandshakeLimits this_ptr_conv;
5609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5610         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5611         jshort ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
5612         return ret_val;
5613 }
5614
5615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5616         LDKChannelHandshakeLimits this_ptr_conv;
5617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5618         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5619         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
5620 }
5621
5622 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) {
5623         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);
5624         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5625 }
5626
5627 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv * _env, jclass _b) {
5628         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_default();
5629         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5630 }
5631
5632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
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_free(this_ptr_conv);
5637 }
5638
5639 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5640         LDKChannelConfig orig_conv;
5641         orig_conv.inner = (void*)(orig & (~1));
5642         orig_conv.is_owned = (orig & 1) || (orig == 0);
5643         LDKChannelConfig ret = ChannelConfig_clone(&orig_conv);
5644         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5645 }
5646
5647 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
5648         LDKChannelConfig this_ptr_conv;
5649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5650         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5651         jint ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
5652         return ret_val;
5653 }
5654
5655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5656         LDKChannelConfig this_ptr_conv;
5657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5658         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5659         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
5660 }
5661
5662 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr) {
5663         LDKChannelConfig this_ptr_conv;
5664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5665         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5666         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
5667         return ret_val;
5668 }
5669
5670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5671         LDKChannelConfig this_ptr_conv;
5672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5673         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5674         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
5675 }
5676
5677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
5678         LDKChannelConfig this_ptr_conv;
5679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5680         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5681         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
5682         return ret_val;
5683 }
5684
5685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5686         LDKChannelConfig this_ptr_conv;
5687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5688         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5689         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
5690 }
5691
5692 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) {
5693         LDKChannelConfig ret = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
5694         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5695 }
5696
5697 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv * _env, jclass _b) {
5698         LDKChannelConfig ret = ChannelConfig_default();
5699         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5700 }
5701
5702 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv * _env, jclass _b, jlong obj) {
5703         LDKChannelConfig obj_conv;
5704         obj_conv.inner = (void*)(obj & (~1));
5705         obj_conv.is_owned = (obj & 1) || (obj == 0);
5706         LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
5707         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
5708         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
5709         return arg_arr;
5710 }
5711
5712 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
5713         LDKu8slice ser_ref;
5714         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
5715         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
5716         LDKChannelConfig ret = ChannelConfig_read(ser_ref);
5717         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
5718         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5719 }
5720
5721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5722         LDKUserConfig this_ptr_conv;
5723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5724         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5725         UserConfig_free(this_ptr_conv);
5726 }
5727
5728 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5729         LDKUserConfig orig_conv;
5730         orig_conv.inner = (void*)(orig & (~1));
5731         orig_conv.is_owned = (orig & 1) || (orig == 0);
5732         LDKUserConfig ret = UserConfig_clone(&orig_conv);
5733         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5734 }
5735
5736 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
5737         LDKUserConfig this_ptr_conv;
5738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5739         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5740         LDKChannelHandshakeConfig ret = UserConfig_get_own_channel_config(&this_ptr_conv);
5741         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5742 }
5743
5744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5745         LDKUserConfig this_ptr_conv;
5746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5747         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5748         LDKChannelHandshakeConfig val_conv;
5749         val_conv.inner = (void*)(val & (~1));
5750         val_conv.is_owned = (val & 1) || (val == 0);
5751         if (val_conv.inner != NULL)
5752                 val_conv = ChannelHandshakeConfig_clone(&val_conv);
5753         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
5754 }
5755
5756 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr) {
5757         LDKUserConfig this_ptr_conv;
5758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5759         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5760         LDKChannelHandshakeLimits ret = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
5761         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5762 }
5763
5764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5765         LDKUserConfig this_ptr_conv;
5766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5767         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5768         LDKChannelHandshakeLimits val_conv;
5769         val_conv.inner = (void*)(val & (~1));
5770         val_conv.is_owned = (val & 1) || (val == 0);
5771         if (val_conv.inner != NULL)
5772                 val_conv = ChannelHandshakeLimits_clone(&val_conv);
5773         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
5774 }
5775
5776 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr) {
5777         LDKUserConfig this_ptr_conv;
5778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5779         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5780         LDKChannelConfig ret = UserConfig_get_channel_options(&this_ptr_conv);
5781         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5782 }
5783
5784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5785         LDKUserConfig this_ptr_conv;
5786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5787         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5788         LDKChannelConfig val_conv;
5789         val_conv.inner = (void*)(val & (~1));
5790         val_conv.is_owned = (val & 1) || (val == 0);
5791         if (val_conv.inner != NULL)
5792                 val_conv = ChannelConfig_clone(&val_conv);
5793         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
5794 }
5795
5796 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) {
5797         LDKChannelHandshakeConfig own_channel_config_arg_conv;
5798         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
5799         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
5800         if (own_channel_config_arg_conv.inner != NULL)
5801                 own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
5802         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
5803         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
5804         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
5805         if (peer_channel_config_limits_arg_conv.inner != NULL)
5806                 peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
5807         LDKChannelConfig channel_options_arg_conv;
5808         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
5809         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
5810         if (channel_options_arg_conv.inner != NULL)
5811                 channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
5812         LDKUserConfig ret = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
5813         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5814 }
5815
5816 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv * _env, jclass _b) {
5817         LDKUserConfig ret = UserConfig_default();
5818         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5819 }
5820
5821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5822         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
5823         FREE((void*)this_ptr);
5824         Access_free(this_ptr_conv);
5825 }
5826
5827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5828         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
5829         FREE((void*)this_ptr);
5830         Watch_free(this_ptr_conv);
5831 }
5832
5833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5834         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
5835         FREE((void*)this_ptr);
5836         Filter_free(this_ptr_conv);
5837 }
5838
5839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5840         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
5841         FREE((void*)this_ptr);
5842         BroadcasterInterface_free(this_ptr_conv);
5843 }
5844
5845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5846         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
5847         FREE((void*)this_ptr);
5848         FeeEstimator_free(this_ptr_conv);
5849 }
5850
5851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5852         LDKChainMonitor this_ptr_conv;
5853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5854         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5855         ChainMonitor_free(this_ptr_conv);
5856 }
5857
5858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height) {
5859         LDKChainMonitor this_arg_conv;
5860         this_arg_conv.inner = (void*)(this_arg & (~1));
5861         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5862         unsigned char header_arr[80];
5863         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5864         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5865         unsigned char (*header_ref)[80] = &header_arr;
5866         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5867         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
5868         if (txdata_constr.datalen > 0)
5869                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5870         else
5871                 txdata_constr.data = NULL;
5872         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
5873         for (size_t d = 0; d < txdata_constr.datalen; d++) {
5874                 long arr_conv_29 = txdata_vals[d];
5875                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
5876                 FREE((void*)arr_conv_29);
5877                 txdata_constr.data[d] = arr_conv_29_conv;
5878         }
5879         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
5880         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
5881 }
5882
5883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint disconnected_height) {
5884         LDKChainMonitor this_arg_conv;
5885         this_arg_conv.inner = (void*)(this_arg & (~1));
5886         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5887         unsigned char header_arr[80];
5888         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5889         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5890         unsigned char (*header_ref)[80] = &header_arr;
5891         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
5892 }
5893
5894 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv * _env, jclass _b, jlong chain_source, jlong broadcaster, jlong logger, jlong feeest) {
5895         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
5896         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5897         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5898                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5899                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5900         }
5901         LDKLogger logger_conv = *(LDKLogger*)logger;
5902         if (logger_conv.free == LDKLogger_JCalls_free) {
5903                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5904                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5905         }
5906         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
5907         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
5908                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5909                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
5910         }
5911         LDKChainMonitor ret = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv);
5912         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5913 }
5914
5915 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv * _env, jclass _b, jlong this_arg) {
5916         LDKChainMonitor this_arg_conv;
5917         this_arg_conv.inner = (void*)(this_arg & (~1));
5918         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5919         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
5920         *ret = ChainMonitor_as_Watch(&this_arg_conv);
5921         return (long)ret;
5922 }
5923
5924 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5925         LDKChainMonitor this_arg_conv;
5926         this_arg_conv.inner = (void*)(this_arg & (~1));
5927         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5928         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5929         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
5930         return (long)ret;
5931 }
5932
5933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5934         LDKChannelMonitorUpdate this_ptr_conv;
5935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5936         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5937         ChannelMonitorUpdate_free(this_ptr_conv);
5938 }
5939
5940 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5941         LDKChannelMonitorUpdate orig_conv;
5942         orig_conv.inner = (void*)(orig & (~1));
5943         orig_conv.is_owned = (orig & 1) || (orig == 0);
5944         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_clone(&orig_conv);
5945         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5946 }
5947
5948 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5949         LDKChannelMonitorUpdate this_ptr_conv;
5950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5951         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5952         jlong ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
5953         return ret_val;
5954 }
5955
5956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5957         LDKChannelMonitorUpdate 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         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
5961 }
5962
5963 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5964         LDKChannelMonitorUpdate obj_conv;
5965         obj_conv.inner = (void*)(obj & (~1));
5966         obj_conv.is_owned = (obj & 1) || (obj == 0);
5967         LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
5968         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
5969         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
5970         return arg_arr;
5971 }
5972
5973 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
5974         LDKu8slice ser_ref;
5975         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
5976         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
5977         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_read(ser_ref);
5978         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
5979         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5980 }
5981
5982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5983         LDKMonitorUpdateError this_ptr_conv;
5984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5985         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5986         MonitorUpdateError_free(this_ptr_conv);
5987 }
5988
5989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5990         LDKMonitorEvent this_ptr_conv;
5991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5992         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5993         MonitorEvent_free(this_ptr_conv);
5994 }
5995
5996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5997         LDKHTLCUpdate this_ptr_conv;
5998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5999         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6000         HTLCUpdate_free(this_ptr_conv);
6001 }
6002
6003 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6004         LDKHTLCUpdate orig_conv;
6005         orig_conv.inner = (void*)(orig & (~1));
6006         orig_conv.is_owned = (orig & 1) || (orig == 0);
6007         LDKHTLCUpdate ret = HTLCUpdate_clone(&orig_conv);
6008         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6009 }
6010
6011 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
6012         LDKHTLCUpdate obj_conv;
6013         obj_conv.inner = (void*)(obj & (~1));
6014         obj_conv.is_owned = (obj & 1) || (obj == 0);
6015         LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
6016         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
6017         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
6018         return arg_arr;
6019 }
6020
6021 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
6022         LDKu8slice ser_ref;
6023         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
6024         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
6025         LDKHTLCUpdate ret = HTLCUpdate_read(ser_ref);
6026         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
6027         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6028 }
6029
6030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6031         LDKChannelMonitor this_ptr_conv;
6032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6033         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6034         ChannelMonitor_free(this_ptr_conv);
6035 }
6036
6037 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv * _env, jclass _b, jlong this_arg, jlong updates, jlong broadcaster, jlong logger) {
6038         LDKChannelMonitor this_arg_conv;
6039         this_arg_conv.inner = (void*)(this_arg & (~1));
6040         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6041         LDKChannelMonitorUpdate updates_conv;
6042         updates_conv.inner = (void*)(updates & (~1));
6043         updates_conv.is_owned = (updates & 1) || (updates == 0);
6044         if (updates_conv.inner != NULL)
6045                 updates_conv = ChannelMonitorUpdate_clone(&updates_conv);
6046         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
6047         LDKLogger* logger_conv = (LDKLogger*)logger;
6048         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6049         *ret = ChannelMonitor_update_monitor(&this_arg_conv, updates_conv, broadcaster_conv, logger_conv);
6050         return (long)ret;
6051 }
6052
6053 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6054         LDKChannelMonitor this_arg_conv;
6055         this_arg_conv.inner = (void*)(this_arg & (~1));
6056         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6057         jlong ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
6058         return ret_val;
6059 }
6060
6061 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv * _env, jclass _b, jlong this_arg) {
6062         LDKChannelMonitor this_arg_conv;
6063         this_arg_conv.inner = (void*)(this_arg & (~1));
6064         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6065         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6066         *ret = ChannelMonitor_get_funding_txo(&this_arg_conv);
6067         return (long)ret;
6068 }
6069
6070 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
6071         LDKChannelMonitor this_arg_conv;
6072         this_arg_conv.inner = (void*)(this_arg & (~1));
6073         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6074         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
6075         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6076         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6077         for (size_t o = 0; o < ret_var.datalen; o++) {
6078                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
6079                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6080                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6081                 long arr_conv_14_ref;
6082                 if (arr_conv_14_var.is_owned) {
6083                         arr_conv_14_ref = (long)arr_conv_14_var.inner | 1;
6084                 } else {
6085                         arr_conv_14_ref = (long)&arr_conv_14_var;
6086                 }
6087                 ret_arr_ptr[o] = arr_conv_14_ref;
6088         }
6089         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6090         FREE(ret_var.data);
6091         return ret_arr;
6092 }
6093
6094 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
6095         LDKChannelMonitor this_arg_conv;
6096         this_arg_conv.inner = (void*)(this_arg & (~1));
6097         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6098         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
6099         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6100         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6101         for (size_t h = 0; h < ret_var.datalen; h++) {
6102                 long arr_conv_7_ref = (long)&ret_var.data[h];
6103                 ret_arr_ptr[h] = arr_conv_7_ref;
6104         }
6105         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6106         return ret_arr;
6107 }
6108
6109 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) {
6110         LDKChannelMonitor this_arg_conv;
6111         this_arg_conv.inner = (void*)(this_arg & (~1));
6112         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6113         LDKLogger* logger_conv = (LDKLogger*)logger;
6114         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
6115         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6116         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6117         for (size_t n = 0; n < ret_var.datalen; n++) {
6118                 long arr_conv_13_ref = (long)&ret_var.data[n];
6119                 ret_arr_ptr[n] = arr_conv_13_ref;
6120         }
6121         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6122         return ret_arr;
6123 }
6124
6125 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) {
6126         LDKChannelMonitor this_arg_conv;
6127         this_arg_conv.inner = (void*)(this_arg & (~1));
6128         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6129         unsigned char header_arr[80];
6130         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6131         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6132         unsigned char (*header_ref)[80] = &header_arr;
6133         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6134         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
6135         if (txdata_constr.datalen > 0)
6136                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6137         else
6138                 txdata_constr.data = NULL;
6139         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
6140         for (size_t d = 0; d < txdata_constr.datalen; d++) {
6141                 long arr_conv_29 = txdata_vals[d];
6142                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
6143                 FREE((void*)arr_conv_29);
6144                 txdata_constr.data[d] = arr_conv_29_conv;
6145         }
6146         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
6147         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6148         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6149                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6150                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
6151         }
6152         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6153         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6154                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6155                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6156         }
6157         LDKLogger logger_conv = *(LDKLogger*)logger;
6158         if (logger_conv.free == LDKLogger_JCalls_free) {
6159                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6160                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6161         }
6162         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
6163         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6164         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6165         for (size_t b = 0; b < ret_var.datalen; b++) {
6166                 long arr_conv_27_ref = (long)&ret_var.data[b];
6167                 ret_arr_ptr[b] = arr_conv_27_ref;
6168         }
6169         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6170         return ret_arr;
6171 }
6172
6173 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) {
6174         LDKChannelMonitor this_arg_conv;
6175         this_arg_conv.inner = (void*)(this_arg & (~1));
6176         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6177         unsigned char header_arr[80];
6178         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6179         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6180         unsigned char (*header_ref)[80] = &header_arr;
6181         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6182         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6183                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6184                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
6185         }
6186         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6187         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6188                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6189                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6190         }
6191         LDKLogger logger_conv = *(LDKLogger*)logger;
6192         if (logger_conv.free == LDKLogger_JCalls_free) {
6193                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6194                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6195         }
6196         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
6197 }
6198
6199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6200         LDKOutPoint this_ptr_conv;
6201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6202         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6203         OutPoint_free(this_ptr_conv);
6204 }
6205
6206 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6207         LDKOutPoint orig_conv;
6208         orig_conv.inner = (void*)(orig & (~1));
6209         orig_conv.is_owned = (orig & 1) || (orig == 0);
6210         LDKOutPoint ret = OutPoint_clone(&orig_conv);
6211         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6212 }
6213
6214 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
6215         LDKOutPoint this_ptr_conv;
6216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6217         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6218         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6219         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
6220         return ret_arr;
6221 }
6222
6223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6224         LDKOutPoint this_ptr_conv;
6225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6226         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6227         LDKThirtyTwoBytes val_ref;
6228         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6229         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6230         OutPoint_set_txid(&this_ptr_conv, val_ref);
6231 }
6232
6233 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
6234         LDKOutPoint this_ptr_conv;
6235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6236         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6237         jshort ret_val = OutPoint_get_index(&this_ptr_conv);
6238         return ret_val;
6239 }
6240
6241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6242         LDKOutPoint this_ptr_conv;
6243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6244         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6245         OutPoint_set_index(&this_ptr_conv, val);
6246 }
6247
6248 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv * _env, jclass _b, jbyteArray txid_arg, jshort index_arg) {
6249         LDKThirtyTwoBytes txid_arg_ref;
6250         CHECK((*_env)->GetArrayLength (_env, txid_arg) == 32);
6251         (*_env)->GetByteArrayRegion (_env, txid_arg, 0, 32, txid_arg_ref.data);
6252         LDKOutPoint ret = OutPoint_new(txid_arg_ref, index_arg);
6253         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6254 }
6255
6256 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6257         LDKOutPoint this_arg_conv;
6258         this_arg_conv.inner = (void*)(this_arg & (~1));
6259         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6260         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
6261         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
6262         return arg_arr;
6263 }
6264
6265 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv * _env, jclass _b, jlong obj) {
6266         LDKOutPoint obj_conv;
6267         obj_conv.inner = (void*)(obj & (~1));
6268         obj_conv.is_owned = (obj & 1) || (obj == 0);
6269         LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
6270         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
6271         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
6272         return arg_arr;
6273 }
6274
6275 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
6276         LDKu8slice ser_ref;
6277         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
6278         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
6279         LDKOutPoint ret = OutPoint_read(ser_ref);
6280         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
6281         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6282 }
6283
6284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6285         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
6286         FREE((void*)this_ptr);
6287         SpendableOutputDescriptor_free(this_ptr_conv);
6288 }
6289
6290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6291         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
6292         FREE((void*)this_ptr);
6293         ChannelKeys_free(this_ptr_conv);
6294 }
6295
6296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6297         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
6298         FREE((void*)this_ptr);
6299         KeysInterface_free(this_ptr_conv);
6300 }
6301
6302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6303         LDKInMemoryChannelKeys this_ptr_conv;
6304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6305         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6306         InMemoryChannelKeys_free(this_ptr_conv);
6307 }
6308
6309 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6310         LDKInMemoryChannelKeys orig_conv;
6311         orig_conv.inner = (void*)(orig & (~1));
6312         orig_conv.is_owned = (orig & 1) || (orig == 0);
6313         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_clone(&orig_conv);
6314         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6315 }
6316
6317 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6318         LDKInMemoryChannelKeys this_ptr_conv;
6319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6320         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6321         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6322         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv));
6323         return ret_arr;
6324 }
6325
6326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6327         LDKInMemoryChannelKeys this_ptr_conv;
6328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6329         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6330         LDKSecretKey val_ref;
6331         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6332         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6333         InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
6334 }
6335
6336 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6337         LDKInMemoryChannelKeys this_ptr_conv;
6338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6339         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6340         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6341         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv));
6342         return ret_arr;
6343 }
6344
6345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6346         LDKInMemoryChannelKeys this_ptr_conv;
6347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6348         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6349         LDKSecretKey val_ref;
6350         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6351         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6352         InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
6353 }
6354
6355 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6356         LDKInMemoryChannelKeys this_ptr_conv;
6357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6358         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6359         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6360         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv));
6361         return ret_arr;
6362 }
6363
6364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6365         LDKInMemoryChannelKeys this_ptr_conv;
6366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6367         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6368         LDKSecretKey val_ref;
6369         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6370         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6371         InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
6372 }
6373
6374 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6375         LDKInMemoryChannelKeys this_ptr_conv;
6376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6377         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6378         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6379         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv));
6380         return ret_arr;
6381 }
6382
6383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6384         LDKInMemoryChannelKeys this_ptr_conv;
6385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6386         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6387         LDKSecretKey val_ref;
6388         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6389         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6390         InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
6391 }
6392
6393 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6394         LDKInMemoryChannelKeys this_ptr_conv;
6395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6396         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6397         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6398         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv));
6399         return ret_arr;
6400 }
6401
6402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6403         LDKInMemoryChannelKeys this_ptr_conv;
6404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6405         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6406         LDKSecretKey val_ref;
6407         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6408         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6409         InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
6410 }
6411
6412 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr) {
6413         LDKInMemoryChannelKeys this_ptr_conv;
6414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6415         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6416         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6417         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv));
6418         return ret_arr;
6419 }
6420
6421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6422         LDKInMemoryChannelKeys this_ptr_conv;
6423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6424         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6425         LDKThirtyTwoBytes val_ref;
6426         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6427         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6428         InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
6429 }
6430
6431 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) {
6432         LDKSecretKey funding_key_ref;
6433         CHECK((*_env)->GetArrayLength (_env, funding_key) == 32);
6434         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_ref.bytes);
6435         LDKSecretKey revocation_base_key_ref;
6436         CHECK((*_env)->GetArrayLength (_env, revocation_base_key) == 32);
6437         (*_env)->GetByteArrayRegion (_env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
6438         LDKSecretKey payment_key_ref;
6439         CHECK((*_env)->GetArrayLength (_env, payment_key) == 32);
6440         (*_env)->GetByteArrayRegion (_env, payment_key, 0, 32, payment_key_ref.bytes);
6441         LDKSecretKey delayed_payment_base_key_ref;
6442         CHECK((*_env)->GetArrayLength (_env, delayed_payment_base_key) == 32);
6443         (*_env)->GetByteArrayRegion (_env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
6444         LDKSecretKey htlc_base_key_ref;
6445         CHECK((*_env)->GetArrayLength (_env, htlc_base_key) == 32);
6446         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
6447         LDKThirtyTwoBytes commitment_seed_ref;
6448         CHECK((*_env)->GetArrayLength (_env, commitment_seed) == 32);
6449         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_ref.data);
6450         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
6451         FREE((void*)key_derivation_params);
6452         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);
6453         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6454 }
6455
6456 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
6457         LDKInMemoryChannelKeys this_arg_conv;
6458         this_arg_conv.inner = (void*)(this_arg & (~1));
6459         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6460         LDKChannelPublicKeys ret = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
6461         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6462 }
6463
6464 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
6465         LDKInMemoryChannelKeys this_arg_conv;
6466         this_arg_conv.inner = (void*)(this_arg & (~1));
6467         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6468         jshort ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
6469         return ret_val;
6470 }
6471
6472 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1holder_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
6473         LDKInMemoryChannelKeys this_arg_conv;
6474         this_arg_conv.inner = (void*)(this_arg & (~1));
6475         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6476         jshort ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
6477         return ret_val;
6478 }
6479
6480 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1as_1ChannelKeys(JNIEnv * _env, jclass _b, jlong this_arg) {
6481         LDKInMemoryChannelKeys this_arg_conv;
6482         this_arg_conv.inner = (void*)(this_arg & (~1));
6483         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6484         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
6485         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
6486         return (long)ret;
6487 }
6488
6489 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
6490         LDKInMemoryChannelKeys obj_conv;
6491         obj_conv.inner = (void*)(obj & (~1));
6492         obj_conv.is_owned = (obj & 1) || (obj == 0);
6493         LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
6494         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
6495         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
6496         return arg_arr;
6497 }
6498
6499 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
6500         LDKu8slice ser_ref;
6501         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
6502         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
6503         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_read(ser_ref);
6504         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
6505         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6506 }
6507
6508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6509         LDKKeysManager this_ptr_conv;
6510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6511         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6512         KeysManager_free(this_ptr_conv);
6513 }
6514
6515 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) {
6516         unsigned char seed_arr[32];
6517         CHECK((*_env)->GetArrayLength (_env, seed) == 32);
6518         (*_env)->GetByteArrayRegion (_env, seed, 0, 32, seed_arr);
6519         unsigned char (*seed_ref)[32] = &seed_arr;
6520         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
6521         LDKKeysManager ret = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
6522         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6523 }
6524
6525 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) {
6526         LDKKeysManager this_arg_conv;
6527         this_arg_conv.inner = (void*)(this_arg & (~1));
6528         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6529         LDKInMemoryChannelKeys ret = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
6530         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6531 }
6532
6533 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv * _env, jclass _b, jlong this_arg) {
6534         LDKKeysManager this_arg_conv;
6535         this_arg_conv.inner = (void*)(this_arg & (~1));
6536         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6537         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6538         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
6539         return (long)ret;
6540 }
6541
6542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6543         LDKChannelManager this_ptr_conv;
6544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6545         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6546         ChannelManager_free(this_ptr_conv);
6547 }
6548
6549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6550         LDKChannelDetails this_ptr_conv;
6551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6552         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6553         ChannelDetails_free(this_ptr_conv);
6554 }
6555
6556 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6557         LDKChannelDetails orig_conv;
6558         orig_conv.inner = (void*)(orig & (~1));
6559         orig_conv.is_owned = (orig & 1) || (orig == 0);
6560         LDKChannelDetails ret = ChannelDetails_clone(&orig_conv);
6561         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6562 }
6563
6564 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6565         LDKChannelDetails this_ptr_conv;
6566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6567         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6568         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6569         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
6570         return ret_arr;
6571 }
6572
6573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6574         LDKChannelDetails this_ptr_conv;
6575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6576         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6577         LDKThirtyTwoBytes val_ref;
6578         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6579         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6580         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
6581 }
6582
6583 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6584         LDKChannelDetails this_ptr_conv;
6585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6586         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6587         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6588         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
6589         return arg_arr;
6590 }
6591
6592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6593         LDKChannelDetails this_ptr_conv;
6594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6595         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6596         LDKPublicKey val_ref;
6597         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6598         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6599         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
6600 }
6601
6602 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
6603         LDKChannelDetails this_ptr_conv;
6604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6605         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6606         LDKInitFeatures ret = ChannelDetails_get_counterparty_features(&this_ptr_conv);
6607         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6608 }
6609
6610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6611         LDKChannelDetails this_ptr_conv;
6612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6613         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6614         LDKInitFeatures val_conv;
6615         val_conv.inner = (void*)(val & (~1));
6616         val_conv.is_owned = (val & 1) || (val == 0);
6617         // Warning: we may need a move here but can't clone!
6618         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
6619 }
6620
6621 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6622         LDKChannelDetails this_ptr_conv;
6623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6624         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6625         jlong ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
6626         return ret_val;
6627 }
6628
6629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6630         LDKChannelDetails this_ptr_conv;
6631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6632         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6633         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
6634 }
6635
6636 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6637         LDKChannelDetails this_ptr_conv;
6638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6639         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6640         jlong ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
6641         return ret_val;
6642 }
6643
6644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6645         LDKChannelDetails this_ptr_conv;
6646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6647         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6648         ChannelDetails_set_user_id(&this_ptr_conv, val);
6649 }
6650
6651 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6652         LDKChannelDetails this_ptr_conv;
6653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6654         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6655         jlong ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
6656         return ret_val;
6657 }
6658
6659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6660         LDKChannelDetails this_ptr_conv;
6661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6662         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6663         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
6664 }
6665
6666 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6667         LDKChannelDetails this_ptr_conv;
6668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6669         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6670         jlong ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
6671         return ret_val;
6672 }
6673
6674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6675         LDKChannelDetails this_ptr_conv;
6676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6677         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6678         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
6679 }
6680
6681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr) {
6682         LDKChannelDetails this_ptr_conv;
6683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6684         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6685         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
6686         return ret_val;
6687 }
6688
6689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
6690         LDKChannelDetails this_ptr_conv;
6691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6692         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6693         ChannelDetails_set_is_live(&this_ptr_conv, val);
6694 }
6695
6696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6697         LDKPaymentSendFailure this_ptr_conv;
6698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6699         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6700         PaymentSendFailure_free(this_ptr_conv);
6701 }
6702
6703 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) {
6704         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
6705         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
6706         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
6707                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6708                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
6709         }
6710         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
6711         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
6712                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6713                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
6714         }
6715         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
6716         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6717                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6718                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
6719         }
6720         LDKLogger logger_conv = *(LDKLogger*)logger;
6721         if (logger_conv.free == LDKLogger_JCalls_free) {
6722                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6723                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6724         }
6725         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
6726         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
6727                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6728                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
6729         }
6730         LDKUserConfig config_conv;
6731         config_conv.inner = (void*)(config & (~1));
6732         config_conv.is_owned = (config & 1) || (config == 0);
6733         if (config_conv.inner != NULL)
6734                 config_conv = UserConfig_clone(&config_conv);
6735         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);
6736         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6737 }
6738
6739 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) {
6740         LDKChannelManager this_arg_conv;
6741         this_arg_conv.inner = (void*)(this_arg & (~1));
6742         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6743         LDKPublicKey their_network_key_ref;
6744         CHECK((*_env)->GetArrayLength (_env, their_network_key) == 33);
6745         (*_env)->GetByteArrayRegion (_env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
6746         LDKUserConfig override_config_conv;
6747         override_config_conv.inner = (void*)(override_config & (~1));
6748         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
6749         if (override_config_conv.inner != NULL)
6750                 override_config_conv = UserConfig_clone(&override_config_conv);
6751         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6752         *ret = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
6753         return (long)ret;
6754 }
6755
6756 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6757         LDKChannelManager this_arg_conv;
6758         this_arg_conv.inner = (void*)(this_arg & (~1));
6759         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6760         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
6761         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6762         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6763         for (size_t q = 0; q < ret_var.datalen; q++) {
6764                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
6765                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6766                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6767                 long arr_conv_16_ref;
6768                 if (arr_conv_16_var.is_owned) {
6769                         arr_conv_16_ref = (long)arr_conv_16_var.inner | 1;
6770                 } else {
6771                         arr_conv_16_ref = (long)&arr_conv_16_var;
6772                 }
6773                 ret_arr_ptr[q] = arr_conv_16_ref;
6774         }
6775         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6776         FREE(ret_var.data);
6777         return ret_arr;
6778 }
6779
6780 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6781         LDKChannelManager this_arg_conv;
6782         this_arg_conv.inner = (void*)(this_arg & (~1));
6783         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6784         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
6785         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6786         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6787         for (size_t q = 0; q < ret_var.datalen; q++) {
6788                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
6789                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6790                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6791                 long arr_conv_16_ref;
6792                 if (arr_conv_16_var.is_owned) {
6793                         arr_conv_16_ref = (long)arr_conv_16_var.inner | 1;
6794                 } else {
6795                         arr_conv_16_ref = (long)&arr_conv_16_var;
6796                 }
6797                 ret_arr_ptr[q] = arr_conv_16_ref;
6798         }
6799         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6800         FREE(ret_var.data);
6801         return ret_arr;
6802 }
6803
6804 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
6805         LDKChannelManager this_arg_conv;
6806         this_arg_conv.inner = (void*)(this_arg & (~1));
6807         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6808         unsigned char channel_id_arr[32];
6809         CHECK((*_env)->GetArrayLength (_env, channel_id) == 32);
6810         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
6811         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6812         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6813         *ret = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
6814         return (long)ret;
6815 }
6816
6817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
6818         LDKChannelManager this_arg_conv;
6819         this_arg_conv.inner = (void*)(this_arg & (~1));
6820         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6821         unsigned char channel_id_arr[32];
6822         CHECK((*_env)->GetArrayLength (_env, channel_id) == 32);
6823         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
6824         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6825         ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
6826 }
6827
6828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6829         LDKChannelManager this_arg_conv;
6830         this_arg_conv.inner = (void*)(this_arg & (~1));
6831         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6832         ChannelManager_force_close_all_channels(&this_arg_conv);
6833 }
6834
6835 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) {
6836         LDKChannelManager this_arg_conv;
6837         this_arg_conv.inner = (void*)(this_arg & (~1));
6838         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6839         LDKRoute route_conv;
6840         route_conv.inner = (void*)(route & (~1));
6841         route_conv.is_owned = (route & 1) || (route == 0);
6842         LDKThirtyTwoBytes payment_hash_ref;
6843         CHECK((*_env)->GetArrayLength (_env, payment_hash) == 32);
6844         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_ref.data);
6845         LDKThirtyTwoBytes payment_secret_ref;
6846         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6847         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6848         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
6849         *ret = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
6850         return (long)ret;
6851 }
6852
6853 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) {
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         unsigned char temporary_channel_id_arr[32];
6858         CHECK((*_env)->GetArrayLength (_env, temporary_channel_id) == 32);
6859         (*_env)->GetByteArrayRegion (_env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
6860         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
6861         LDKOutPoint funding_txo_conv;
6862         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6863         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6864         if (funding_txo_conv.inner != NULL)
6865                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6866         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
6867 }
6868
6869 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) {
6870         LDKChannelManager this_arg_conv;
6871         this_arg_conv.inner = (void*)(this_arg & (~1));
6872         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6873         LDKThreeBytes rgb_ref;
6874         CHECK((*_env)->GetArrayLength (_env, rgb) == 3);
6875         (*_env)->GetByteArrayRegion (_env, rgb, 0, 3, rgb_ref.data);
6876         LDKThirtyTwoBytes alias_ref;
6877         CHECK((*_env)->GetArrayLength (_env, alias) == 32);
6878         (*_env)->GetByteArrayRegion (_env, alias, 0, 32, alias_ref.data);
6879         LDKCVec_NetAddressZ addresses_constr;
6880         addresses_constr.datalen = (*_env)->GetArrayLength (_env, addresses);
6881         if (addresses_constr.datalen > 0)
6882                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
6883         else
6884                 addresses_constr.data = NULL;
6885         long* addresses_vals = (*_env)->GetLongArrayElements (_env, addresses, NULL);
6886         for (size_t m = 0; m < addresses_constr.datalen; m++) {
6887                 long arr_conv_12 = addresses_vals[m];
6888                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
6889                 FREE((void*)arr_conv_12);
6890                 addresses_constr.data[m] = arr_conv_12_conv;
6891         }
6892         (*_env)->ReleaseLongArrayElements (_env, addresses, addresses_vals, 0);
6893         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
6894 }
6895
6896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv * _env, jclass _b, jlong this_arg) {
6897         LDKChannelManager this_arg_conv;
6898         this_arg_conv.inner = (void*)(this_arg & (~1));
6899         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6900         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
6901 }
6902
6903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv * _env, jclass _b, jlong this_arg) {
6904         LDKChannelManager this_arg_conv;
6905         this_arg_conv.inner = (void*)(this_arg & (~1));
6906         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6907         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
6908 }
6909
6910 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) {
6911         LDKChannelManager this_arg_conv;
6912         this_arg_conv.inner = (void*)(this_arg & (~1));
6913         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6914         unsigned char payment_hash_arr[32];
6915         CHECK((*_env)->GetArrayLength (_env, payment_hash) == 32);
6916         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_arr);
6917         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
6918         LDKThirtyTwoBytes payment_secret_ref;
6919         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6920         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6921         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
6922         return ret_val;
6923 }
6924
6925 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) {
6926         LDKChannelManager this_arg_conv;
6927         this_arg_conv.inner = (void*)(this_arg & (~1));
6928         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6929         LDKThirtyTwoBytes payment_preimage_ref;
6930         CHECK((*_env)->GetArrayLength (_env, payment_preimage) == 32);
6931         (*_env)->GetByteArrayRegion (_env, payment_preimage, 0, 32, payment_preimage_ref.data);
6932         LDKThirtyTwoBytes payment_secret_ref;
6933         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6934         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6935         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
6936         return ret_val;
6937 }
6938
6939 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6940         LDKChannelManager this_arg_conv;
6941         this_arg_conv.inner = (void*)(this_arg & (~1));
6942         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6943         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6944         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
6945         return arg_arr;
6946 }
6947
6948 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) {
6949         LDKChannelManager this_arg_conv;
6950         this_arg_conv.inner = (void*)(this_arg & (~1));
6951         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6952         LDKOutPoint funding_txo_conv;
6953         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6954         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6955         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
6956 }
6957
6958 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6959         LDKChannelManager this_arg_conv;
6960         this_arg_conv.inner = (void*)(this_arg & (~1));
6961         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6962         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6963         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
6964         return (long)ret;
6965 }
6966
6967 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6968         LDKChannelManager this_arg_conv;
6969         this_arg_conv.inner = (void*)(this_arg & (~1));
6970         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6971         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6972         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
6973         return (long)ret;
6974 }
6975
6976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height) {
6977         LDKChannelManager this_arg_conv;
6978         this_arg_conv.inner = (void*)(this_arg & (~1));
6979         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6980         unsigned char header_arr[80];
6981         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6982         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6983         unsigned char (*header_ref)[80] = &header_arr;
6984         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6985         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
6986         if (txdata_constr.datalen > 0)
6987                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6988         else
6989                 txdata_constr.data = NULL;
6990         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
6991         for (size_t d = 0; d < txdata_constr.datalen; d++) {
6992                 long arr_conv_29 = txdata_vals[d];
6993                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
6994                 FREE((void*)arr_conv_29);
6995                 txdata_constr.data[d] = arr_conv_29_conv;
6996         }
6997         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
6998         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
6999 }
7000
7001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header) {
7002         LDKChannelManager this_arg_conv;
7003         this_arg_conv.inner = (void*)(this_arg & (~1));
7004         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
7005         unsigned char header_arr[80];
7006         CHECK((*_env)->GetArrayLength (_env, header) == 80);
7007         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
7008         unsigned char (*header_ref)[80] = &header_arr;
7009         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
7010 }
7011
7012 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
7013         LDKChannelManager this_arg_conv;
7014         this_arg_conv.inner = (void*)(this_arg & (~1));
7015         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
7016         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7017         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
7018         return (long)ret;
7019 }
7020
7021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7022         LDKChannelManagerReadArgs this_ptr_conv;
7023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7024         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7025         ChannelManagerReadArgs_free(this_ptr_conv);
7026 }
7027
7028 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr) {
7029         LDKChannelManagerReadArgs this_ptr_conv;
7030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7031         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7032         long ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
7033         return ret;
7034 }
7035
7036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7037         LDKChannelManagerReadArgs this_ptr_conv;
7038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7039         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7040         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
7041         if (val_conv.free == LDKKeysInterface_JCalls_free) {
7042                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7043                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
7044         }
7045         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
7046 }
7047
7048 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr) {
7049         LDKChannelManagerReadArgs this_ptr_conv;
7050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7051         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7052         long ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
7053         return ret;
7054 }
7055
7056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7057         LDKChannelManagerReadArgs this_ptr_conv;
7058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7059         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7060         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
7061         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
7062                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7063                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
7064         }
7065         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
7066 }
7067
7068 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr) {
7069         LDKChannelManagerReadArgs this_ptr_conv;
7070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7071         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7072         long ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
7073         return ret;
7074 }
7075
7076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7077         LDKChannelManagerReadArgs this_ptr_conv;
7078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7079         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7080         LDKWatch val_conv = *(LDKWatch*)val;
7081         if (val_conv.free == LDKWatch_JCalls_free) {
7082                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7083                 LDKWatch_JCalls_clone(val_conv.this_arg);
7084         }
7085         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
7086 }
7087
7088 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr) {
7089         LDKChannelManagerReadArgs this_ptr_conv;
7090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7091         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7092         long ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
7093         return ret;
7094 }
7095
7096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7097         LDKChannelManagerReadArgs this_ptr_conv;
7098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7099         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7100         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
7101         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
7102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7103                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
7104         }
7105         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
7106 }
7107
7108 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv * _env, jclass _b, jlong this_ptr) {
7109         LDKChannelManagerReadArgs this_ptr_conv;
7110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7111         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7112         long ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
7113         return ret;
7114 }
7115
7116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7117         LDKChannelManagerReadArgs this_ptr_conv;
7118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7119         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7120         LDKLogger val_conv = *(LDKLogger*)val;
7121         if (val_conv.free == LDKLogger_JCalls_free) {
7122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7123                 LDKLogger_JCalls_clone(val_conv.this_arg);
7124         }
7125         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
7126 }
7127
7128 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
7129         LDKChannelManagerReadArgs this_ptr_conv;
7130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7131         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7132         LDKUserConfig ret = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
7133         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7134 }
7135
7136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7137         LDKChannelManagerReadArgs this_ptr_conv;
7138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7139         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7140         LDKUserConfig val_conv;
7141         val_conv.inner = (void*)(val & (~1));
7142         val_conv.is_owned = (val & 1) || (val == 0);
7143         if (val_conv.inner != NULL)
7144                 val_conv = UserConfig_clone(&val_conv);
7145         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
7146 }
7147
7148 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) {
7149         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
7150         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
7151                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7152                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
7153         }
7154         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
7155         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
7156                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7157                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
7158         }
7159         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
7160         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
7161                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7162                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
7163         }
7164         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
7165         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
7166                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7167                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
7168         }
7169         LDKLogger logger_conv = *(LDKLogger*)logger;
7170         if (logger_conv.free == LDKLogger_JCalls_free) {
7171                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7172                 LDKLogger_JCalls_clone(logger_conv.this_arg);
7173         }
7174         LDKUserConfig default_config_conv;
7175         default_config_conv.inner = (void*)(default_config & (~1));
7176         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
7177         if (default_config_conv.inner != NULL)
7178                 default_config_conv = UserConfig_clone(&default_config_conv);
7179         LDKCVec_ChannelMonitorZ channel_monitors_constr;
7180         channel_monitors_constr.datalen = (*_env)->GetArrayLength (_env, channel_monitors);
7181         if (channel_monitors_constr.datalen > 0)
7182                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7183         else
7184                 channel_monitors_constr.data = NULL;
7185         long* channel_monitors_vals = (*_env)->GetLongArrayElements (_env, channel_monitors, NULL);
7186         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
7187                 long arr_conv_16 = channel_monitors_vals[q];
7188                 LDKChannelMonitor arr_conv_16_conv;
7189                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
7190                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
7191                 // Warning: we may need a move here but can't clone!
7192                 channel_monitors_constr.data[q] = arr_conv_16_conv;
7193         }
7194         (*_env)->ReleaseLongArrayElements (_env, channel_monitors, channel_monitors_vals, 0);
7195         LDKChannelManagerReadArgs ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
7196         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7197 }
7198
7199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7200         LDKDecodeError this_ptr_conv;
7201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7202         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7203         DecodeError_free(this_ptr_conv);
7204 }
7205
7206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7207         LDKInit this_ptr_conv;
7208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7209         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7210         Init_free(this_ptr_conv);
7211 }
7212
7213 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7214         LDKInit orig_conv;
7215         orig_conv.inner = (void*)(orig & (~1));
7216         orig_conv.is_owned = (orig & 1) || (orig == 0);
7217         LDKInit ret = Init_clone(&orig_conv);
7218         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7219 }
7220
7221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7222         LDKErrorMessage this_ptr_conv;
7223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7224         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7225         ErrorMessage_free(this_ptr_conv);
7226 }
7227
7228 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7229         LDKErrorMessage orig_conv;
7230         orig_conv.inner = (void*)(orig & (~1));
7231         orig_conv.is_owned = (orig & 1) || (orig == 0);
7232         LDKErrorMessage ret = ErrorMessage_clone(&orig_conv);
7233         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7234 }
7235
7236 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7237         LDKErrorMessage this_ptr_conv;
7238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7239         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7240         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7241         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
7242         return ret_arr;
7243 }
7244
7245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7246         LDKErrorMessage this_ptr_conv;
7247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7248         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7249         LDKThirtyTwoBytes val_ref;
7250         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7251         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7252         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
7253 }
7254
7255 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) {
7256         LDKErrorMessage this_ptr_conv;
7257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7258         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7259         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
7260         char* _buf = MALLOC(_str.len + 1, "str conv buf");
7261         memcpy(_buf, _str.chars, _str.len);
7262         _buf[_str.len] = 0;
7263         jstring _conv = (*_env)->NewStringUTF(_env, _str.chars);
7264         FREE(_buf);
7265         return _conv;
7266 }
7267
7268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7269         LDKErrorMessage this_ptr_conv;
7270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7271         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7272         LDKCVec_u8Z val_ref;
7273         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
7274         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
7275         ErrorMessage_set_data(&this_ptr_conv, val_ref);
7276         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
7277 }
7278
7279 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray data_arg) {
7280         LDKThirtyTwoBytes channel_id_arg_ref;
7281         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7282         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7283         LDKCVec_u8Z data_arg_ref;
7284         data_arg_ref.data = (*_env)->GetByteArrayElements (_env, data_arg, NULL);
7285         data_arg_ref.datalen = (*_env)->GetArrayLength (_env, data_arg);
7286         LDKErrorMessage ret = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
7287         (*_env)->ReleaseByteArrayElements(_env, data_arg, (int8_t*)data_arg_ref.data, 0);
7288         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7289 }
7290
7291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7292         LDKPing this_ptr_conv;
7293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7294         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7295         Ping_free(this_ptr_conv);
7296 }
7297
7298 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7299         LDKPing orig_conv;
7300         orig_conv.inner = (void*)(orig & (~1));
7301         orig_conv.is_owned = (orig & 1) || (orig == 0);
7302         LDKPing ret = Ping_clone(&orig_conv);
7303         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7304 }
7305
7306 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7307         LDKPing this_ptr_conv;
7308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7309         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7310         jshort ret_val = Ping_get_ponglen(&this_ptr_conv);
7311         return ret_val;
7312 }
7313
7314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7315         LDKPing this_ptr_conv;
7316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7317         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7318         Ping_set_ponglen(&this_ptr_conv, val);
7319 }
7320
7321 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7322         LDKPing this_ptr_conv;
7323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7324         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7325         jshort ret_val = Ping_get_byteslen(&this_ptr_conv);
7326         return ret_val;
7327 }
7328
7329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7330         LDKPing this_ptr_conv;
7331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7332         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7333         Ping_set_byteslen(&this_ptr_conv, val);
7334 }
7335
7336 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv * _env, jclass _b, jshort ponglen_arg, jshort byteslen_arg) {
7337         LDKPing ret = Ping_new(ponglen_arg, byteslen_arg);
7338         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7339 }
7340
7341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7342         LDKPong this_ptr_conv;
7343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7344         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7345         Pong_free(this_ptr_conv);
7346 }
7347
7348 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7349         LDKPong orig_conv;
7350         orig_conv.inner = (void*)(orig & (~1));
7351         orig_conv.is_owned = (orig & 1) || (orig == 0);
7352         LDKPong ret = Pong_clone(&orig_conv);
7353         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7354 }
7355
7356 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7357         LDKPong this_ptr_conv;
7358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7359         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7360         jshort ret_val = Pong_get_byteslen(&this_ptr_conv);
7361         return ret_val;
7362 }
7363
7364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7365         LDKPong this_ptr_conv;
7366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7367         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7368         Pong_set_byteslen(&this_ptr_conv, val);
7369 }
7370
7371 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv * _env, jclass _b, jshort byteslen_arg) {
7372         LDKPong ret = Pong_new(byteslen_arg);
7373         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7374 }
7375
7376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7377         LDKOpenChannel this_ptr_conv;
7378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7379         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7380         OpenChannel_free(this_ptr_conv);
7381 }
7382
7383 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7384         LDKOpenChannel orig_conv;
7385         orig_conv.inner = (void*)(orig & (~1));
7386         orig_conv.is_owned = (orig & 1) || (orig == 0);
7387         LDKOpenChannel ret = OpenChannel_clone(&orig_conv);
7388         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7389 }
7390
7391 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7392         LDKOpenChannel this_ptr_conv;
7393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7394         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7395         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7396         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
7397         return ret_arr;
7398 }
7399
7400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7401         LDKOpenChannel this_ptr_conv;
7402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7403         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7404         LDKThirtyTwoBytes val_ref;
7405         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7406         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7407         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
7408 }
7409
7410 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7411         LDKOpenChannel this_ptr_conv;
7412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7413         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7414         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7415         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
7416         return ret_arr;
7417 }
7418
7419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7420         LDKOpenChannel this_ptr_conv;
7421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7422         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7423         LDKThirtyTwoBytes val_ref;
7424         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7425         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7426         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7427 }
7428
7429 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7430         LDKOpenChannel this_ptr_conv;
7431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7432         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7433         jlong ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
7434         return ret_val;
7435 }
7436
7437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7438         LDKOpenChannel this_ptr_conv;
7439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7440         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7441         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
7442 }
7443
7444 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7445         LDKOpenChannel this_ptr_conv;
7446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7447         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7448         jlong ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
7449         return ret_val;
7450 }
7451
7452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7453         LDKOpenChannel this_ptr_conv;
7454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7455         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7456         OpenChannel_set_push_msat(&this_ptr_conv, val);
7457 }
7458
7459 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7460         LDKOpenChannel this_ptr_conv;
7461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7462         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7463         jlong ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
7464         return ret_val;
7465 }
7466
7467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7468         LDKOpenChannel this_ptr_conv;
7469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7470         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7471         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7472 }
7473
7474 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7475         LDKOpenChannel this_ptr_conv;
7476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7477         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7478         jlong ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7479         return ret_val;
7480 }
7481
7482 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) {
7483         LDKOpenChannel this_ptr_conv;
7484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7485         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7486         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7487 }
7488
7489 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7490         LDKOpenChannel this_ptr_conv;
7491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7492         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7493         jlong ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7494         return ret_val;
7495 }
7496
7497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7498         LDKOpenChannel this_ptr_conv;
7499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7500         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7501         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7502 }
7503
7504 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7505         LDKOpenChannel this_ptr_conv;
7506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7507         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7508         jlong ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
7509         return ret_val;
7510 }
7511
7512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7513         LDKOpenChannel this_ptr_conv;
7514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7515         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7516         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7517 }
7518
7519 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
7520         LDKOpenChannel this_ptr_conv;
7521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7522         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7523         jint ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
7524         return ret_val;
7525 }
7526
7527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7528         LDKOpenChannel this_ptr_conv;
7529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7530         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7531         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
7532 }
7533
7534 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
7535         LDKOpenChannel this_ptr_conv;
7536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7537         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7538         jshort ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
7539         return ret_val;
7540 }
7541
7542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7543         LDKOpenChannel this_ptr_conv;
7544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7545         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7546         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
7547 }
7548
7549 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
7550         LDKOpenChannel this_ptr_conv;
7551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7552         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7553         jshort ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
7554         return ret_val;
7555 }
7556
7557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort 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         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7562 }
7563
7564 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
7565         LDKOpenChannel this_ptr_conv;
7566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7567         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7568         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7569         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
7570         return arg_arr;
7571 }
7572
7573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7574         LDKOpenChannel this_ptr_conv;
7575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7576         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7577         LDKPublicKey val_ref;
7578         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7579         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7580         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7581 }
7582
7583 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7584         LDKOpenChannel this_ptr_conv;
7585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7586         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7587         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7588         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
7589         return arg_arr;
7590 }
7591
7592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7593         LDKOpenChannel this_ptr_conv;
7594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7595         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7596         LDKPublicKey val_ref;
7597         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7598         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7599         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7600 }
7601
7602 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7603         LDKOpenChannel this_ptr_conv;
7604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7605         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7606         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7607         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
7608         return arg_arr;
7609 }
7610
7611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7612         LDKOpenChannel this_ptr_conv;
7613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7614         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7615         LDKPublicKey val_ref;
7616         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7617         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7618         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
7619 }
7620
7621 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7622         LDKOpenChannel this_ptr_conv;
7623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7624         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7625         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7626         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
7627         return arg_arr;
7628 }
7629
7630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7631         LDKOpenChannel this_ptr_conv;
7632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7633         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7634         LDKPublicKey val_ref;
7635         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7636         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7637         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7638 }
7639
7640 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7641         LDKOpenChannel this_ptr_conv;
7642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7643         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7644         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7645         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
7646         return arg_arr;
7647 }
7648
7649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7650         LDKOpenChannel this_ptr_conv;
7651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7652         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7653         LDKPublicKey val_ref;
7654         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7655         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7656         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7657 }
7658
7659 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7660         LDKOpenChannel this_ptr_conv;
7661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7662         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7663         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7664         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
7665         return arg_arr;
7666 }
7667
7668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7669         LDKOpenChannel this_ptr_conv;
7670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7671         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7672         LDKPublicKey val_ref;
7673         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7674         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7675         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7676 }
7677
7678 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
7679         LDKOpenChannel this_ptr_conv;
7680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7681         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7682         jbyte ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
7683         return ret_val;
7684 }
7685
7686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
7687         LDKOpenChannel this_ptr_conv;
7688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7689         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7690         OpenChannel_set_channel_flags(&this_ptr_conv, val);
7691 }
7692
7693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7694         LDKAcceptChannel this_ptr_conv;
7695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7696         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7697         AcceptChannel_free(this_ptr_conv);
7698 }
7699
7700 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7701         LDKAcceptChannel orig_conv;
7702         orig_conv.inner = (void*)(orig & (~1));
7703         orig_conv.is_owned = (orig & 1) || (orig == 0);
7704         LDKAcceptChannel ret = AcceptChannel_clone(&orig_conv);
7705         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7706 }
7707
7708 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7709         LDKAcceptChannel this_ptr_conv;
7710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7711         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7712         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7713         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
7714         return ret_arr;
7715 }
7716
7717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7718         LDKAcceptChannel this_ptr_conv;
7719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7720         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7721         LDKThirtyTwoBytes val_ref;
7722         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7723         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7724         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7725 }
7726
7727 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7728         LDKAcceptChannel this_ptr_conv;
7729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7730         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7731         jlong ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
7732         return ret_val;
7733 }
7734
7735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7736         LDKAcceptChannel this_ptr_conv;
7737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7738         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7739         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7740 }
7741
7742 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7743         LDKAcceptChannel this_ptr_conv;
7744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7745         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7746         jlong ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7747         return ret_val;
7748 }
7749
7750 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) {
7751         LDKAcceptChannel this_ptr_conv;
7752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7753         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7754         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7755 }
7756
7757 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7758         LDKAcceptChannel this_ptr_conv;
7759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7760         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7761         jlong ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7762         return ret_val;
7763 }
7764
7765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7766         LDKAcceptChannel this_ptr_conv;
7767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7768         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7769         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7770 }
7771
7772 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7773         LDKAcceptChannel this_ptr_conv;
7774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7775         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7776         jlong ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
7777         return ret_val;
7778 }
7779
7780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7781         LDKAcceptChannel this_ptr_conv;
7782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7783         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7784         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7785 }
7786
7787 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
7788         LDKAcceptChannel this_ptr_conv;
7789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7790         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7791         jint ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
7792         return ret_val;
7793 }
7794
7795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7796         LDKAcceptChannel this_ptr_conv;
7797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7798         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7799         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
7800 }
7801
7802 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
7803         LDKAcceptChannel this_ptr_conv;
7804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7805         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7806         jshort ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
7807         return ret_val;
7808 }
7809
7810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7811         LDKAcceptChannel this_ptr_conv;
7812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7813         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7814         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
7815 }
7816
7817 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
7818         LDKAcceptChannel this_ptr_conv;
7819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7820         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7821         jshort ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
7822         return ret_val;
7823 }
7824
7825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort 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         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7830 }
7831
7832 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
7833         LDKAcceptChannel this_ptr_conv;
7834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7835         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7836         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7837         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
7838         return arg_arr;
7839 }
7840
7841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7842         LDKAcceptChannel this_ptr_conv;
7843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7844         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7845         LDKPublicKey val_ref;
7846         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7847         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7848         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7849 }
7850
7851 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7852         LDKAcceptChannel this_ptr_conv;
7853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7854         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7855         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7856         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
7857         return arg_arr;
7858 }
7859
7860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7861         LDKAcceptChannel this_ptr_conv;
7862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7863         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7864         LDKPublicKey val_ref;
7865         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7866         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7867         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7868 }
7869
7870 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7871         LDKAcceptChannel this_ptr_conv;
7872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7873         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7874         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7875         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
7876         return arg_arr;
7877 }
7878
7879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7880         LDKAcceptChannel this_ptr_conv;
7881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7882         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7883         LDKPublicKey val_ref;
7884         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7885         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7886         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
7887 }
7888
7889 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7890         LDKAcceptChannel this_ptr_conv;
7891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7892         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7893         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7894         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
7895         return arg_arr;
7896 }
7897
7898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7899         LDKAcceptChannel this_ptr_conv;
7900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7901         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7902         LDKPublicKey val_ref;
7903         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7904         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7905         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7906 }
7907
7908 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7909         LDKAcceptChannel this_ptr_conv;
7910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7911         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7912         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7913         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
7914         return arg_arr;
7915 }
7916
7917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7918         LDKAcceptChannel this_ptr_conv;
7919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7920         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7921         LDKPublicKey val_ref;
7922         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7923         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7924         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7925 }
7926
7927 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7928         LDKAcceptChannel this_ptr_conv;
7929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7930         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7931         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7932         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
7933         return arg_arr;
7934 }
7935
7936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7937         LDKAcceptChannel this_ptr_conv;
7938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7939         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7940         LDKPublicKey val_ref;
7941         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7942         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7943         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7944 }
7945
7946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7947         LDKFundingCreated this_ptr_conv;
7948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7949         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7950         FundingCreated_free(this_ptr_conv);
7951 }
7952
7953 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7954         LDKFundingCreated orig_conv;
7955         orig_conv.inner = (void*)(orig & (~1));
7956         orig_conv.is_owned = (orig & 1) || (orig == 0);
7957         LDKFundingCreated ret = FundingCreated_clone(&orig_conv);
7958         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7959 }
7960
7961 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7962         LDKFundingCreated this_ptr_conv;
7963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7964         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7965         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7966         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
7967         return ret_arr;
7968 }
7969
7970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7971         LDKFundingCreated this_ptr_conv;
7972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7973         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7974         LDKThirtyTwoBytes val_ref;
7975         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7976         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7977         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
7978 }
7979
7980 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
7981         LDKFundingCreated this_ptr_conv;
7982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7983         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7984         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7985         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
7986         return ret_arr;
7987 }
7988
7989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7990         LDKFundingCreated this_ptr_conv;
7991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7992         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7993         LDKThirtyTwoBytes val_ref;
7994         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7995         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7996         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
7997 }
7998
7999 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
8000         LDKFundingCreated this_ptr_conv;
8001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8002         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8003         jshort ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
8004         return ret_val;
8005 }
8006
8007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort 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         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
8012 }
8013
8014 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8015         LDKFundingCreated this_ptr_conv;
8016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8017         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8018         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8019         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
8020         return arg_arr;
8021 }
8022
8023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8024         LDKFundingCreated this_ptr_conv;
8025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8026         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8027         LDKSignature val_ref;
8028         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8029         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8030         FundingCreated_set_signature(&this_ptr_conv, val_ref);
8031 }
8032
8033 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) {
8034         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
8035         CHECK((*_env)->GetArrayLength (_env, temporary_channel_id_arg) == 32);
8036         (*_env)->GetByteArrayRegion (_env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
8037         LDKThirtyTwoBytes funding_txid_arg_ref;
8038         CHECK((*_env)->GetArrayLength (_env, funding_txid_arg) == 32);
8039         (*_env)->GetByteArrayRegion (_env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
8040         LDKSignature signature_arg_ref;
8041         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8042         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8043         LDKFundingCreated ret = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
8044         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8045 }
8046
8047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8048         LDKFundingSigned this_ptr_conv;
8049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8050         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8051         FundingSigned_free(this_ptr_conv);
8052 }
8053
8054 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8055         LDKFundingSigned orig_conv;
8056         orig_conv.inner = (void*)(orig & (~1));
8057         orig_conv.is_owned = (orig & 1) || (orig == 0);
8058         LDKFundingSigned ret = FundingSigned_clone(&orig_conv);
8059         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8060 }
8061
8062 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8063         LDKFundingSigned this_ptr_conv;
8064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8065         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8066         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8067         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
8068         return ret_arr;
8069 }
8070
8071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8072         LDKFundingSigned this_ptr_conv;
8073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8074         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8075         LDKThirtyTwoBytes val_ref;
8076         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8077         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8078         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
8079 }
8080
8081 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8082         LDKFundingSigned this_ptr_conv;
8083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8084         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8085         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8086         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
8087         return arg_arr;
8088 }
8089
8090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8091         LDKFundingSigned this_ptr_conv;
8092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8093         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8094         LDKSignature val_ref;
8095         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8096         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8097         FundingSigned_set_signature(&this_ptr_conv, val_ref);
8098 }
8099
8100 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray signature_arg) {
8101         LDKThirtyTwoBytes channel_id_arg_ref;
8102         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8103         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8104         LDKSignature signature_arg_ref;
8105         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8106         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8107         LDKFundingSigned ret = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
8108         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8109 }
8110
8111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8112         LDKFundingLocked this_ptr_conv;
8113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8114         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8115         FundingLocked_free(this_ptr_conv);
8116 }
8117
8118 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8119         LDKFundingLocked orig_conv;
8120         orig_conv.inner = (void*)(orig & (~1));
8121         orig_conv.is_owned = (orig & 1) || (orig == 0);
8122         LDKFundingLocked ret = FundingLocked_clone(&orig_conv);
8123         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8124 }
8125
8126 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8127         LDKFundingLocked this_ptr_conv;
8128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8129         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8130         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8131         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
8132         return ret_arr;
8133 }
8134
8135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8136         LDKFundingLocked this_ptr_conv;
8137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8138         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8139         LDKThirtyTwoBytes val_ref;
8140         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8141         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8142         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
8143 }
8144
8145 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8146         LDKFundingLocked this_ptr_conv;
8147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8148         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8149         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8150         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
8151         return arg_arr;
8152 }
8153
8154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8155         LDKFundingLocked this_ptr_conv;
8156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8157         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8158         LDKPublicKey val_ref;
8159         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8160         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8161         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
8162 }
8163
8164 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray next_per_commitment_point_arg) {
8165         LDKThirtyTwoBytes channel_id_arg_ref;
8166         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8167         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8168         LDKPublicKey next_per_commitment_point_arg_ref;
8169         CHECK((*_env)->GetArrayLength (_env, next_per_commitment_point_arg) == 33);
8170         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
8171         LDKFundingLocked ret = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
8172         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8173 }
8174
8175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8176         LDKShutdown this_ptr_conv;
8177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8178         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8179         Shutdown_free(this_ptr_conv);
8180 }
8181
8182 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8183         LDKShutdown orig_conv;
8184         orig_conv.inner = (void*)(orig & (~1));
8185         orig_conv.is_owned = (orig & 1) || (orig == 0);
8186         LDKShutdown ret = Shutdown_clone(&orig_conv);
8187         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8188 }
8189
8190 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8191         LDKShutdown this_ptr_conv;
8192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8193         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8194         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8195         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
8196         return ret_arr;
8197 }
8198
8199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8200         LDKShutdown this_ptr_conv;
8201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8202         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8203         LDKThirtyTwoBytes val_ref;
8204         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8205         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8206         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
8207 }
8208
8209 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
8210         LDKShutdown this_ptr_conv;
8211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8212         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8213         LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
8214         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
8215         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
8216         return arg_arr;
8217 }
8218
8219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8220         LDKShutdown this_ptr_conv;
8221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8222         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8223         LDKCVec_u8Z val_ref;
8224         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
8225         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
8226         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
8227         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
8228 }
8229
8230 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray scriptpubkey_arg) {
8231         LDKThirtyTwoBytes channel_id_arg_ref;
8232         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8233         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8234         LDKCVec_u8Z scriptpubkey_arg_ref;
8235         scriptpubkey_arg_ref.data = (*_env)->GetByteArrayElements (_env, scriptpubkey_arg, NULL);
8236         scriptpubkey_arg_ref.datalen = (*_env)->GetArrayLength (_env, scriptpubkey_arg);
8237         LDKShutdown ret = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
8238         (*_env)->ReleaseByteArrayElements(_env, scriptpubkey_arg, (int8_t*)scriptpubkey_arg_ref.data, 0);
8239         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8240 }
8241
8242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8243         LDKClosingSigned this_ptr_conv;
8244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8245         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8246         ClosingSigned_free(this_ptr_conv);
8247 }
8248
8249 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8250         LDKClosingSigned orig_conv;
8251         orig_conv.inner = (void*)(orig & (~1));
8252         orig_conv.is_owned = (orig & 1) || (orig == 0);
8253         LDKClosingSigned ret = ClosingSigned_clone(&orig_conv);
8254         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8255 }
8256
8257 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8258         LDKClosingSigned this_ptr_conv;
8259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8260         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8261         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8262         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
8263         return ret_arr;
8264 }
8265
8266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8267         LDKClosingSigned this_ptr_conv;
8268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8269         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8270         LDKThirtyTwoBytes val_ref;
8271         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8272         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8273         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
8274 }
8275
8276 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
8277         LDKClosingSigned this_ptr_conv;
8278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8279         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8280         jlong ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
8281         return ret_val;
8282 }
8283
8284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong 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         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
8289 }
8290
8291 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8292         LDKClosingSigned this_ptr_conv;
8293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8294         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8295         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8296         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
8297         return arg_arr;
8298 }
8299
8300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8301         LDKClosingSigned this_ptr_conv;
8302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8303         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8304         LDKSignature val_ref;
8305         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8306         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8307         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
8308 }
8309
8310 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) {
8311         LDKThirtyTwoBytes channel_id_arg_ref;
8312         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8313         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8314         LDKSignature signature_arg_ref;
8315         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8316         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8317         LDKClosingSigned ret = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
8318         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8319 }
8320
8321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8322         LDKUpdateAddHTLC this_ptr_conv;
8323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8324         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8325         UpdateAddHTLC_free(this_ptr_conv);
8326 }
8327
8328 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8329         LDKUpdateAddHTLC orig_conv;
8330         orig_conv.inner = (void*)(orig & (~1));
8331         orig_conv.is_owned = (orig & 1) || (orig == 0);
8332         LDKUpdateAddHTLC ret = UpdateAddHTLC_clone(&orig_conv);
8333         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8334 }
8335
8336 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8337         LDKUpdateAddHTLC this_ptr_conv;
8338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8339         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8340         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8341         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
8342         return ret_arr;
8343 }
8344
8345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8346         LDKUpdateAddHTLC this_ptr_conv;
8347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8348         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8349         LDKThirtyTwoBytes val_ref;
8350         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8351         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8352         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
8353 }
8354
8355 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8356         LDKUpdateAddHTLC this_ptr_conv;
8357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8358         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8359         jlong ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
8360         return ret_val;
8361 }
8362
8363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8364         LDKUpdateAddHTLC this_ptr_conv;
8365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8366         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8367         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
8368 }
8369
8370 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8371         LDKUpdateAddHTLC this_ptr_conv;
8372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8373         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8374         jlong ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
8375         return ret_val;
8376 }
8377
8378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong 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         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
8383 }
8384
8385 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8386         LDKUpdateAddHTLC this_ptr_conv;
8387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8388         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8389         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8390         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
8391         return ret_arr;
8392 }
8393
8394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8395         LDKUpdateAddHTLC this_ptr_conv;
8396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8397         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8398         LDKThirtyTwoBytes val_ref;
8399         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8400         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8401         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
8402 }
8403
8404 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
8405         LDKUpdateAddHTLC this_ptr_conv;
8406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8407         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8408         jint ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
8409         return ret_val;
8410 }
8411
8412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8413         LDKUpdateAddHTLC this_ptr_conv;
8414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8415         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8416         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
8417 }
8418
8419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8420         LDKUpdateFulfillHTLC this_ptr_conv;
8421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8422         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8423         UpdateFulfillHTLC_free(this_ptr_conv);
8424 }
8425
8426 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8427         LDKUpdateFulfillHTLC orig_conv;
8428         orig_conv.inner = (void*)(orig & (~1));
8429         orig_conv.is_owned = (orig & 1) || (orig == 0);
8430         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_clone(&orig_conv);
8431         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8432 }
8433
8434 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8435         LDKUpdateFulfillHTLC this_ptr_conv;
8436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8437         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8438         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8439         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
8440         return ret_arr;
8441 }
8442
8443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8444         LDKUpdateFulfillHTLC this_ptr_conv;
8445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8446         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8447         LDKThirtyTwoBytes val_ref;
8448         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8449         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8450         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
8451 }
8452
8453 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8454         LDKUpdateFulfillHTLC this_ptr_conv;
8455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8456         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8457         jlong ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
8458         return ret_val;
8459 }
8460
8461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong 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         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
8466 }
8467
8468 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr) {
8469         LDKUpdateFulfillHTLC this_ptr_conv;
8470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8471         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8472         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8473         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
8474         return ret_arr;
8475 }
8476
8477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8478         LDKUpdateFulfillHTLC this_ptr_conv;
8479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8480         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8481         LDKThirtyTwoBytes val_ref;
8482         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8483         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8484         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
8485 }
8486
8487 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) {
8488         LDKThirtyTwoBytes channel_id_arg_ref;
8489         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8490         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8491         LDKThirtyTwoBytes payment_preimage_arg_ref;
8492         CHECK((*_env)->GetArrayLength (_env, payment_preimage_arg) == 32);
8493         (*_env)->GetByteArrayRegion (_env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
8494         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
8495         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8496 }
8497
8498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8499         LDKUpdateFailHTLC this_ptr_conv;
8500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8501         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8502         UpdateFailHTLC_free(this_ptr_conv);
8503 }
8504
8505 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8506         LDKUpdateFailHTLC orig_conv;
8507         orig_conv.inner = (void*)(orig & (~1));
8508         orig_conv.is_owned = (orig & 1) || (orig == 0);
8509         LDKUpdateFailHTLC ret = UpdateFailHTLC_clone(&orig_conv);
8510         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8511 }
8512
8513 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8514         LDKUpdateFailHTLC this_ptr_conv;
8515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8516         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8517         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8518         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
8519         return ret_arr;
8520 }
8521
8522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8523         LDKUpdateFailHTLC this_ptr_conv;
8524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8525         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8526         LDKThirtyTwoBytes val_ref;
8527         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8528         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8529         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
8530 }
8531
8532 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8533         LDKUpdateFailHTLC this_ptr_conv;
8534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8535         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8536         jlong ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
8537         return ret_val;
8538 }
8539
8540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8541         LDKUpdateFailHTLC this_ptr_conv;
8542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8543         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8544         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
8545 }
8546
8547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8548         LDKUpdateFailMalformedHTLC this_ptr_conv;
8549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8550         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8551         UpdateFailMalformedHTLC_free(this_ptr_conv);
8552 }
8553
8554 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8555         LDKUpdateFailMalformedHTLC orig_conv;
8556         orig_conv.inner = (void*)(orig & (~1));
8557         orig_conv.is_owned = (orig & 1) || (orig == 0);
8558         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_clone(&orig_conv);
8559         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8560 }
8561
8562 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8563         LDKUpdateFailMalformedHTLC this_ptr_conv;
8564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8565         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8566         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8567         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
8568         return ret_arr;
8569 }
8570
8571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8572         LDKUpdateFailMalformedHTLC this_ptr_conv;
8573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8574         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8575         LDKThirtyTwoBytes val_ref;
8576         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8577         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8578         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
8579 }
8580
8581 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8582         LDKUpdateFailMalformedHTLC this_ptr_conv;
8583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8584         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8585         jlong ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
8586         return ret_val;
8587 }
8588
8589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8590         LDKUpdateFailMalformedHTLC this_ptr_conv;
8591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8592         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8593         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
8594 }
8595
8596 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr) {
8597         LDKUpdateFailMalformedHTLC this_ptr_conv;
8598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8599         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8600         jshort ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
8601         return ret_val;
8602 }
8603
8604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
8605         LDKUpdateFailMalformedHTLC this_ptr_conv;
8606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8607         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8608         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
8609 }
8610
8611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8612         LDKCommitmentSigned this_ptr_conv;
8613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8614         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8615         CommitmentSigned_free(this_ptr_conv);
8616 }
8617
8618 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8619         LDKCommitmentSigned orig_conv;
8620         orig_conv.inner = (void*)(orig & (~1));
8621         orig_conv.is_owned = (orig & 1) || (orig == 0);
8622         LDKCommitmentSigned ret = CommitmentSigned_clone(&orig_conv);
8623         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8624 }
8625
8626 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8627         LDKCommitmentSigned this_ptr_conv;
8628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8629         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8630         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8631         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
8632         return ret_arr;
8633 }
8634
8635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8636         LDKCommitmentSigned this_ptr_conv;
8637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8638         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8639         LDKThirtyTwoBytes val_ref;
8640         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8641         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8642         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
8643 }
8644
8645 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8646         LDKCommitmentSigned this_ptr_conv;
8647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8648         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8649         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8650         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
8651         return arg_arr;
8652 }
8653
8654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8655         LDKCommitmentSigned this_ptr_conv;
8656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8657         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8658         LDKSignature val_ref;
8659         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8660         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8661         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
8662 }
8663
8664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jobjectArray val) {
8665         LDKCommitmentSigned this_ptr_conv;
8666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8667         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8668         LDKCVec_SignatureZ val_constr;
8669         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
8670         if (val_constr.datalen > 0)
8671                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8672         else
8673                 val_constr.data = NULL;
8674         for (size_t i = 0; i < val_constr.datalen; i++) {
8675                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, val, i);
8676                 LDKSignature arr_conv_8_ref;
8677                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
8678                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
8679                 val_constr.data[i] = arr_conv_8_ref;
8680         }
8681         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
8682 }
8683
8684 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) {
8685         LDKThirtyTwoBytes channel_id_arg_ref;
8686         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8687         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8688         LDKSignature signature_arg_ref;
8689         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8690         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8691         LDKCVec_SignatureZ htlc_signatures_arg_constr;
8692         htlc_signatures_arg_constr.datalen = (*_env)->GetArrayLength (_env, htlc_signatures_arg);
8693         if (htlc_signatures_arg_constr.datalen > 0)
8694                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8695         else
8696                 htlc_signatures_arg_constr.data = NULL;
8697         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
8698                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, htlc_signatures_arg, i);
8699                 LDKSignature arr_conv_8_ref;
8700                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
8701                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
8702                 htlc_signatures_arg_constr.data[i] = arr_conv_8_ref;
8703         }
8704         LDKCommitmentSigned ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
8705         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8706 }
8707
8708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8709         LDKRevokeAndACK this_ptr_conv;
8710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8711         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8712         RevokeAndACK_free(this_ptr_conv);
8713 }
8714
8715 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8716         LDKRevokeAndACK orig_conv;
8717         orig_conv.inner = (void*)(orig & (~1));
8718         orig_conv.is_owned = (orig & 1) || (orig == 0);
8719         LDKRevokeAndACK ret = RevokeAndACK_clone(&orig_conv);
8720         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8721 }
8722
8723 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8724         LDKRevokeAndACK this_ptr_conv;
8725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8726         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8727         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8728         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
8729         return ret_arr;
8730 }
8731
8732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8733         LDKRevokeAndACK this_ptr_conv;
8734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8735         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8736         LDKThirtyTwoBytes val_ref;
8737         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8738         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8739         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
8740 }
8741
8742 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
8743         LDKRevokeAndACK this_ptr_conv;
8744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8745         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8746         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8747         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
8748         return ret_arr;
8749 }
8750
8751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8752         LDKRevokeAndACK this_ptr_conv;
8753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8754         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8755         LDKThirtyTwoBytes val_ref;
8756         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8757         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8758         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
8759 }
8760
8761 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8762         LDKRevokeAndACK this_ptr_conv;
8763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8764         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8765         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8766         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
8767         return arg_arr;
8768 }
8769
8770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8771         LDKRevokeAndACK this_ptr_conv;
8772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8773         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8774         LDKPublicKey val_ref;
8775         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8776         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8777         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
8778 }
8779
8780 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) {
8781         LDKThirtyTwoBytes channel_id_arg_ref;
8782         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8783         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8784         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
8785         CHECK((*_env)->GetArrayLength (_env, per_commitment_secret_arg) == 32);
8786         (*_env)->GetByteArrayRegion (_env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
8787         LDKPublicKey next_per_commitment_point_arg_ref;
8788         CHECK((*_env)->GetArrayLength (_env, next_per_commitment_point_arg) == 33);
8789         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
8790         LDKRevokeAndACK ret = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
8791         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8792 }
8793
8794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8795         LDKUpdateFee this_ptr_conv;
8796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8797         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8798         UpdateFee_free(this_ptr_conv);
8799 }
8800
8801 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8802         LDKUpdateFee orig_conv;
8803         orig_conv.inner = (void*)(orig & (~1));
8804         orig_conv.is_owned = (orig & 1) || (orig == 0);
8805         LDKUpdateFee ret = UpdateFee_clone(&orig_conv);
8806         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8807 }
8808
8809 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8810         LDKUpdateFee this_ptr_conv;
8811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8812         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8813         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8814         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
8815         return ret_arr;
8816 }
8817
8818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8819         LDKUpdateFee this_ptr_conv;
8820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8821         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8822         LDKThirtyTwoBytes val_ref;
8823         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8824         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8825         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
8826 }
8827
8828 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
8829         LDKUpdateFee this_ptr_conv;
8830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8831         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8832         jint ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
8833         return ret_val;
8834 }
8835
8836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8837         LDKUpdateFee this_ptr_conv;
8838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8839         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8840         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
8841 }
8842
8843 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jint feerate_per_kw_arg) {
8844         LDKThirtyTwoBytes channel_id_arg_ref;
8845         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8846         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8847         LDKUpdateFee ret = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
8848         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8849 }
8850
8851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8852         LDKDataLossProtect this_ptr_conv;
8853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8854         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8855         DataLossProtect_free(this_ptr_conv);
8856 }
8857
8858 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8859         LDKDataLossProtect orig_conv;
8860         orig_conv.inner = (void*)(orig & (~1));
8861         orig_conv.is_owned = (orig & 1) || (orig == 0);
8862         LDKDataLossProtect ret = DataLossProtect_clone(&orig_conv);
8863         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8864 }
8865
8866 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
8867         LDKDataLossProtect this_ptr_conv;
8868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8869         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8870         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8871         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
8872         return ret_arr;
8873 }
8874
8875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8876         LDKDataLossProtect this_ptr_conv;
8877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8878         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8879         LDKThirtyTwoBytes val_ref;
8880         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8881         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8882         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
8883 }
8884
8885 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8886         LDKDataLossProtect this_ptr_conv;
8887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8888         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8889         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8890         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
8891         return arg_arr;
8892 }
8893
8894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8895         LDKDataLossProtect this_ptr_conv;
8896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8897         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8898         LDKPublicKey val_ref;
8899         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8900         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8901         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
8902 }
8903
8904 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) {
8905         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
8906         CHECK((*_env)->GetArrayLength (_env, your_last_per_commitment_secret_arg) == 32);
8907         (*_env)->GetByteArrayRegion (_env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
8908         LDKPublicKey my_current_per_commitment_point_arg_ref;
8909         CHECK((*_env)->GetArrayLength (_env, my_current_per_commitment_point_arg) == 33);
8910         (*_env)->GetByteArrayRegion (_env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
8911         LDKDataLossProtect ret = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
8912         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8913 }
8914
8915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8916         LDKChannelReestablish this_ptr_conv;
8917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8918         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8919         ChannelReestablish_free(this_ptr_conv);
8920 }
8921
8922 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8923         LDKChannelReestablish orig_conv;
8924         orig_conv.inner = (void*)(orig & (~1));
8925         orig_conv.is_owned = (orig & 1) || (orig == 0);
8926         LDKChannelReestablish ret = ChannelReestablish_clone(&orig_conv);
8927         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8928 }
8929
8930 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8931         LDKChannelReestablish this_ptr_conv;
8932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8933         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8934         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8935         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
8936         return ret_arr;
8937 }
8938
8939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8940         LDKChannelReestablish this_ptr_conv;
8941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8942         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8943         LDKThirtyTwoBytes val_ref;
8944         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8945         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8946         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
8947 }
8948
8949 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
8950         LDKChannelReestablish this_ptr_conv;
8951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8952         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8953         jlong ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
8954         return ret_val;
8955 }
8956
8957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8958         LDKChannelReestablish this_ptr_conv;
8959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8960         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8961         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
8962 }
8963
8964 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
8965         LDKChannelReestablish this_ptr_conv;
8966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8967         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8968         jlong ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
8969         return ret_val;
8970 }
8971
8972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8973         LDKChannelReestablish this_ptr_conv;
8974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8975         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8976         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
8977 }
8978
8979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8980         LDKAnnouncementSignatures this_ptr_conv;
8981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8982         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8983         AnnouncementSignatures_free(this_ptr_conv);
8984 }
8985
8986 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8987         LDKAnnouncementSignatures orig_conv;
8988         orig_conv.inner = (void*)(orig & (~1));
8989         orig_conv.is_owned = (orig & 1) || (orig == 0);
8990         LDKAnnouncementSignatures ret = AnnouncementSignatures_clone(&orig_conv);
8991         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8992 }
8993
8994 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8995         LDKAnnouncementSignatures this_ptr_conv;
8996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8997         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8998         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8999         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
9000         return ret_arr;
9001 }
9002
9003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9004         LDKAnnouncementSignatures this_ptr_conv;
9005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9006         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9007         LDKThirtyTwoBytes val_ref;
9008         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9009         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9010         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
9011 }
9012
9013 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9014         LDKAnnouncementSignatures this_ptr_conv;
9015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9016         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9017         jlong ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
9018         return ret_val;
9019 }
9020
9021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong 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         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
9026 }
9027
9028 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
9029         LDKAnnouncementSignatures this_ptr_conv;
9030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9031         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9032         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9033         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
9034         return arg_arr;
9035 }
9036
9037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9038         LDKAnnouncementSignatures this_ptr_conv;
9039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9040         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9041         LDKSignature val_ref;
9042         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9043         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9044         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
9045 }
9046
9047 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
9048         LDKAnnouncementSignatures this_ptr_conv;
9049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9050         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9051         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9052         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
9053         return arg_arr;
9054 }
9055
9056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9057         LDKAnnouncementSignatures this_ptr_conv;
9058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9059         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9060         LDKSignature val_ref;
9061         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9062         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9063         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
9064 }
9065
9066 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) {
9067         LDKThirtyTwoBytes channel_id_arg_ref;
9068         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
9069         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
9070         LDKSignature node_signature_arg_ref;
9071         CHECK((*_env)->GetArrayLength (_env, node_signature_arg) == 64);
9072         (*_env)->GetByteArrayRegion (_env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
9073         LDKSignature bitcoin_signature_arg_ref;
9074         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_arg) == 64);
9075         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
9076         LDKAnnouncementSignatures ret = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
9077         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9078 }
9079
9080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9081         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
9082         FREE((void*)this_ptr);
9083         NetAddress_free(this_ptr_conv);
9084 }
9085
9086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9087         LDKUnsignedNodeAnnouncement this_ptr_conv;
9088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9089         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9090         UnsignedNodeAnnouncement_free(this_ptr_conv);
9091 }
9092
9093 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9094         LDKUnsignedNodeAnnouncement orig_conv;
9095         orig_conv.inner = (void*)(orig & (~1));
9096         orig_conv.is_owned = (orig & 1) || (orig == 0);
9097         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_clone(&orig_conv);
9098         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9099 }
9100
9101 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9102         LDKUnsignedNodeAnnouncement this_ptr_conv;
9103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9104         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9105         LDKNodeFeatures ret = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
9106         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9107 }
9108
9109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9110         LDKUnsignedNodeAnnouncement this_ptr_conv;
9111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9112         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9113         LDKNodeFeatures val_conv;
9114         val_conv.inner = (void*)(val & (~1));
9115         val_conv.is_owned = (val & 1) || (val == 0);
9116         // Warning: we may need a move here but can't clone!
9117         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
9118 }
9119
9120 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
9121         LDKUnsignedNodeAnnouncement this_ptr_conv;
9122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9123         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9124         jint ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
9125         return ret_val;
9126 }
9127
9128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9129         LDKUnsignedNodeAnnouncement this_ptr_conv;
9130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9131         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9132         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
9133 }
9134
9135 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9140         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
9141         return arg_arr;
9142 }
9143
9144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9145         LDKUnsignedNodeAnnouncement this_ptr_conv;
9146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9147         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9148         LDKPublicKey val_ref;
9149         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9150         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9151         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
9152 }
9153
9154 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
9159         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
9160         return ret_arr;
9161 }
9162
9163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9164         LDKUnsignedNodeAnnouncement this_ptr_conv;
9165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9166         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9167         LDKThreeBytes val_ref;
9168         CHECK((*_env)->GetArrayLength (_env, val) == 3);
9169         (*_env)->GetByteArrayRegion (_env, val, 0, 3, val_ref.data);
9170         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
9171 }
9172
9173 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9178         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
9179         return ret_arr;
9180 }
9181
9182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9183         LDKUnsignedNodeAnnouncement this_ptr_conv;
9184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9185         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9186         LDKThirtyTwoBytes val_ref;
9187         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9188         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9189         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
9190 }
9191
9192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9193         LDKUnsignedNodeAnnouncement this_ptr_conv;
9194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9195         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9196         LDKCVec_NetAddressZ val_constr;
9197         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9198         if (val_constr.datalen > 0)
9199                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
9200         else
9201                 val_constr.data = NULL;
9202         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9203         for (size_t m = 0; m < val_constr.datalen; m++) {
9204                 long arr_conv_12 = val_vals[m];
9205                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
9206                 FREE((void*)arr_conv_12);
9207                 val_constr.data[m] = arr_conv_12_conv;
9208         }
9209         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
9210         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
9211 }
9212
9213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9214         LDKNodeAnnouncement this_ptr_conv;
9215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9216         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9217         NodeAnnouncement_free(this_ptr_conv);
9218 }
9219
9220 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9221         LDKNodeAnnouncement orig_conv;
9222         orig_conv.inner = (void*)(orig & (~1));
9223         orig_conv.is_owned = (orig & 1) || (orig == 0);
9224         LDKNodeAnnouncement ret = NodeAnnouncement_clone(&orig_conv);
9225         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9226 }
9227
9228 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9233         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
9234         return arg_arr;
9235 }
9236
9237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9238         LDKNodeAnnouncement this_ptr_conv;
9239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9240         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9241         LDKSignature val_ref;
9242         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9243         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9244         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
9245 }
9246
9247 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9248         LDKNodeAnnouncement this_ptr_conv;
9249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9250         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9251         LDKUnsignedNodeAnnouncement ret = NodeAnnouncement_get_contents(&this_ptr_conv);
9252         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9253 }
9254
9255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9256         LDKNodeAnnouncement this_ptr_conv;
9257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9258         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9259         LDKUnsignedNodeAnnouncement val_conv;
9260         val_conv.inner = (void*)(val & (~1));
9261         val_conv.is_owned = (val & 1) || (val == 0);
9262         if (val_conv.inner != NULL)
9263                 val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
9264         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
9265 }
9266
9267 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv * _env, jclass _b, jbyteArray signature_arg, jlong contents_arg) {
9268         LDKSignature signature_arg_ref;
9269         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
9270         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
9271         LDKUnsignedNodeAnnouncement contents_arg_conv;
9272         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9273         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9274         if (contents_arg_conv.inner != NULL)
9275                 contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
9276         LDKNodeAnnouncement ret = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
9277         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9278 }
9279
9280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9281         LDKUnsignedChannelAnnouncement this_ptr_conv;
9282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9283         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9284         UnsignedChannelAnnouncement_free(this_ptr_conv);
9285 }
9286
9287 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9288         LDKUnsignedChannelAnnouncement orig_conv;
9289         orig_conv.inner = (void*)(orig & (~1));
9290         orig_conv.is_owned = (orig & 1) || (orig == 0);
9291         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_clone(&orig_conv);
9292         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9293 }
9294
9295 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9296         LDKUnsignedChannelAnnouncement this_ptr_conv;
9297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9298         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9299         LDKChannelFeatures ret = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
9300         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9301 }
9302
9303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9304         LDKUnsignedChannelAnnouncement this_ptr_conv;
9305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9306         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9307         LDKChannelFeatures val_conv;
9308         val_conv.inner = (void*)(val & (~1));
9309         val_conv.is_owned = (val & 1) || (val == 0);
9310         // Warning: we may need a move here but can't clone!
9311         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
9312 }
9313
9314 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9319         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
9320         return ret_arr;
9321 }
9322
9323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9324         LDKUnsignedChannelAnnouncement this_ptr_conv;
9325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9326         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9327         LDKThirtyTwoBytes val_ref;
9328         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9329         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9330         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
9331 }
9332
9333 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9334         LDKUnsignedChannelAnnouncement this_ptr_conv;
9335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9336         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9337         jlong ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
9338         return ret_val;
9339 }
9340
9341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9342         LDKUnsignedChannelAnnouncement this_ptr_conv;
9343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9344         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9345         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
9346 }
9347
9348 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9353         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
9354         return arg_arr;
9355 }
9356
9357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9358         LDKUnsignedChannelAnnouncement this_ptr_conv;
9359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9360         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9361         LDKPublicKey val_ref;
9362         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9363         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9364         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
9365 }
9366
9367 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9372         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
9373         return arg_arr;
9374 }
9375
9376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9377         LDKUnsignedChannelAnnouncement this_ptr_conv;
9378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9379         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9380         LDKPublicKey val_ref;
9381         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9382         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9383         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
9384 }
9385
9386 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9391         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
9392         return arg_arr;
9393 }
9394
9395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9396         LDKUnsignedChannelAnnouncement this_ptr_conv;
9397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9398         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9399         LDKPublicKey val_ref;
9400         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9401         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9402         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
9403 }
9404
9405 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9410         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
9411         return arg_arr;
9412 }
9413
9414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9415         LDKUnsignedChannelAnnouncement this_ptr_conv;
9416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9417         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9418         LDKPublicKey val_ref;
9419         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9420         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9421         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
9422 }
9423
9424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9425         LDKChannelAnnouncement this_ptr_conv;
9426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9427         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9428         ChannelAnnouncement_free(this_ptr_conv);
9429 }
9430
9431 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9432         LDKChannelAnnouncement orig_conv;
9433         orig_conv.inner = (void*)(orig & (~1));
9434         orig_conv.is_owned = (orig & 1) || (orig == 0);
9435         LDKChannelAnnouncement ret = ChannelAnnouncement_clone(&orig_conv);
9436         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9437 }
9438
9439 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9444         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
9445         return arg_arr;
9446 }
9447
9448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9449         LDKChannelAnnouncement this_ptr_conv;
9450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9451         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9452         LDKSignature val_ref;
9453         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9454         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9455         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
9456 }
9457
9458 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9463         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
9464         return arg_arr;
9465 }
9466
9467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9468         LDKChannelAnnouncement this_ptr_conv;
9469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9470         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9471         LDKSignature val_ref;
9472         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9473         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9474         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
9475 }
9476
9477 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9482         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
9483         return arg_arr;
9484 }
9485
9486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9487         LDKChannelAnnouncement this_ptr_conv;
9488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9489         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9490         LDKSignature val_ref;
9491         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9492         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9493         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
9494 }
9495
9496 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9501         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
9502         return arg_arr;
9503 }
9504
9505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9506         LDKChannelAnnouncement this_ptr_conv;
9507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9508         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9509         LDKSignature val_ref;
9510         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9511         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9512         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
9513 }
9514
9515 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9516         LDKChannelAnnouncement this_ptr_conv;
9517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9518         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9519         LDKUnsignedChannelAnnouncement ret = ChannelAnnouncement_get_contents(&this_ptr_conv);
9520         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9521 }
9522
9523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9524         LDKChannelAnnouncement this_ptr_conv;
9525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9526         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9527         LDKUnsignedChannelAnnouncement val_conv;
9528         val_conv.inner = (void*)(val & (~1));
9529         val_conv.is_owned = (val & 1) || (val == 0);
9530         if (val_conv.inner != NULL)
9531                 val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
9532         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
9533 }
9534
9535 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) {
9536         LDKSignature node_signature_1_arg_ref;
9537         CHECK((*_env)->GetArrayLength (_env, node_signature_1_arg) == 64);
9538         (*_env)->GetByteArrayRegion (_env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
9539         LDKSignature node_signature_2_arg_ref;
9540         CHECK((*_env)->GetArrayLength (_env, node_signature_2_arg) == 64);
9541         (*_env)->GetByteArrayRegion (_env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
9542         LDKSignature bitcoin_signature_1_arg_ref;
9543         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_1_arg) == 64);
9544         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
9545         LDKSignature bitcoin_signature_2_arg_ref;
9546         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_2_arg) == 64);
9547         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
9548         LDKUnsignedChannelAnnouncement contents_arg_conv;
9549         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9550         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9551         if (contents_arg_conv.inner != NULL)
9552                 contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
9553         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);
9554         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9555 }
9556
9557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9558         LDKUnsignedChannelUpdate this_ptr_conv;
9559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9560         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9561         UnsignedChannelUpdate_free(this_ptr_conv);
9562 }
9563
9564 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9565         LDKUnsignedChannelUpdate orig_conv;
9566         orig_conv.inner = (void*)(orig & (~1));
9567         orig_conv.is_owned = (orig & 1) || (orig == 0);
9568         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_clone(&orig_conv);
9569         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9570 }
9571
9572 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9577         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
9578         return ret_arr;
9579 }
9580
9581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9582         LDKUnsignedChannelUpdate this_ptr_conv;
9583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9584         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9585         LDKThirtyTwoBytes val_ref;
9586         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9587         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9588         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
9589 }
9590
9591 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9592         LDKUnsignedChannelUpdate this_ptr_conv;
9593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9594         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9595         jlong ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
9596         return ret_val;
9597 }
9598
9599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9600         LDKUnsignedChannelUpdate this_ptr_conv;
9601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9602         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9603         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
9604 }
9605
9606 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
9607         LDKUnsignedChannelUpdate this_ptr_conv;
9608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9609         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9610         jint ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
9611         return ret_val;
9612 }
9613
9614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9615         LDKUnsignedChannelUpdate this_ptr_conv;
9616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9617         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9618         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
9619 }
9620
9621 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
9622         LDKUnsignedChannelUpdate this_ptr_conv;
9623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9624         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9625         jbyte ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
9626         return ret_val;
9627 }
9628
9629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
9630         LDKUnsignedChannelUpdate this_ptr_conv;
9631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9632         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9633         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
9634 }
9635
9636 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
9637         LDKUnsignedChannelUpdate this_ptr_conv;
9638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9639         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9640         jshort ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
9641         return ret_val;
9642 }
9643
9644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
9645         LDKUnsignedChannelUpdate this_ptr_conv;
9646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9647         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9648         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
9649 }
9650
9651 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9652         LDKUnsignedChannelUpdate this_ptr_conv;
9653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9654         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9655         jlong ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
9656         return ret_val;
9657 }
9658
9659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9660         LDKUnsignedChannelUpdate this_ptr_conv;
9661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9662         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9663         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
9664 }
9665
9666 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9667         LDKUnsignedChannelUpdate this_ptr_conv;
9668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9669         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9670         jint ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
9671         return ret_val;
9672 }
9673
9674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9675         LDKUnsignedChannelUpdate this_ptr_conv;
9676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9677         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9678         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
9679 }
9680
9681 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
9682         LDKUnsignedChannelUpdate this_ptr_conv;
9683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9684         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9685         jint ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
9686         return ret_val;
9687 }
9688
9689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9690         LDKUnsignedChannelUpdate this_ptr_conv;
9691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9692         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9693         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
9694 }
9695
9696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9697         LDKChannelUpdate this_ptr_conv;
9698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9699         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9700         ChannelUpdate_free(this_ptr_conv);
9701 }
9702
9703 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9704         LDKChannelUpdate orig_conv;
9705         orig_conv.inner = (void*)(orig & (~1));
9706         orig_conv.is_owned = (orig & 1) || (orig == 0);
9707         LDKChannelUpdate ret = ChannelUpdate_clone(&orig_conv);
9708         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9709 }
9710
9711 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9716         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
9717         return arg_arr;
9718 }
9719
9720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9721         LDKChannelUpdate this_ptr_conv;
9722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9723         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9724         LDKSignature val_ref;
9725         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9726         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9727         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
9728 }
9729
9730 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9731         LDKChannelUpdate this_ptr_conv;
9732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9733         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9734         LDKUnsignedChannelUpdate ret = ChannelUpdate_get_contents(&this_ptr_conv);
9735         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9736 }
9737
9738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9739         LDKChannelUpdate this_ptr_conv;
9740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9741         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9742         LDKUnsignedChannelUpdate val_conv;
9743         val_conv.inner = (void*)(val & (~1));
9744         val_conv.is_owned = (val & 1) || (val == 0);
9745         if (val_conv.inner != NULL)
9746                 val_conv = UnsignedChannelUpdate_clone(&val_conv);
9747         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
9748 }
9749
9750 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv * _env, jclass _b, jbyteArray signature_arg, jlong contents_arg) {
9751         LDKSignature signature_arg_ref;
9752         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
9753         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
9754         LDKUnsignedChannelUpdate contents_arg_conv;
9755         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9756         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9757         if (contents_arg_conv.inner != NULL)
9758                 contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
9759         LDKChannelUpdate ret = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
9760         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9761 }
9762
9763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9764         LDKQueryChannelRange this_ptr_conv;
9765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9766         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9767         QueryChannelRange_free(this_ptr_conv);
9768 }
9769
9770 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9771         LDKQueryChannelRange orig_conv;
9772         orig_conv.inner = (void*)(orig & (~1));
9773         orig_conv.is_owned = (orig & 1) || (orig == 0);
9774         LDKQueryChannelRange ret = QueryChannelRange_clone(&orig_conv);
9775         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9776 }
9777
9778 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9783         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
9784         return ret_arr;
9785 }
9786
9787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9788         LDKQueryChannelRange this_ptr_conv;
9789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9790         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9791         LDKThirtyTwoBytes val_ref;
9792         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9793         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9794         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
9795 }
9796
9797 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
9798         LDKQueryChannelRange this_ptr_conv;
9799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9800         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9801         jint ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
9802         return ret_val;
9803 }
9804
9805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9806         LDKQueryChannelRange this_ptr_conv;
9807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9808         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9809         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
9810 }
9811
9812 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
9813         LDKQueryChannelRange this_ptr_conv;
9814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9815         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9816         jint ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
9817         return ret_val;
9818 }
9819
9820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9821         LDKQueryChannelRange this_ptr_conv;
9822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9823         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9824         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
9825 }
9826
9827 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) {
9828         LDKThirtyTwoBytes chain_hash_arg_ref;
9829         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9830         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9831         LDKQueryChannelRange ret = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
9832         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9833 }
9834
9835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9836         LDKReplyChannelRange this_ptr_conv;
9837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9839         ReplyChannelRange_free(this_ptr_conv);
9840 }
9841
9842 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9843         LDKReplyChannelRange orig_conv;
9844         orig_conv.inner = (void*)(orig & (~1));
9845         orig_conv.is_owned = (orig & 1) || (orig == 0);
9846         LDKReplyChannelRange ret = ReplyChannelRange_clone(&orig_conv);
9847         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9848 }
9849
9850 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9855         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
9856         return ret_arr;
9857 }
9858
9859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9860         LDKReplyChannelRange this_ptr_conv;
9861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9862         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9863         LDKThirtyTwoBytes val_ref;
9864         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9865         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9866         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
9867 }
9868
9869 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
9870         LDKReplyChannelRange this_ptr_conv;
9871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9872         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9873         jint ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
9874         return ret_val;
9875 }
9876
9877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9878         LDKReplyChannelRange this_ptr_conv;
9879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9880         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9881         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
9882 }
9883
9884 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
9885         LDKReplyChannelRange this_ptr_conv;
9886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9887         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9888         jint ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
9889         return ret_val;
9890 }
9891
9892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9893         LDKReplyChannelRange this_ptr_conv;
9894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9895         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9896         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
9897 }
9898
9899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
9900         LDKReplyChannelRange this_ptr_conv;
9901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9902         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9903         jboolean ret_val = ReplyChannelRange_get_full_information(&this_ptr_conv);
9904         return ret_val;
9905 }
9906
9907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9908         LDKReplyChannelRange this_ptr_conv;
9909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9910         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9911         ReplyChannelRange_set_full_information(&this_ptr_conv, val);
9912 }
9913
9914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9915         LDKReplyChannelRange this_ptr_conv;
9916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9917         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9918         LDKCVec_u64Z val_constr;
9919         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9920         if (val_constr.datalen > 0)
9921                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9922         else
9923                 val_constr.data = NULL;
9924         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9925         for (size_t g = 0; g < val_constr.datalen; g++) {
9926                 long arr_conv_6 = val_vals[g];
9927                 val_constr.data[g] = arr_conv_6;
9928         }
9929         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
9930         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
9931 }
9932
9933 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) {
9934         LDKThirtyTwoBytes chain_hash_arg_ref;
9935         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9936         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9937         LDKCVec_u64Z short_channel_ids_arg_constr;
9938         short_channel_ids_arg_constr.datalen = (*_env)->GetArrayLength (_env, short_channel_ids_arg);
9939         if (short_channel_ids_arg_constr.datalen > 0)
9940                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9941         else
9942                 short_channel_ids_arg_constr.data = NULL;
9943         long* short_channel_ids_arg_vals = (*_env)->GetLongArrayElements (_env, short_channel_ids_arg, NULL);
9944         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
9945                 long arr_conv_6 = short_channel_ids_arg_vals[g];
9946                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
9947         }
9948         (*_env)->ReleaseLongArrayElements (_env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
9949         LDKReplyChannelRange ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr);
9950         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9951 }
9952
9953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9954         LDKQueryShortChannelIds this_ptr_conv;
9955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9956         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9957         QueryShortChannelIds_free(this_ptr_conv);
9958 }
9959
9960 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9961         LDKQueryShortChannelIds orig_conv;
9962         orig_conv.inner = (void*)(orig & (~1));
9963         orig_conv.is_owned = (orig & 1) || (orig == 0);
9964         LDKQueryShortChannelIds ret = QueryShortChannelIds_clone(&orig_conv);
9965         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9966 }
9967
9968 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9973         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
9974         return ret_arr;
9975 }
9976
9977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9978         LDKQueryShortChannelIds this_ptr_conv;
9979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9980         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9981         LDKThirtyTwoBytes val_ref;
9982         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9983         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9984         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
9985 }
9986
9987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9988         LDKQueryShortChannelIds this_ptr_conv;
9989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9990         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9991         LDKCVec_u64Z val_constr;
9992         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9993         if (val_constr.datalen > 0)
9994                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9995         else
9996                 val_constr.data = NULL;
9997         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9998         for (size_t g = 0; g < val_constr.datalen; g++) {
9999                 long arr_conv_6 = val_vals[g];
10000                 val_constr.data[g] = arr_conv_6;
10001         }
10002         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10003         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
10004 }
10005
10006 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlongArray short_channel_ids_arg) {
10007         LDKThirtyTwoBytes chain_hash_arg_ref;
10008         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
10009         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
10010         LDKCVec_u64Z short_channel_ids_arg_constr;
10011         short_channel_ids_arg_constr.datalen = (*_env)->GetArrayLength (_env, short_channel_ids_arg);
10012         if (short_channel_ids_arg_constr.datalen > 0)
10013                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
10014         else
10015                 short_channel_ids_arg_constr.data = NULL;
10016         long* short_channel_ids_arg_vals = (*_env)->GetLongArrayElements (_env, short_channel_ids_arg, NULL);
10017         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
10018                 long arr_conv_6 = short_channel_ids_arg_vals[g];
10019                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
10020         }
10021         (*_env)->ReleaseLongArrayElements (_env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
10022         LDKQueryShortChannelIds ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
10023         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10024 }
10025
10026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10027         LDKReplyShortChannelIdsEnd this_ptr_conv;
10028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10029         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10030         ReplyShortChannelIdsEnd_free(this_ptr_conv);
10031 }
10032
10033 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10034         LDKReplyShortChannelIdsEnd orig_conv;
10035         orig_conv.inner = (void*)(orig & (~1));
10036         orig_conv.is_owned = (orig & 1) || (orig == 0);
10037         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_clone(&orig_conv);
10038         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10039 }
10040
10041 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
10046         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
10047         return ret_arr;
10048 }
10049
10050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10051         LDKReplyShortChannelIdsEnd this_ptr_conv;
10052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10053         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10054         LDKThirtyTwoBytes val_ref;
10055         CHECK((*_env)->GetArrayLength (_env, val) == 32);
10056         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
10057         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
10058 }
10059
10060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
10061         LDKReplyShortChannelIdsEnd this_ptr_conv;
10062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10063         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10064         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
10065         return ret_val;
10066 }
10067
10068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
10069         LDKReplyShortChannelIdsEnd this_ptr_conv;
10070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10071         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10072         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
10073 }
10074
10075 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jboolean full_information_arg) {
10076         LDKThirtyTwoBytes chain_hash_arg_ref;
10077         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
10078         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
10079         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
10080         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10081 }
10082
10083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10084         LDKGossipTimestampFilter this_ptr_conv;
10085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10086         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10087         GossipTimestampFilter_free(this_ptr_conv);
10088 }
10089
10090 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10091         LDKGossipTimestampFilter orig_conv;
10092         orig_conv.inner = (void*)(orig & (~1));
10093         orig_conv.is_owned = (orig & 1) || (orig == 0);
10094         LDKGossipTimestampFilter ret = GossipTimestampFilter_clone(&orig_conv);
10095         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10096 }
10097
10098 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
10103         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
10104         return ret_arr;
10105 }
10106
10107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10108         LDKGossipTimestampFilter this_ptr_conv;
10109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10110         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10111         LDKThirtyTwoBytes val_ref;
10112         CHECK((*_env)->GetArrayLength (_env, val) == 32);
10113         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
10114         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
10115 }
10116
10117 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
10118         LDKGossipTimestampFilter this_ptr_conv;
10119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10120         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10121         jint ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
10122         return ret_val;
10123 }
10124
10125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10126         LDKGossipTimestampFilter this_ptr_conv;
10127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10128         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10129         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
10130 }
10131
10132 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr) {
10133         LDKGossipTimestampFilter this_ptr_conv;
10134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10135         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10136         jint ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
10137         return ret_val;
10138 }
10139
10140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10141         LDKGossipTimestampFilter this_ptr_conv;
10142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10143         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10144         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
10145 }
10146
10147 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) {
10148         LDKThirtyTwoBytes chain_hash_arg_ref;
10149         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
10150         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
10151         LDKGossipTimestampFilter ret = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
10152         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10153 }
10154
10155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10156         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
10157         FREE((void*)this_ptr);
10158         ErrorAction_free(this_ptr_conv);
10159 }
10160
10161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10162         LDKLightningError this_ptr_conv;
10163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10164         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10165         LightningError_free(this_ptr_conv);
10166 }
10167
10168 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) {
10169         LDKLightningError this_ptr_conv;
10170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10171         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10172         LDKStr _str = LightningError_get_err(&this_ptr_conv);
10173         char* _buf = MALLOC(_str.len + 1, "str conv buf");
10174         memcpy(_buf, _str.chars, _str.len);
10175         _buf[_str.len] = 0;
10176         jstring _conv = (*_env)->NewStringUTF(_env, _str.chars);
10177         FREE(_buf);
10178         return _conv;
10179 }
10180
10181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10182         LDKLightningError this_ptr_conv;
10183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10184         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10185         LDKCVec_u8Z val_ref;
10186         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
10187         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
10188         LightningError_set_err(&this_ptr_conv, val_ref);
10189         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
10190 }
10191
10192 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv * _env, jclass _b, jlong this_ptr) {
10193         LDKLightningError this_ptr_conv;
10194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10195         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10196         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10197         *ret = LightningError_get_action(&this_ptr_conv);
10198         return (long)ret;
10199 }
10200
10201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10202         LDKLightningError this_ptr_conv;
10203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10204         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10205         LDKErrorAction val_conv = *(LDKErrorAction*)val;
10206         FREE((void*)val);
10207         LightningError_set_action(&this_ptr_conv, val_conv);
10208 }
10209
10210 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv * _env, jclass _b, jbyteArray err_arg, jlong action_arg) {
10211         LDKCVec_u8Z err_arg_ref;
10212         err_arg_ref.data = (*_env)->GetByteArrayElements (_env, err_arg, NULL);
10213         err_arg_ref.datalen = (*_env)->GetArrayLength (_env, err_arg);
10214         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
10215         FREE((void*)action_arg);
10216         LDKLightningError ret = LightningError_new(err_arg_ref, action_arg_conv);
10217         (*_env)->ReleaseByteArrayElements(_env, err_arg, (int8_t*)err_arg_ref.data, 0);
10218         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10219 }
10220
10221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10222         LDKCommitmentUpdate this_ptr_conv;
10223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10224         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10225         CommitmentUpdate_free(this_ptr_conv);
10226 }
10227
10228 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10229         LDKCommitmentUpdate orig_conv;
10230         orig_conv.inner = (void*)(orig & (~1));
10231         orig_conv.is_owned = (orig & 1) || (orig == 0);
10232         LDKCommitmentUpdate ret = CommitmentUpdate_clone(&orig_conv);
10233         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10234 }
10235
10236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10237         LDKCommitmentUpdate this_ptr_conv;
10238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10239         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10240         LDKCVec_UpdateAddHTLCZ val_constr;
10241         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10242         if (val_constr.datalen > 0)
10243                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10244         else
10245                 val_constr.data = NULL;
10246         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10247         for (size_t p = 0; p < val_constr.datalen; p++) {
10248                 long arr_conv_15 = val_vals[p];
10249                 LDKUpdateAddHTLC arr_conv_15_conv;
10250                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10251                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10252                 if (arr_conv_15_conv.inner != NULL)
10253                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10254                 val_constr.data[p] = arr_conv_15_conv;
10255         }
10256         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10257         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
10258 }
10259
10260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10261         LDKCommitmentUpdate this_ptr_conv;
10262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10263         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10264         LDKCVec_UpdateFulfillHTLCZ val_constr;
10265         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10266         if (val_constr.datalen > 0)
10267                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10268         else
10269                 val_constr.data = NULL;
10270         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10271         for (size_t t = 0; t < val_constr.datalen; t++) {
10272                 long arr_conv_19 = val_vals[t];
10273                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10274                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
10275                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
10276                 if (arr_conv_19_conv.inner != NULL)
10277                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
10278                 val_constr.data[t] = arr_conv_19_conv;
10279         }
10280         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10281         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
10282 }
10283
10284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10285         LDKCommitmentUpdate this_ptr_conv;
10286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10287         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10288         LDKCVec_UpdateFailHTLCZ val_constr;
10289         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10290         if (val_constr.datalen > 0)
10291                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10292         else
10293                 val_constr.data = NULL;
10294         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10295         for (size_t q = 0; q < val_constr.datalen; q++) {
10296                 long arr_conv_16 = val_vals[q];
10297                 LDKUpdateFailHTLC arr_conv_16_conv;
10298                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
10299                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
10300                 if (arr_conv_16_conv.inner != NULL)
10301                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
10302                 val_constr.data[q] = arr_conv_16_conv;
10303         }
10304         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10305         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
10306 }
10307
10308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10309         LDKCommitmentUpdate this_ptr_conv;
10310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10311         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10312         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
10313         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10314         if (val_constr.datalen > 0)
10315                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10316         else
10317                 val_constr.data = NULL;
10318         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10319         for (size_t z = 0; z < val_constr.datalen; z++) {
10320                 long arr_conv_25 = val_vals[z];
10321                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
10322                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
10323                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
10324                 if (arr_conv_25_conv.inner != NULL)
10325                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
10326                 val_constr.data[z] = arr_conv_25_conv;
10327         }
10328         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10329         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
10330 }
10331
10332 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr) {
10333         LDKCommitmentUpdate this_ptr_conv;
10334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10335         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10336         LDKUpdateFee ret = CommitmentUpdate_get_update_fee(&this_ptr_conv);
10337         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10338 }
10339
10340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10341         LDKCommitmentUpdate this_ptr_conv;
10342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10343         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10344         LDKUpdateFee val_conv;
10345         val_conv.inner = (void*)(val & (~1));
10346         val_conv.is_owned = (val & 1) || (val == 0);
10347         if (val_conv.inner != NULL)
10348                 val_conv = UpdateFee_clone(&val_conv);
10349         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
10350 }
10351
10352 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr) {
10353         LDKCommitmentUpdate this_ptr_conv;
10354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10355         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10356         LDKCommitmentSigned ret = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
10357         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10358 }
10359
10360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10361         LDKCommitmentUpdate this_ptr_conv;
10362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10363         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10364         LDKCommitmentSigned val_conv;
10365         val_conv.inner = (void*)(val & (~1));
10366         val_conv.is_owned = (val & 1) || (val == 0);
10367         if (val_conv.inner != NULL)
10368                 val_conv = CommitmentSigned_clone(&val_conv);
10369         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
10370 }
10371
10372 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) {
10373         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
10374         update_add_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_add_htlcs_arg);
10375         if (update_add_htlcs_arg_constr.datalen > 0)
10376                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10377         else
10378                 update_add_htlcs_arg_constr.data = NULL;
10379         long* update_add_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_add_htlcs_arg, NULL);
10380         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
10381                 long arr_conv_15 = update_add_htlcs_arg_vals[p];
10382                 LDKUpdateAddHTLC arr_conv_15_conv;
10383                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10384                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10385                 if (arr_conv_15_conv.inner != NULL)
10386                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10387                 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
10388         }
10389         (*_env)->ReleaseLongArrayElements (_env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
10390         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
10391         update_fulfill_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fulfill_htlcs_arg);
10392         if (update_fulfill_htlcs_arg_constr.datalen > 0)
10393                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10394         else
10395                 update_fulfill_htlcs_arg_constr.data = NULL;
10396         long* update_fulfill_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fulfill_htlcs_arg, NULL);
10397         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
10398                 long arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
10399                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10400                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
10401                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
10402                 if (arr_conv_19_conv.inner != NULL)
10403                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
10404                 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
10405         }
10406         (*_env)->ReleaseLongArrayElements (_env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
10407         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
10408         update_fail_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fail_htlcs_arg);
10409         if (update_fail_htlcs_arg_constr.datalen > 0)
10410                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10411         else
10412                 update_fail_htlcs_arg_constr.data = NULL;
10413         long* update_fail_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fail_htlcs_arg, NULL);
10414         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
10415                 long arr_conv_16 = update_fail_htlcs_arg_vals[q];
10416                 LDKUpdateFailHTLC arr_conv_16_conv;
10417                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
10418                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
10419                 if (arr_conv_16_conv.inner != NULL)
10420                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
10421                 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
10422         }
10423         (*_env)->ReleaseLongArrayElements (_env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
10424         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
10425         update_fail_malformed_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fail_malformed_htlcs_arg);
10426         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
10427                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10428         else
10429                 update_fail_malformed_htlcs_arg_constr.data = NULL;
10430         long* update_fail_malformed_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fail_malformed_htlcs_arg, NULL);
10431         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
10432                 long arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
10433                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
10434                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
10435                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
10436                 if (arr_conv_25_conv.inner != NULL)
10437                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
10438                 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
10439         }
10440         (*_env)->ReleaseLongArrayElements (_env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
10441         LDKUpdateFee update_fee_arg_conv;
10442         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
10443         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
10444         if (update_fee_arg_conv.inner != NULL)
10445                 update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
10446         LDKCommitmentSigned commitment_signed_arg_conv;
10447         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
10448         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
10449         if (commitment_signed_arg_conv.inner != NULL)
10450                 commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
10451         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);
10452         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10453 }
10454
10455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10456         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
10457         FREE((void*)this_ptr);
10458         HTLCFailChannelUpdate_free(this_ptr_conv);
10459 }
10460
10461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10462         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
10463         FREE((void*)this_ptr);
10464         ChannelMessageHandler_free(this_ptr_conv);
10465 }
10466
10467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10468         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
10469         FREE((void*)this_ptr);
10470         RoutingMessageHandler_free(this_ptr_conv);
10471 }
10472
10473 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
10474         LDKAcceptChannel obj_conv;
10475         obj_conv.inner = (void*)(obj & (~1));
10476         obj_conv.is_owned = (obj & 1) || (obj == 0);
10477         LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
10478         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10479         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10480         return arg_arr;
10481 }
10482
10483 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10484         LDKu8slice ser_ref;
10485         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10486         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10487         LDKAcceptChannel ret = AcceptChannel_read(ser_ref);
10488         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10489         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10490 }
10491
10492 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv * _env, jclass _b, jlong obj) {
10493         LDKAnnouncementSignatures obj_conv;
10494         obj_conv.inner = (void*)(obj & (~1));
10495         obj_conv.is_owned = (obj & 1) || (obj == 0);
10496         LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
10497         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10498         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10499         return arg_arr;
10500 }
10501
10502 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10503         LDKu8slice ser_ref;
10504         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10505         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10506         LDKAnnouncementSignatures ret = AnnouncementSignatures_read(ser_ref);
10507         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10508         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10509 }
10510
10511 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv * _env, jclass _b, jlong obj) {
10512         LDKChannelReestablish obj_conv;
10513         obj_conv.inner = (void*)(obj & (~1));
10514         obj_conv.is_owned = (obj & 1) || (obj == 0);
10515         LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
10516         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10517         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10518         return arg_arr;
10519 }
10520
10521 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10522         LDKu8slice ser_ref;
10523         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10524         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10525         LDKChannelReestablish ret = ChannelReestablish_read(ser_ref);
10526         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10527         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10528 }
10529
10530 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10531         LDKClosingSigned obj_conv;
10532         obj_conv.inner = (void*)(obj & (~1));
10533         obj_conv.is_owned = (obj & 1) || (obj == 0);
10534         LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
10535         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10536         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10537         return arg_arr;
10538 }
10539
10540 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10541         LDKu8slice ser_ref;
10542         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10543         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10544         LDKClosingSigned ret = ClosingSigned_read(ser_ref);
10545         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10546         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10547 }
10548
10549 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10550         LDKCommitmentSigned obj_conv;
10551         obj_conv.inner = (void*)(obj & (~1));
10552         obj_conv.is_owned = (obj & 1) || (obj == 0);
10553         LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
10554         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10555         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10556         return arg_arr;
10557 }
10558
10559 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10560         LDKu8slice ser_ref;
10561         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10562         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10563         LDKCommitmentSigned ret = CommitmentSigned_read(ser_ref);
10564         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10565         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10566 }
10567
10568 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv * _env, jclass _b, jlong obj) {
10569         LDKFundingCreated obj_conv;
10570         obj_conv.inner = (void*)(obj & (~1));
10571         obj_conv.is_owned = (obj & 1) || (obj == 0);
10572         LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
10573         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10574         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10575         return arg_arr;
10576 }
10577
10578 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10579         LDKu8slice ser_ref;
10580         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10581         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10582         LDKFundingCreated ret = FundingCreated_read(ser_ref);
10583         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10584         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10585 }
10586
10587 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10588         LDKFundingSigned obj_conv;
10589         obj_conv.inner = (void*)(obj & (~1));
10590         obj_conv.is_owned = (obj & 1) || (obj == 0);
10591         LDKCVec_u8Z arg_var = FundingSigned_write(&obj_conv);
10592         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10593         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10594         return arg_arr;
10595 }
10596
10597 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10598         LDKu8slice ser_ref;
10599         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10600         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10601         LDKFundingSigned ret = FundingSigned_read(ser_ref);
10602         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10603         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10604 }
10605
10606 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv * _env, jclass _b, jlong obj) {
10607         LDKFundingLocked obj_conv;
10608         obj_conv.inner = (void*)(obj & (~1));
10609         obj_conv.is_owned = (obj & 1) || (obj == 0);
10610         LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
10611         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10612         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10613         return arg_arr;
10614 }
10615
10616 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10617         LDKu8slice ser_ref;
10618         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10619         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10620         LDKFundingLocked ret = FundingLocked_read(ser_ref);
10621         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10622         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10623 }
10624
10625 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv * _env, jclass _b, jlong obj) {
10626         LDKInit obj_conv;
10627         obj_conv.inner = (void*)(obj & (~1));
10628         obj_conv.is_owned = (obj & 1) || (obj == 0);
10629         LDKCVec_u8Z arg_var = Init_write(&obj_conv);
10630         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10631         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10632         return arg_arr;
10633 }
10634
10635 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10636         LDKu8slice ser_ref;
10637         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10638         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10639         LDKInit ret = Init_read(ser_ref);
10640         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10641         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10642 }
10643
10644 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
10645         LDKOpenChannel obj_conv;
10646         obj_conv.inner = (void*)(obj & (~1));
10647         obj_conv.is_owned = (obj & 1) || (obj == 0);
10648         LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
10649         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10650         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10651         return arg_arr;
10652 }
10653
10654 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10655         LDKu8slice ser_ref;
10656         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10657         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10658         LDKOpenChannel ret = OpenChannel_read(ser_ref);
10659         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10660         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10661 }
10662
10663 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv * _env, jclass _b, jlong obj) {
10664         LDKRevokeAndACK obj_conv;
10665         obj_conv.inner = (void*)(obj & (~1));
10666         obj_conv.is_owned = (obj & 1) || (obj == 0);
10667         LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
10668         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10669         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10670         return arg_arr;
10671 }
10672
10673 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10674         LDKu8slice ser_ref;
10675         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10676         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10677         LDKRevokeAndACK ret = RevokeAndACK_read(ser_ref);
10678         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10679         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10680 }
10681
10682 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv * _env, jclass _b, jlong obj) {
10683         LDKShutdown obj_conv;
10684         obj_conv.inner = (void*)(obj & (~1));
10685         obj_conv.is_owned = (obj & 1) || (obj == 0);
10686         LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
10687         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10688         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10689         return arg_arr;
10690 }
10691
10692 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10693         LDKu8slice ser_ref;
10694         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10695         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10696         LDKShutdown ret = Shutdown_read(ser_ref);
10697         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10698         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10699 }
10700
10701 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10702         LDKUpdateFailHTLC obj_conv;
10703         obj_conv.inner = (void*)(obj & (~1));
10704         obj_conv.is_owned = (obj & 1) || (obj == 0);
10705         LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
10706         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10707         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10708         return arg_arr;
10709 }
10710
10711 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10712         LDKu8slice ser_ref;
10713         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10714         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10715         LDKUpdateFailHTLC ret = UpdateFailHTLC_read(ser_ref);
10716         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10717         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10718 }
10719
10720 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10721         LDKUpdateFailMalformedHTLC obj_conv;
10722         obj_conv.inner = (void*)(obj & (~1));
10723         obj_conv.is_owned = (obj & 1) || (obj == 0);
10724         LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
10725         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10726         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10727         return arg_arr;
10728 }
10729
10730 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10731         LDKu8slice ser_ref;
10732         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10733         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10734         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_read(ser_ref);
10735         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10736         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10737 }
10738
10739 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv * _env, jclass _b, jlong obj) {
10740         LDKUpdateFee obj_conv;
10741         obj_conv.inner = (void*)(obj & (~1));
10742         obj_conv.is_owned = (obj & 1) || (obj == 0);
10743         LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
10744         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10745         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10746         return arg_arr;
10747 }
10748
10749 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_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         LDKUpdateFee ret = UpdateFee_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_UpdateFulfillHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10759         LDKUpdateFulfillHTLC obj_conv;
10760         obj_conv.inner = (void*)(obj & (~1));
10761         obj_conv.is_owned = (obj & 1) || (obj == 0);
10762         LDKCVec_u8Z arg_var = UpdateFulfillHTLC_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         return arg_arr;
10766 }
10767
10768 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10769         LDKu8slice ser_ref;
10770         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10771         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10772         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_read(ser_ref);
10773         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10774         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10775 }
10776
10777 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10778         LDKUpdateAddHTLC obj_conv;
10779         obj_conv.inner = (void*)(obj & (~1));
10780         obj_conv.is_owned = (obj & 1) || (obj == 0);
10781         LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
10782         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10783         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10784         return arg_arr;
10785 }
10786
10787 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10788         LDKu8slice ser_ref;
10789         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10790         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10791         LDKUpdateAddHTLC ret = UpdateAddHTLC_read(ser_ref);
10792         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10793         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10794 }
10795
10796 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv * _env, jclass _b, jlong obj) {
10797         LDKPing obj_conv;
10798         obj_conv.inner = (void*)(obj & (~1));
10799         obj_conv.is_owned = (obj & 1) || (obj == 0);
10800         LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
10801         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10802         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10803         return arg_arr;
10804 }
10805
10806 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10807         LDKu8slice ser_ref;
10808         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10809         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10810         LDKPing ret = Ping_read(ser_ref);
10811         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10812         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10813 }
10814
10815 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv * _env, jclass _b, jlong obj) {
10816         LDKPong obj_conv;
10817         obj_conv.inner = (void*)(obj & (~1));
10818         obj_conv.is_owned = (obj & 1) || (obj == 0);
10819         LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
10820         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10821         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10822         return arg_arr;
10823 }
10824
10825 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10826         LDKu8slice ser_ref;
10827         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10828         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10829         LDKPong ret = Pong_read(ser_ref);
10830         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10831         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10832 }
10833
10834 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10835         LDKUnsignedChannelAnnouncement obj_conv;
10836         obj_conv.inner = (void*)(obj & (~1));
10837         obj_conv.is_owned = (obj & 1) || (obj == 0);
10838         LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_write(&obj_conv);
10839         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10840         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10841         return arg_arr;
10842 }
10843
10844 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10845         LDKu8slice ser_ref;
10846         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10847         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10848         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_read(ser_ref);
10849         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10850         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10851 }
10852
10853 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10854         LDKChannelAnnouncement obj_conv;
10855         obj_conv.inner = (void*)(obj & (~1));
10856         obj_conv.is_owned = (obj & 1) || (obj == 0);
10857         LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
10858         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10859         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10860         return arg_arr;
10861 }
10862
10863 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10864         LDKu8slice ser_ref;
10865         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10866         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10867         LDKChannelAnnouncement ret = ChannelAnnouncement_read(ser_ref);
10868         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10869         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10870 }
10871
10872 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
10873         LDKUnsignedChannelUpdate obj_conv;
10874         obj_conv.inner = (void*)(obj & (~1));
10875         obj_conv.is_owned = (obj & 1) || (obj == 0);
10876         LDKCVec_u8Z arg_var = UnsignedChannelUpdate_write(&obj_conv);
10877         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10878         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10879         return arg_arr;
10880 }
10881
10882 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10883         LDKu8slice ser_ref;
10884         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10885         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10886         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_read(ser_ref);
10887         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10888         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10889 }
10890
10891 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
10892         LDKChannelUpdate obj_conv;
10893         obj_conv.inner = (void*)(obj & (~1));
10894         obj_conv.is_owned = (obj & 1) || (obj == 0);
10895         LDKCVec_u8Z arg_var = ChannelUpdate_write(&obj_conv);
10896         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10897         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10898         return arg_arr;
10899 }
10900
10901 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10902         LDKu8slice ser_ref;
10903         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10904         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10905         LDKChannelUpdate ret = ChannelUpdate_read(ser_ref);
10906         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10907         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10908 }
10909
10910 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv * _env, jclass _b, jlong obj) {
10911         LDKErrorMessage obj_conv;
10912         obj_conv.inner = (void*)(obj & (~1));
10913         obj_conv.is_owned = (obj & 1) || (obj == 0);
10914         LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
10915         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10916         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10917         return arg_arr;
10918 }
10919
10920 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10921         LDKu8slice ser_ref;
10922         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10923         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10924         LDKErrorMessage ret = ErrorMessage_read(ser_ref);
10925         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10926         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10927 }
10928
10929 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10930         LDKUnsignedNodeAnnouncement obj_conv;
10931         obj_conv.inner = (void*)(obj & (~1));
10932         obj_conv.is_owned = (obj & 1) || (obj == 0);
10933         LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_write(&obj_conv);
10934         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10935         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10936         return arg_arr;
10937 }
10938
10939 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10940         LDKu8slice ser_ref;
10941         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10942         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10943         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_read(ser_ref);
10944         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10945         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10946 }
10947
10948 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10949         LDKNodeAnnouncement obj_conv;
10950         obj_conv.inner = (void*)(obj & (~1));
10951         obj_conv.is_owned = (obj & 1) || (obj == 0);
10952         LDKCVec_u8Z arg_var = NodeAnnouncement_write(&obj_conv);
10953         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10954         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10955         return arg_arr;
10956 }
10957
10958 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10959         LDKu8slice ser_ref;
10960         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10961         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10962         LDKNodeAnnouncement ret = NodeAnnouncement_read(ser_ref);
10963         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10964         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10965 }
10966
10967 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10968         LDKu8slice ser_ref;
10969         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10970         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10971         LDKQueryShortChannelIds ret = QueryShortChannelIds_read(ser_ref);
10972         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10973         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10974 }
10975
10976 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv * _env, jclass _b, jlong obj) {
10977         LDKQueryShortChannelIds obj_conv;
10978         obj_conv.inner = (void*)(obj & (~1));
10979         obj_conv.is_owned = (obj & 1) || (obj == 0);
10980         LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
10981         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10982         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10983         return arg_arr;
10984 }
10985
10986 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10987         LDKu8slice ser_ref;
10988         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10989         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10990         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_read(ser_ref);
10991         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10992         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10993 }
10994
10995 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv * _env, jclass _b, jlong obj) {
10996         LDKReplyShortChannelIdsEnd obj_conv;
10997         obj_conv.inner = (void*)(obj & (~1));
10998         obj_conv.is_owned = (obj & 1) || (obj == 0);
10999         LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
11000         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11001         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11002         return arg_arr;
11003 }
11004
11005 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11006         LDKu8slice ser_ref;
11007         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11008         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11009         LDKQueryChannelRange ret = QueryChannelRange_read(ser_ref);
11010         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11011         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11012 }
11013
11014 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
11015         LDKQueryChannelRange obj_conv;
11016         obj_conv.inner = (void*)(obj & (~1));
11017         obj_conv.is_owned = (obj & 1) || (obj == 0);
11018         LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
11019         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11020         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11021         return arg_arr;
11022 }
11023
11024 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11025         LDKu8slice ser_ref;
11026         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11027         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11028         LDKReplyChannelRange ret = ReplyChannelRange_read(ser_ref);
11029         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11030         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11031 }
11032
11033 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
11034         LDKReplyChannelRange obj_conv;
11035         obj_conv.inner = (void*)(obj & (~1));
11036         obj_conv.is_owned = (obj & 1) || (obj == 0);
11037         LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
11038         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11039         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11040         return arg_arr;
11041 }
11042
11043 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11044         LDKu8slice ser_ref;
11045         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11046         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11047         LDKGossipTimestampFilter ret = GossipTimestampFilter_read(ser_ref);
11048         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11049         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11050 }
11051
11052 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv * _env, jclass _b, jlong obj) {
11053         LDKGossipTimestampFilter obj_conv;
11054         obj_conv.inner = (void*)(obj & (~1));
11055         obj_conv.is_owned = (obj & 1) || (obj == 0);
11056         LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
11057         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11058         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11059         return arg_arr;
11060 }
11061
11062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11063         LDKMessageHandler this_ptr_conv;
11064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11065         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11066         MessageHandler_free(this_ptr_conv);
11067 }
11068
11069 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
11070         LDKMessageHandler this_ptr_conv;
11071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11072         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11073         long ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
11074         return ret;
11075 }
11076
11077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11078         LDKMessageHandler this_ptr_conv;
11079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11080         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11081         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
11082         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
11083                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11084                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
11085         }
11086         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
11087 }
11088
11089 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
11090         LDKMessageHandler this_ptr_conv;
11091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11092         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11093         long ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
11094         return ret;
11095 }
11096
11097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11098         LDKMessageHandler this_ptr_conv;
11099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11100         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11101         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
11102         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11103                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11104                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
11105         }
11106         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
11107 }
11108
11109 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv * _env, jclass _b, jlong chan_handler_arg, jlong route_handler_arg) {
11110         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
11111         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
11112                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11113                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
11114         }
11115         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
11116         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11117                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11118                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
11119         }
11120         LDKMessageHandler ret = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
11121         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11122 }
11123
11124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11125         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
11126         FREE((void*)this_ptr);
11127         SocketDescriptor_free(this_ptr_conv);
11128 }
11129
11130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11131         LDKPeerHandleError this_ptr_conv;
11132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11133         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11134         PeerHandleError_free(this_ptr_conv);
11135 }
11136
11137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr) {
11138         LDKPeerHandleError this_ptr_conv;
11139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11140         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11141         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
11142         return ret_val;
11143 }
11144
11145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
11146         LDKPeerHandleError this_ptr_conv;
11147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11148         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11149         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
11150 }
11151
11152 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv * _env, jclass _b, jboolean no_connection_possible_arg) {
11153         LDKPeerHandleError ret = PeerHandleError_new(no_connection_possible_arg);
11154         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11155 }
11156
11157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11158         LDKPeerManager this_ptr_conv;
11159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11160         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11161         PeerManager_free(this_ptr_conv);
11162 }
11163
11164 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) {
11165         LDKMessageHandler message_handler_conv;
11166         message_handler_conv.inner = (void*)(message_handler & (~1));
11167         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
11168         // Warning: we may need a move here but can't clone!
11169         LDKSecretKey our_node_secret_ref;
11170         CHECK((*_env)->GetArrayLength (_env, our_node_secret) == 32);
11171         (*_env)->GetByteArrayRegion (_env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
11172         unsigned char ephemeral_random_data_arr[32];
11173         CHECK((*_env)->GetArrayLength (_env, ephemeral_random_data) == 32);
11174         (*_env)->GetByteArrayRegion (_env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
11175         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
11176         LDKLogger logger_conv = *(LDKLogger*)logger;
11177         if (logger_conv.free == LDKLogger_JCalls_free) {
11178                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11179                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11180         }
11181         LDKPeerManager ret = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
11182         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11183 }
11184
11185 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) {
11186         LDKPeerManager this_arg_conv;
11187         this_arg_conv.inner = (void*)(this_arg & (~1));
11188         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11189         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
11190         jobjectArray ret_arr = (*_env)->NewObjectArray(_env, ret_var.datalen, NULL, NULL);
11191         for (size_t i = 0; i < ret_var.datalen; i++) {
11192                 jbyteArray arr_conv_8_arr = (*_env)->NewByteArray(_env, 33);
11193                 (*_env)->SetByteArrayRegion(_env, arr_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
11194                 (*_env)->SetObjectArrayElement(_env, ret_arr, i, arr_conv_8_arr);}
11195         return ret_arr;
11196 }
11197
11198 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) {
11199         LDKPeerManager this_arg_conv;
11200         this_arg_conv.inner = (void*)(this_arg & (~1));
11201         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11202         LDKPublicKey their_node_id_ref;
11203         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
11204         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11205         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
11206         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
11207                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11208                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
11209         }
11210         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11211         *ret = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
11212         return (long)ret;
11213 }
11214
11215 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
11216         LDKPeerManager this_arg_conv;
11217         this_arg_conv.inner = (void*)(this_arg & (~1));
11218         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11219         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
11220         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
11221                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11222                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
11223         }
11224         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11225         *ret = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
11226         return (long)ret;
11227 }
11228
11229 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
11230         LDKPeerManager this_arg_conv;
11231         this_arg_conv.inner = (void*)(this_arg & (~1));
11232         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11233         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
11234         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11235         *ret = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
11236         return (long)ret;
11237 }
11238
11239 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv * _env, jclass _b, jlong this_arg, jlong peer_descriptor, jbyteArray data) {
11240         LDKPeerManager this_arg_conv;
11241         this_arg_conv.inner = (void*)(this_arg & (~1));
11242         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11243         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
11244         LDKu8slice data_ref;
11245         data_ref.data = (*_env)->GetByteArrayElements (_env, data, NULL);
11246         data_ref.datalen = (*_env)->GetArrayLength (_env, data);
11247         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11248         *ret = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
11249         (*_env)->ReleaseByteArrayElements(_env, data, (int8_t*)data_ref.data, 0);
11250         return (long)ret;
11251 }
11252
11253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
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         PeerManager_process_events(&this_arg_conv);
11258 }
11259
11260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
11261         LDKPeerManager this_arg_conv;
11262         this_arg_conv.inner = (void*)(this_arg & (~1));
11263         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11264         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
11265         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
11266 }
11267
11268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv * _env, jclass _b, jlong this_arg) {
11269         LDKPeerManager this_arg_conv;
11270         this_arg_conv.inner = (void*)(this_arg & (~1));
11271         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11272         PeerManager_timer_tick_occured(&this_arg_conv);
11273 }
11274
11275 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv * _env, jclass _b, jbyteArray commitment_seed, jlong idx) {
11276         unsigned char commitment_seed_arr[32];
11277         CHECK((*_env)->GetArrayLength (_env, commitment_seed) == 32);
11278         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_arr);
11279         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
11280         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
11281         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
11282         return arg_arr;
11283 }
11284
11285 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_secret) {
11286         LDKPublicKey per_commitment_point_ref;
11287         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11288         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11289         unsigned char base_secret_arr[32];
11290         CHECK((*_env)->GetArrayLength (_env, base_secret) == 32);
11291         (*_env)->GetByteArrayRegion (_env, base_secret, 0, 32, base_secret_arr);
11292         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
11293         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
11294         *ret = derive_private_key(per_commitment_point_ref, base_secret_ref);
11295         return (long)ret;
11296 }
11297
11298 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_point) {
11299         LDKPublicKey per_commitment_point_ref;
11300         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11301         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11302         LDKPublicKey base_point_ref;
11303         CHECK((*_env)->GetArrayLength (_env, base_point) == 33);
11304         (*_env)->GetByteArrayRegion (_env, base_point, 0, 33, base_point_ref.compressed_form);
11305         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
11306         *ret = derive_public_key(per_commitment_point_ref, base_point_ref);
11307         return (long)ret;
11308 }
11309
11310 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) {
11311         unsigned char per_commitment_secret_arr[32];
11312         CHECK((*_env)->GetArrayLength (_env, per_commitment_secret) == 32);
11313         (*_env)->GetByteArrayRegion (_env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
11314         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
11315         unsigned char countersignatory_revocation_base_secret_arr[32];
11316         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base_secret) == 32);
11317         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
11318         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
11319         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
11320         *ret = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
11321         return (long)ret;
11322 }
11323
11324 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) {
11325         LDKPublicKey per_commitment_point_ref;
11326         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11327         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11328         LDKPublicKey countersignatory_revocation_base_point_ref;
11329         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base_point) == 33);
11330         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
11331         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
11332         *ret = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
11333         return (long)ret;
11334 }
11335
11336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11337         LDKTxCreationKeys this_ptr_conv;
11338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11339         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11340         TxCreationKeys_free(this_ptr_conv);
11341 }
11342
11343 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11344         LDKTxCreationKeys orig_conv;
11345         orig_conv.inner = (void*)(orig & (~1));
11346         orig_conv.is_owned = (orig & 1) || (orig == 0);
11347         LDKTxCreationKeys ret = TxCreationKeys_clone(&orig_conv);
11348         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11349 }
11350
11351 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
11352         LDKTxCreationKeys this_ptr_conv;
11353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11354         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11355         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11356         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
11357         return arg_arr;
11358 }
11359
11360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11361         LDKTxCreationKeys this_ptr_conv;
11362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11363         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11364         LDKPublicKey val_ref;
11365         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11366         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11367         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
11368 }
11369
11370 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11371         LDKTxCreationKeys this_ptr_conv;
11372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11373         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11374         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11375         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
11376         return arg_arr;
11377 }
11378
11379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11380         LDKTxCreationKeys this_ptr_conv;
11381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11382         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11383         LDKPublicKey val_ref;
11384         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11385         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11386         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
11387 }
11388
11389 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(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_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
11395         return arg_arr;
11396 }
11397
11398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(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_broadcaster_htlc_key(&this_ptr_conv, val_ref);
11406 }
11407
11408 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_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_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
11414         return arg_arr;
11415 }
11416
11417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_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_countersignatory_htlc_key(&this_ptr_conv, val_ref);
11425 }
11426
11427 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_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_delayed_payment_key(&this_ptr_conv).compressed_form);
11433         return arg_arr;
11434 }
11435
11436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_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_delayed_payment_key(&this_ptr_conv, val_ref);
11444 }
11445
11446 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) {
11447         LDKPublicKey per_commitment_point_arg_ref;
11448         CHECK((*_env)->GetArrayLength (_env, per_commitment_point_arg) == 33);
11449         (*_env)->GetByteArrayRegion (_env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
11450         LDKPublicKey revocation_key_arg_ref;
11451         CHECK((*_env)->GetArrayLength (_env, revocation_key_arg) == 33);
11452         (*_env)->GetByteArrayRegion (_env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
11453         LDKPublicKey broadcaster_htlc_key_arg_ref;
11454         CHECK((*_env)->GetArrayLength (_env, broadcaster_htlc_key_arg) == 33);
11455         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
11456         LDKPublicKey countersignatory_htlc_key_arg_ref;
11457         CHECK((*_env)->GetArrayLength (_env, countersignatory_htlc_key_arg) == 33);
11458         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
11459         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
11460         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key_arg) == 33);
11461         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
11462         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);
11463         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11464 }
11465
11466 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
11467         LDKTxCreationKeys obj_conv;
11468         obj_conv.inner = (void*)(obj & (~1));
11469         obj_conv.is_owned = (obj & 1) || (obj == 0);
11470         LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
11471         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11472         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11473         return arg_arr;
11474 }
11475
11476 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11477         LDKu8slice ser_ref;
11478         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11479         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11480         LDKTxCreationKeys ret = TxCreationKeys_read(ser_ref);
11481         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11482         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11483 }
11484
11485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11486         LDKPreCalculatedTxCreationKeys this_ptr_conv;
11487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11488         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11489         PreCalculatedTxCreationKeys_free(this_ptr_conv);
11490 }
11491
11492 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1new(JNIEnv * _env, jclass _b, jlong keys) {
11493         LDKTxCreationKeys keys_conv;
11494         keys_conv.inner = (void*)(keys & (~1));
11495         keys_conv.is_owned = (keys & 1) || (keys == 0);
11496         if (keys_conv.inner != NULL)
11497                 keys_conv = TxCreationKeys_clone(&keys_conv);
11498         LDKPreCalculatedTxCreationKeys ret = PreCalculatedTxCreationKeys_new(keys_conv);
11499         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11500 }
11501
11502 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
11503         LDKPreCalculatedTxCreationKeys this_arg_conv;
11504         this_arg_conv.inner = (void*)(this_arg & (~1));
11505         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11506         LDKTxCreationKeys ret = PreCalculatedTxCreationKeys_trust_key_derivation(&this_arg_conv);
11507         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11508 }
11509
11510 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg) {
11511         LDKPreCalculatedTxCreationKeys this_arg_conv;
11512         this_arg_conv.inner = (void*)(this_arg & (~1));
11513         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11514         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11515         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, PreCalculatedTxCreationKeys_per_commitment_point(&this_arg_conv).compressed_form);
11516         return arg_arr;
11517 }
11518
11519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11520         LDKChannelPublicKeys this_ptr_conv;
11521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11522         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11523         ChannelPublicKeys_free(this_ptr_conv);
11524 }
11525
11526 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11527         LDKChannelPublicKeys orig_conv;
11528         orig_conv.inner = (void*)(orig & (~1));
11529         orig_conv.is_owned = (orig & 1) || (orig == 0);
11530         LDKChannelPublicKeys ret = ChannelPublicKeys_clone(&orig_conv);
11531         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11532 }
11533
11534 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
11535         LDKChannelPublicKeys this_ptr_conv;
11536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11537         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11538         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11539         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
11540         return arg_arr;
11541 }
11542
11543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11544         LDKChannelPublicKeys this_ptr_conv;
11545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11546         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11547         LDKPublicKey val_ref;
11548         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11549         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11550         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
11551 }
11552
11553 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
11554         LDKChannelPublicKeys this_ptr_conv;
11555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11556         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11557         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11558         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
11559         return arg_arr;
11560 }
11561
11562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11563         LDKChannelPublicKeys this_ptr_conv;
11564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11565         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11566         LDKPublicKey val_ref;
11567         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11568         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11569         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
11570 }
11571
11572 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
11573         LDKChannelPublicKeys this_ptr_conv;
11574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11575         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11576         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11577         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
11578         return arg_arr;
11579 }
11580
11581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11582         LDKChannelPublicKeys this_ptr_conv;
11583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11584         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11585         LDKPublicKey val_ref;
11586         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11587         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11588         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
11589 }
11590
11591 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
11592         LDKChannelPublicKeys this_ptr_conv;
11593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11594         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11595         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11596         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
11597         return arg_arr;
11598 }
11599
11600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11601         LDKChannelPublicKeys this_ptr_conv;
11602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11603         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11604         LDKPublicKey val_ref;
11605         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11606         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11607         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
11608 }
11609
11610 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
11611         LDKChannelPublicKeys this_ptr_conv;
11612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11613         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11614         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11615         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
11616         return arg_arr;
11617 }
11618
11619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11620         LDKChannelPublicKeys this_ptr_conv;
11621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11622         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11623         LDKPublicKey val_ref;
11624         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11625         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11626         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
11627 }
11628
11629 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) {
11630         LDKPublicKey funding_pubkey_arg_ref;
11631         CHECK((*_env)->GetArrayLength (_env, funding_pubkey_arg) == 33);
11632         (*_env)->GetByteArrayRegion (_env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
11633         LDKPublicKey revocation_basepoint_arg_ref;
11634         CHECK((*_env)->GetArrayLength (_env, revocation_basepoint_arg) == 33);
11635         (*_env)->GetByteArrayRegion (_env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
11636         LDKPublicKey payment_point_arg_ref;
11637         CHECK((*_env)->GetArrayLength (_env, payment_point_arg) == 33);
11638         (*_env)->GetByteArrayRegion (_env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
11639         LDKPublicKey delayed_payment_basepoint_arg_ref;
11640         CHECK((*_env)->GetArrayLength (_env, delayed_payment_basepoint_arg) == 33);
11641         (*_env)->GetByteArrayRegion (_env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
11642         LDKPublicKey htlc_basepoint_arg_ref;
11643         CHECK((*_env)->GetArrayLength (_env, htlc_basepoint_arg) == 33);
11644         (*_env)->GetByteArrayRegion (_env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
11645         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);
11646         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11647 }
11648
11649 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
11650         LDKChannelPublicKeys obj_conv;
11651         obj_conv.inner = (void*)(obj & (~1));
11652         obj_conv.is_owned = (obj & 1) || (obj == 0);
11653         LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
11654         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11655         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11656         return arg_arr;
11657 }
11658
11659 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11660         LDKu8slice ser_ref;
11661         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11662         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11663         LDKChannelPublicKeys ret = ChannelPublicKeys_read(ser_ref);
11664         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11665         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11666 }
11667
11668 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) {
11669         LDKPublicKey per_commitment_point_ref;
11670         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11671         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11672         LDKPublicKey broadcaster_delayed_payment_base_ref;
11673         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_base) == 33);
11674         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
11675         LDKPublicKey broadcaster_htlc_base_ref;
11676         CHECK((*_env)->GetArrayLength (_env, broadcaster_htlc_base) == 33);
11677         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
11678         LDKPublicKey countersignatory_revocation_base_ref;
11679         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base) == 33);
11680         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
11681         LDKPublicKey countersignatory_htlc_base_ref;
11682         CHECK((*_env)->GetArrayLength (_env, countersignatory_htlc_base) == 33);
11683         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
11684         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
11685         *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);
11686         return (long)ret;
11687 }
11688
11689 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) {
11690         LDKPublicKey revocation_key_ref;
11691         CHECK((*_env)->GetArrayLength (_env, revocation_key) == 33);
11692         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
11693         LDKPublicKey broadcaster_delayed_payment_key_ref;
11694         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key) == 33);
11695         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
11696         LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
11697         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11698         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11699         return arg_arr;
11700 }
11701
11702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11703         LDKHTLCOutputInCommitment this_ptr_conv;
11704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11705         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11706         HTLCOutputInCommitment_free(this_ptr_conv);
11707 }
11708
11709 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11710         LDKHTLCOutputInCommitment orig_conv;
11711         orig_conv.inner = (void*)(orig & (~1));
11712         orig_conv.is_owned = (orig & 1) || (orig == 0);
11713         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_clone(&orig_conv);
11714         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11715 }
11716
11717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv * _env, jclass _b, jlong this_ptr) {
11718         LDKHTLCOutputInCommitment this_ptr_conv;
11719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11720         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11721         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
11722         return ret_val;
11723 }
11724
11725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
11726         LDKHTLCOutputInCommitment this_ptr_conv;
11727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11728         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11729         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
11730 }
11731
11732 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
11733         LDKHTLCOutputInCommitment this_ptr_conv;
11734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11735         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11736         jlong ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
11737         return ret_val;
11738 }
11739
11740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11741         LDKHTLCOutputInCommitment this_ptr_conv;
11742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11743         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11744         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
11745 }
11746
11747 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
11748         LDKHTLCOutputInCommitment this_ptr_conv;
11749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11750         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11751         jint ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
11752         return ret_val;
11753 }
11754
11755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11756         LDKHTLCOutputInCommitment this_ptr_conv;
11757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11758         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11759         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
11760 }
11761
11762 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
11763         LDKHTLCOutputInCommitment this_ptr_conv;
11764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11765         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11766         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
11767         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
11768         return ret_arr;
11769 }
11770
11771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11772         LDKHTLCOutputInCommitment this_ptr_conv;
11773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11774         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11775         LDKThirtyTwoBytes val_ref;
11776         CHECK((*_env)->GetArrayLength (_env, val) == 32);
11777         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
11778         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
11779 }
11780
11781 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv * _env, jclass _b, jlong obj) {
11782         LDKHTLCOutputInCommitment obj_conv;
11783         obj_conv.inner = (void*)(obj & (~1));
11784         obj_conv.is_owned = (obj & 1) || (obj == 0);
11785         LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
11786         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11787         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11788         return arg_arr;
11789 }
11790
11791 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11792         LDKu8slice ser_ref;
11793         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11794         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11795         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_read(ser_ref);
11796         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11797         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11798 }
11799
11800 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv * _env, jclass _b, jlong htlc, jlong keys) {
11801         LDKHTLCOutputInCommitment htlc_conv;
11802         htlc_conv.inner = (void*)(htlc & (~1));
11803         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
11804         LDKTxCreationKeys keys_conv;
11805         keys_conv.inner = (void*)(keys & (~1));
11806         keys_conv.is_owned = (keys & 1) || (keys == 0);
11807         LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
11808         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11809         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11810         return arg_arr;
11811 }
11812
11813 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv * _env, jclass _b, jbyteArray broadcaster, jbyteArray countersignatory) {
11814         LDKPublicKey broadcaster_ref;
11815         CHECK((*_env)->GetArrayLength (_env, broadcaster) == 33);
11816         (*_env)->GetByteArrayRegion (_env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
11817         LDKPublicKey countersignatory_ref;
11818         CHECK((*_env)->GetArrayLength (_env, countersignatory) == 33);
11819         (*_env)->GetByteArrayRegion (_env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
11820         LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
11821         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11822         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11823         return arg_arr;
11824 }
11825
11826 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) {
11827         unsigned char prev_hash_arr[32];
11828         CHECK((*_env)->GetArrayLength (_env, prev_hash) == 32);
11829         (*_env)->GetByteArrayRegion (_env, prev_hash, 0, 32, prev_hash_arr);
11830         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
11831         LDKHTLCOutputInCommitment htlc_conv;
11832         htlc_conv.inner = (void*)(htlc & (~1));
11833         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
11834         LDKPublicKey broadcaster_delayed_payment_key_ref;
11835         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key) == 33);
11836         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
11837         LDKPublicKey revocation_key_ref;
11838         CHECK((*_env)->GetArrayLength (_env, revocation_key) == 33);
11839         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
11840         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
11841         *ret = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
11842         return (long)ret;
11843 }
11844
11845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11846         LDKHolderCommitmentTransaction this_ptr_conv;
11847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11848         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11849         HolderCommitmentTransaction_free(this_ptr_conv);
11850 }
11851
11852 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11853         LDKHolderCommitmentTransaction orig_conv;
11854         orig_conv.inner = (void*)(orig & (~1));
11855         orig_conv.is_owned = (orig & 1) || (orig == 0);
11856         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_clone(&orig_conv);
11857         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11858 }
11859
11860 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr) {
11861         LDKHolderCommitmentTransaction this_ptr_conv;
11862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11863         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11864         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
11865         *ret = HolderCommitmentTransaction_get_unsigned_tx(&this_ptr_conv);
11866         return (long)ret;
11867 }
11868
11869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11870         LDKHolderCommitmentTransaction this_ptr_conv;
11871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11872         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11873         LDKTransaction val_conv = *(LDKTransaction*)val;
11874         FREE((void*)val);
11875         HolderCommitmentTransaction_set_unsigned_tx(&this_ptr_conv, val_conv);
11876 }
11877
11878 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr) {
11879         LDKHolderCommitmentTransaction this_ptr_conv;
11880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11881         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11882         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
11883         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
11884         return arg_arr;
11885 }
11886
11887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11888         LDKHolderCommitmentTransaction this_ptr_conv;
11889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11890         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11891         LDKSignature val_ref;
11892         CHECK((*_env)->GetArrayLength (_env, val) == 64);
11893         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
11894         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
11895 }
11896
11897 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
11898         LDKHolderCommitmentTransaction this_ptr_conv;
11899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11900         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11901         jint ret_val = HolderCommitmentTransaction_get_feerate_per_kw(&this_ptr_conv);
11902         return ret_val;
11903 }
11904
11905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11906         LDKHolderCommitmentTransaction this_ptr_conv;
11907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11908         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11909         HolderCommitmentTransaction_set_feerate_per_kw(&this_ptr_conv, val);
11910 }
11911
11912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
11913         LDKHolderCommitmentTransaction this_ptr_conv;
11914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11915         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11916         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_constr;
11917         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
11918         if (val_constr.datalen > 0)
11919                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
11920         else
11921                 val_constr.data = NULL;
11922         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
11923         for (size_t q = 0; q < val_constr.datalen; q++) {
11924                 long arr_conv_42 = val_vals[q];
11925                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
11926                 FREE((void*)arr_conv_42);
11927                 val_constr.data[q] = arr_conv_42_conv;
11928         }
11929         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
11930         HolderCommitmentTransaction_set_per_htlc(&this_ptr_conv, val_constr);
11931 }
11932
11933 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) {
11934         LDKTransaction unsigned_tx_conv = *(LDKTransaction*)unsigned_tx;
11935         FREE((void*)unsigned_tx);
11936         LDKSignature counterparty_sig_ref;
11937         CHECK((*_env)->GetArrayLength (_env, counterparty_sig) == 64);
11938         (*_env)->GetByteArrayRegion (_env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
11939         LDKPublicKey holder_funding_key_ref;
11940         CHECK((*_env)->GetArrayLength (_env, holder_funding_key) == 33);
11941         (*_env)->GetByteArrayRegion (_env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
11942         LDKPublicKey counterparty_funding_key_ref;
11943         CHECK((*_env)->GetArrayLength (_env, counterparty_funding_key) == 33);
11944         (*_env)->GetByteArrayRegion (_env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
11945         LDKTxCreationKeys keys_conv;
11946         keys_conv.inner = (void*)(keys & (~1));
11947         keys_conv.is_owned = (keys & 1) || (keys == 0);
11948         if (keys_conv.inner != NULL)
11949                 keys_conv = TxCreationKeys_clone(&keys_conv);
11950         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_constr;
11951         htlc_data_constr.datalen = (*_env)->GetArrayLength (_env, htlc_data);
11952         if (htlc_data_constr.datalen > 0)
11953                 htlc_data_constr.data = MALLOC(htlc_data_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
11954         else
11955                 htlc_data_constr.data = NULL;
11956         long* htlc_data_vals = (*_env)->GetLongArrayElements (_env, htlc_data, NULL);
11957         for (size_t q = 0; q < htlc_data_constr.datalen; q++) {
11958                 long arr_conv_42 = htlc_data_vals[q];
11959                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
11960                 FREE((void*)arr_conv_42);
11961                 htlc_data_constr.data[q] = arr_conv_42_conv;
11962         }
11963         (*_env)->ReleaseLongArrayElements (_env, htlc_data, htlc_data_vals, 0);
11964         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);
11965         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11966 }
11967
11968 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
11969         LDKHolderCommitmentTransaction this_arg_conv;
11970         this_arg_conv.inner = (void*)(this_arg & (~1));
11971         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11972         LDKTxCreationKeys ret = HolderCommitmentTransaction_trust_key_derivation(&this_arg_conv);
11973         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11974 }
11975
11976 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1txid(JNIEnv * _env, jclass _b, jlong this_arg) {
11977         LDKHolderCommitmentTransaction this_arg_conv;
11978         this_arg_conv.inner = (void*)(this_arg & (~1));
11979         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11980         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
11981         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, HolderCommitmentTransaction_txid(&this_arg_conv).data);
11982         return arg_arr;
11983 }
11984
11985 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) {
11986         LDKHolderCommitmentTransaction this_arg_conv;
11987         this_arg_conv.inner = (void*)(this_arg & (~1));
11988         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11989         unsigned char funding_key_arr[32];
11990         CHECK((*_env)->GetArrayLength (_env, funding_key) == 32);
11991         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_arr);
11992         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
11993         LDKu8slice funding_redeemscript_ref;
11994         funding_redeemscript_ref.data = (*_env)->GetByteArrayElements (_env, funding_redeemscript, NULL);
11995         funding_redeemscript_ref.datalen = (*_env)->GetArrayLength (_env, funding_redeemscript);
11996         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
11997         (*_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);
11998         (*_env)->ReleaseByteArrayElements(_env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
11999         return arg_arr;
12000 }
12001
12002 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) {
12003         LDKHolderCommitmentTransaction this_arg_conv;
12004         this_arg_conv.inner = (void*)(this_arg & (~1));
12005         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12006         unsigned char htlc_base_key_arr[32];
12007         CHECK((*_env)->GetArrayLength (_env, htlc_base_key) == 32);
12008         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_arr);
12009         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
12010         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12011         *ret = HolderCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, counterparty_selected_contest_delay);
12012         return (long)ret;
12013 }
12014
12015 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv * _env, jclass _b, jlong obj) {
12016         LDKHolderCommitmentTransaction obj_conv;
12017         obj_conv.inner = (void*)(obj & (~1));
12018         obj_conv.is_owned = (obj & 1) || (obj == 0);
12019         LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
12020         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12021         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12022         return arg_arr;
12023 }
12024
12025 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12026         LDKu8slice ser_ref;
12027         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12028         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12029         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_read(ser_ref);
12030         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12031         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12032 }
12033
12034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12035         LDKInitFeatures this_ptr_conv;
12036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12037         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12038         InitFeatures_free(this_ptr_conv);
12039 }
12040
12041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12042         LDKNodeFeatures this_ptr_conv;
12043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12044         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12045         NodeFeatures_free(this_ptr_conv);
12046 }
12047
12048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12049         LDKChannelFeatures this_ptr_conv;
12050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12051         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12052         ChannelFeatures_free(this_ptr_conv);
12053 }
12054
12055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12056         LDKRouteHop this_ptr_conv;
12057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12058         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12059         RouteHop_free(this_ptr_conv);
12060 }
12061
12062 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12063         LDKRouteHop orig_conv;
12064         orig_conv.inner = (void*)(orig & (~1));
12065         orig_conv.is_owned = (orig & 1) || (orig == 0);
12066         LDKRouteHop ret = RouteHop_clone(&orig_conv);
12067         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12068 }
12069
12070 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
12071         LDKRouteHop this_ptr_conv;
12072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12073         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12074         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12075         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
12076         return arg_arr;
12077 }
12078
12079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12080         LDKRouteHop this_ptr_conv;
12081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12082         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12083         LDKPublicKey val_ref;
12084         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12085         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12086         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
12087 }
12088
12089 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12090         LDKRouteHop this_ptr_conv;
12091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12092         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12093         LDKNodeFeatures ret = RouteHop_get_node_features(&this_ptr_conv);
12094         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12095 }
12096
12097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12098         LDKRouteHop this_ptr_conv;
12099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12100         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12101         LDKNodeFeatures val_conv;
12102         val_conv.inner = (void*)(val & (~1));
12103         val_conv.is_owned = (val & 1) || (val == 0);
12104         // Warning: we may need a move here but can't clone!
12105         RouteHop_set_node_features(&this_ptr_conv, val_conv);
12106 }
12107
12108 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12109         LDKRouteHop this_ptr_conv;
12110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12111         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12112         jlong ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
12113         return ret_val;
12114 }
12115
12116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12117         LDKRouteHop this_ptr_conv;
12118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12119         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12120         RouteHop_set_short_channel_id(&this_ptr_conv, val);
12121 }
12122
12123 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12124         LDKRouteHop this_ptr_conv;
12125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12126         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12127         LDKChannelFeatures ret = RouteHop_get_channel_features(&this_ptr_conv);
12128         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12129 }
12130
12131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12132         LDKRouteHop this_ptr_conv;
12133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12134         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12135         LDKChannelFeatures val_conv;
12136         val_conv.inner = (void*)(val & (~1));
12137         val_conv.is_owned = (val & 1) || (val == 0);
12138         // Warning: we may need a move here but can't clone!
12139         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
12140 }
12141
12142 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12143         LDKRouteHop this_ptr_conv;
12144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12145         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12146         jlong ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
12147         return ret_val;
12148 }
12149
12150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12151         LDKRouteHop this_ptr_conv;
12152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12153         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12154         RouteHop_set_fee_msat(&this_ptr_conv, val);
12155 }
12156
12157 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
12158         LDKRouteHop this_ptr_conv;
12159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12160         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12161         jint ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
12162         return ret_val;
12163 }
12164
12165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12166         LDKRouteHop this_ptr_conv;
12167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12168         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12169         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
12170 }
12171
12172 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) {
12173         LDKPublicKey pubkey_arg_ref;
12174         CHECK((*_env)->GetArrayLength (_env, pubkey_arg) == 33);
12175         (*_env)->GetByteArrayRegion (_env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
12176         LDKNodeFeatures node_features_arg_conv;
12177         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
12178         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
12179         // Warning: we may need a move here but can't clone!
12180         LDKChannelFeatures channel_features_arg_conv;
12181         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
12182         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
12183         // Warning: we may need a move here but can't clone!
12184         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);
12185         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12186 }
12187
12188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12189         LDKRoute this_ptr_conv;
12190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12191         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12192         Route_free(this_ptr_conv);
12193 }
12194
12195 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12196         LDKRoute orig_conv;
12197         orig_conv.inner = (void*)(orig & (~1));
12198         orig_conv.is_owned = (orig & 1) || (orig == 0);
12199         LDKRoute ret = Route_clone(&orig_conv);
12200         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12201 }
12202
12203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jobjectArray val) {
12204         LDKRoute this_ptr_conv;
12205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12206         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12207         LDKCVec_CVec_RouteHopZZ val_constr;
12208         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
12209         if (val_constr.datalen > 0)
12210                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12211         else
12212                 val_constr.data = NULL;
12213         for (size_t m = 0; m < val_constr.datalen; m++) {
12214                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, val, m);
12215                 LDKCVec_RouteHopZ arr_conv_12_constr;
12216                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
12217                 if (arr_conv_12_constr.datalen > 0)
12218                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12219                 else
12220                         arr_conv_12_constr.data = NULL;
12221                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
12222                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
12223                         long arr_conv_10 = arr_conv_12_vals[k];
12224                         LDKRouteHop arr_conv_10_conv;
12225                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
12226                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
12227                         if (arr_conv_10_conv.inner != NULL)
12228                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
12229                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
12230                 }
12231                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
12232                 val_constr.data[m] = arr_conv_12_constr;
12233         }
12234         Route_set_paths(&this_ptr_conv, val_constr);
12235 }
12236
12237 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jobjectArray paths_arg) {
12238         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
12239         paths_arg_constr.datalen = (*_env)->GetArrayLength (_env, paths_arg);
12240         if (paths_arg_constr.datalen > 0)
12241                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12242         else
12243                 paths_arg_constr.data = NULL;
12244         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
12245                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, paths_arg, m);
12246                 LDKCVec_RouteHopZ arr_conv_12_constr;
12247                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
12248                 if (arr_conv_12_constr.datalen > 0)
12249                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12250                 else
12251                         arr_conv_12_constr.data = NULL;
12252                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
12253                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
12254                         long arr_conv_10 = arr_conv_12_vals[k];
12255                         LDKRouteHop arr_conv_10_conv;
12256                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
12257                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
12258                         if (arr_conv_10_conv.inner != NULL)
12259                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
12260                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
12261                 }
12262                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
12263                 paths_arg_constr.data[m] = arr_conv_12_constr;
12264         }
12265         LDKRoute ret = Route_new(paths_arg_constr);
12266         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12267 }
12268
12269 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv * _env, jclass _b, jlong obj) {
12270         LDKRoute obj_conv;
12271         obj_conv.inner = (void*)(obj & (~1));
12272         obj_conv.is_owned = (obj & 1) || (obj == 0);
12273         LDKCVec_u8Z arg_var = Route_write(&obj_conv);
12274         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12275         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12276         return arg_arr;
12277 }
12278
12279 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12280         LDKu8slice ser_ref;
12281         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12282         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12283         LDKRoute ret = Route_read(ser_ref);
12284         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12285         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12286 }
12287
12288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12289         LDKRouteHint this_ptr_conv;
12290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12291         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12292         RouteHint_free(this_ptr_conv);
12293 }
12294
12295 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12296         LDKRouteHint orig_conv;
12297         orig_conv.inner = (void*)(orig & (~1));
12298         orig_conv.is_owned = (orig & 1) || (orig == 0);
12299         LDKRouteHint ret = RouteHint_clone(&orig_conv);
12300         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12301 }
12302
12303 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12304         LDKRouteHint this_ptr_conv;
12305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12306         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12307         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12308         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
12309         return arg_arr;
12310 }
12311
12312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12313         LDKRouteHint this_ptr_conv;
12314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12315         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12316         LDKPublicKey val_ref;
12317         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12318         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12319         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
12320 }
12321
12322 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12323         LDKRouteHint this_ptr_conv;
12324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12325         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12326         jlong ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
12327         return ret_val;
12328 }
12329
12330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12331         LDKRouteHint this_ptr_conv;
12332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12333         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12334         RouteHint_set_short_channel_id(&this_ptr_conv, val);
12335 }
12336
12337 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
12338         LDKRouteHint this_ptr_conv;
12339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12340         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12341         LDKRoutingFees ret = RouteHint_get_fees(&this_ptr_conv);
12342         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12343 }
12344
12345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12346         LDKRouteHint this_ptr_conv;
12347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12348         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12349         LDKRoutingFees val_conv;
12350         val_conv.inner = (void*)(val & (~1));
12351         val_conv.is_owned = (val & 1) || (val == 0);
12352         if (val_conv.inner != NULL)
12353                 val_conv = RoutingFees_clone(&val_conv);
12354         RouteHint_set_fees(&this_ptr_conv, val_conv);
12355 }
12356
12357 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
12358         LDKRouteHint this_ptr_conv;
12359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12360         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12361         jshort ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
12362         return ret_val;
12363 }
12364
12365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
12366         LDKRouteHint this_ptr_conv;
12367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12368         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12369         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
12370 }
12371
12372 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12373         LDKRouteHint this_ptr_conv;
12374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12375         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12376         jlong ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
12377         return ret_val;
12378 }
12379
12380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12381         LDKRouteHint this_ptr_conv;
12382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12383         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12384         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
12385 }
12386
12387 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) {
12388         LDKPublicKey src_node_id_arg_ref;
12389         CHECK((*_env)->GetArrayLength (_env, src_node_id_arg) == 33);
12390         (*_env)->GetByteArrayRegion (_env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
12391         LDKRoutingFees fees_arg_conv;
12392         fees_arg_conv.inner = (void*)(fees_arg & (~1));
12393         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
12394         if (fees_arg_conv.inner != NULL)
12395                 fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
12396         LDKRouteHint ret = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
12397         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12398 }
12399
12400 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) {
12401         LDKPublicKey our_node_id_ref;
12402         CHECK((*_env)->GetArrayLength (_env, our_node_id) == 33);
12403         (*_env)->GetByteArrayRegion (_env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
12404         LDKNetworkGraph network_conv;
12405         network_conv.inner = (void*)(network & (~1));
12406         network_conv.is_owned = (network & 1) || (network == 0);
12407         LDKPublicKey target_ref;
12408         CHECK((*_env)->GetArrayLength (_env, target) == 33);
12409         (*_env)->GetByteArrayRegion (_env, target, 0, 33, target_ref.compressed_form);
12410         LDKCVec_ChannelDetailsZ first_hops_constr;
12411         first_hops_constr.datalen = (*_env)->GetArrayLength (_env, first_hops);
12412         if (first_hops_constr.datalen > 0)
12413                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12414         else
12415                 first_hops_constr.data = NULL;
12416         long* first_hops_vals = (*_env)->GetLongArrayElements (_env, first_hops, NULL);
12417         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
12418                 long arr_conv_16 = first_hops_vals[q];
12419                 LDKChannelDetails arr_conv_16_conv;
12420                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
12421                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
12422                 first_hops_constr.data[q] = arr_conv_16_conv;
12423         }
12424         (*_env)->ReleaseLongArrayElements (_env, first_hops, first_hops_vals, 0);
12425         LDKCVec_RouteHintZ last_hops_constr;
12426         last_hops_constr.datalen = (*_env)->GetArrayLength (_env, last_hops);
12427         if (last_hops_constr.datalen > 0)
12428                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12429         else
12430                 last_hops_constr.data = NULL;
12431         long* last_hops_vals = (*_env)->GetLongArrayElements (_env, last_hops, NULL);
12432         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
12433                 long arr_conv_11 = last_hops_vals[l];
12434                 LDKRouteHint arr_conv_11_conv;
12435                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
12436                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
12437                 if (arr_conv_11_conv.inner != NULL)
12438                         arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
12439                 last_hops_constr.data[l] = arr_conv_11_conv;
12440         }
12441         (*_env)->ReleaseLongArrayElements (_env, last_hops, last_hops_vals, 0);
12442         LDKLogger logger_conv = *(LDKLogger*)logger;
12443         if (logger_conv.free == LDKLogger_JCalls_free) {
12444                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12445                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12446         }
12447         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12448         *ret = get_route(our_node_id_ref, &network_conv, target_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
12449         FREE(first_hops_constr.data);
12450         return (long)ret;
12451 }
12452
12453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12454         LDKNetworkGraph this_ptr_conv;
12455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12456         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12457         NetworkGraph_free(this_ptr_conv);
12458 }
12459
12460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12461         LDKLockedNetworkGraph this_ptr_conv;
12462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12463         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12464         LockedNetworkGraph_free(this_ptr_conv);
12465 }
12466
12467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12468         LDKNetGraphMsgHandler this_ptr_conv;
12469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12470         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12471         NetGraphMsgHandler_free(this_ptr_conv);
12472 }
12473
12474 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger) {
12475         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
12476         LDKLogger logger_conv = *(LDKLogger*)logger;
12477         if (logger_conv.free == LDKLogger_JCalls_free) {
12478                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12479                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12480         }
12481         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_new(chain_access_conv, logger_conv);
12482         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12483 }
12484
12485 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger, jlong network_graph) {
12486         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
12487         LDKLogger logger_conv = *(LDKLogger*)logger;
12488         if (logger_conv.free == LDKLogger_JCalls_free) {
12489                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12490                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12491         }
12492         LDKNetworkGraph network_graph_conv;
12493         network_graph_conv.inner = (void*)(network_graph & (~1));
12494         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
12495         // Warning: we may need a move here but can't clone!
12496         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
12497         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12498 }
12499
12500 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
12501         LDKNetGraphMsgHandler this_arg_conv;
12502         this_arg_conv.inner = (void*)(this_arg & (~1));
12503         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12504         LDKLockedNetworkGraph ret = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
12505         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12506 }
12507
12508 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
12509         LDKLockedNetworkGraph this_arg_conv;
12510         this_arg_conv.inner = (void*)(this_arg & (~1));
12511         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12512         LDKNetworkGraph ret = LockedNetworkGraph_graph(&this_arg_conv);
12513         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12514 }
12515
12516 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
12517         LDKNetGraphMsgHandler this_arg_conv;
12518         this_arg_conv.inner = (void*)(this_arg & (~1));
12519         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12520         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
12521         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
12522         return (long)ret;
12523 }
12524
12525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12526         LDKDirectionalChannelInfo this_ptr_conv;
12527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12528         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12529         DirectionalChannelInfo_free(this_ptr_conv);
12530 }
12531
12532 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
12533         LDKDirectionalChannelInfo this_ptr_conv;
12534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12535         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12536         jint ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
12537         return ret_val;
12538 }
12539
12540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12541         LDKDirectionalChannelInfo this_ptr_conv;
12542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12543         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12544         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
12545 }
12546
12547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr) {
12548         LDKDirectionalChannelInfo this_ptr_conv;
12549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12550         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12551         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
12552         return ret_val;
12553 }
12554
12555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
12556         LDKDirectionalChannelInfo this_ptr_conv;
12557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12558         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12559         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
12560 }
12561
12562 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
12563         LDKDirectionalChannelInfo this_ptr_conv;
12564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12565         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12566         jshort ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
12567         return ret_val;
12568 }
12569
12570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
12571         LDKDirectionalChannelInfo this_ptr_conv;
12572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12573         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12574         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
12575 }
12576
12577 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12578         LDKDirectionalChannelInfo this_ptr_conv;
12579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12580         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12581         jlong ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
12582         return ret_val;
12583 }
12584
12585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12586         LDKDirectionalChannelInfo this_ptr_conv;
12587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12588         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12589         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
12590 }
12591
12592 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
12593         LDKDirectionalChannelInfo this_ptr_conv;
12594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12595         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12596         LDKChannelUpdate ret = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
12597         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12598 }
12599
12600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12601         LDKDirectionalChannelInfo this_ptr_conv;
12602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12603         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12604         LDKChannelUpdate val_conv;
12605         val_conv.inner = (void*)(val & (~1));
12606         val_conv.is_owned = (val & 1) || (val == 0);
12607         if (val_conv.inner != NULL)
12608                 val_conv = ChannelUpdate_clone(&val_conv);
12609         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
12610 }
12611
12612 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
12613         LDKDirectionalChannelInfo obj_conv;
12614         obj_conv.inner = (void*)(obj & (~1));
12615         obj_conv.is_owned = (obj & 1) || (obj == 0);
12616         LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
12617         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12618         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12619         return arg_arr;
12620 }
12621
12622 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12623         LDKu8slice ser_ref;
12624         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12625         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12626         LDKDirectionalChannelInfo ret = DirectionalChannelInfo_read(ser_ref);
12627         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12628         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12629 }
12630
12631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12632         LDKChannelInfo this_ptr_conv;
12633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12634         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12635         ChannelInfo_free(this_ptr_conv);
12636 }
12637
12638 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12639         LDKChannelInfo this_ptr_conv;
12640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12641         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12642         LDKChannelFeatures ret = ChannelInfo_get_features(&this_ptr_conv);
12643         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12644 }
12645
12646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12647         LDKChannelInfo this_ptr_conv;
12648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12649         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12650         LDKChannelFeatures val_conv;
12651         val_conv.inner = (void*)(val & (~1));
12652         val_conv.is_owned = (val & 1) || (val == 0);
12653         // Warning: we may need a move here but can't clone!
12654         ChannelInfo_set_features(&this_ptr_conv, val_conv);
12655 }
12656
12657 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
12658         LDKChannelInfo this_ptr_conv;
12659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12660         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12661         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12662         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
12663         return arg_arr;
12664 }
12665
12666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12667         LDKChannelInfo this_ptr_conv;
12668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12669         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12670         LDKPublicKey val_ref;
12671         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12672         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12673         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
12674 }
12675
12676 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(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         LDKDirectionalChannelInfo ret = ChannelInfo_get_one_to_two(&this_ptr_conv);
12681         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12682 }
12683
12684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12685         LDKChannelInfo this_ptr_conv;
12686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12687         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12688         LDKDirectionalChannelInfo val_conv;
12689         val_conv.inner = (void*)(val & (~1));
12690         val_conv.is_owned = (val & 1) || (val == 0);
12691         // Warning: we may need a move here but can't clone!
12692         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
12693 }
12694
12695 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
12696         LDKChannelInfo this_ptr_conv;
12697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12698         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12699         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12700         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
12701         return arg_arr;
12702 }
12703
12704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12705         LDKChannelInfo this_ptr_conv;
12706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12707         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12708         LDKPublicKey val_ref;
12709         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12710         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12711         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
12712 }
12713
12714 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
12715         LDKChannelInfo this_ptr_conv;
12716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12717         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12718         LDKDirectionalChannelInfo ret = ChannelInfo_get_two_to_one(&this_ptr_conv);
12719         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12720 }
12721
12722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12723         LDKChannelInfo this_ptr_conv;
12724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12725         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12726         LDKDirectionalChannelInfo val_conv;
12727         val_conv.inner = (void*)(val & (~1));
12728         val_conv.is_owned = (val & 1) || (val == 0);
12729         // Warning: we may need a move here but can't clone!
12730         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
12731 }
12732
12733 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
12734         LDKChannelInfo this_ptr_conv;
12735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12736         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12737         LDKChannelAnnouncement ret = ChannelInfo_get_announcement_message(&this_ptr_conv);
12738         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12739 }
12740
12741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12742         LDKChannelInfo this_ptr_conv;
12743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12744         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12745         LDKChannelAnnouncement val_conv;
12746         val_conv.inner = (void*)(val & (~1));
12747         val_conv.is_owned = (val & 1) || (val == 0);
12748         if (val_conv.inner != NULL)
12749                 val_conv = ChannelAnnouncement_clone(&val_conv);
12750         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
12751 }
12752
12753 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
12754         LDKChannelInfo obj_conv;
12755         obj_conv.inner = (void*)(obj & (~1));
12756         obj_conv.is_owned = (obj & 1) || (obj == 0);
12757         LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
12758         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12759         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12760         return arg_arr;
12761 }
12762
12763 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12764         LDKu8slice ser_ref;
12765         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12766         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12767         LDKChannelInfo ret = ChannelInfo_read(ser_ref);
12768         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12769         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12770 }
12771
12772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12773         LDKRoutingFees this_ptr_conv;
12774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12775         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12776         RoutingFees_free(this_ptr_conv);
12777 }
12778
12779 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12780         LDKRoutingFees orig_conv;
12781         orig_conv.inner = (void*)(orig & (~1));
12782         orig_conv.is_owned = (orig & 1) || (orig == 0);
12783         LDKRoutingFees ret = RoutingFees_clone(&orig_conv);
12784         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12785 }
12786
12787 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12788         LDKRoutingFees this_ptr_conv;
12789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12790         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12791         jint ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
12792         return ret_val;
12793 }
12794
12795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12796         LDKRoutingFees this_ptr_conv;
12797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12798         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12799         RoutingFees_set_base_msat(&this_ptr_conv, val);
12800 }
12801
12802 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
12803         LDKRoutingFees this_ptr_conv;
12804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12805         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12806         jint ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
12807         return ret_val;
12808 }
12809
12810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12811         LDKRoutingFees this_ptr_conv;
12812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12813         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12814         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
12815 }
12816
12817 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv * _env, jclass _b, jint base_msat_arg, jint proportional_millionths_arg) {
12818         LDKRoutingFees ret = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
12819         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12820 }
12821
12822 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12823         LDKu8slice ser_ref;
12824         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12825         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12826         LDKRoutingFees ret = RoutingFees_read(ser_ref);
12827         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12828         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12829 }
12830
12831 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv * _env, jclass _b, jlong obj) {
12832         LDKRoutingFees obj_conv;
12833         obj_conv.inner = (void*)(obj & (~1));
12834         obj_conv.is_owned = (obj & 1) || (obj == 0);
12835         LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
12836         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12837         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12838         return arg_arr;
12839 }
12840
12841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12842         LDKNodeAnnouncementInfo 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         NodeAnnouncementInfo_free(this_ptr_conv);
12846 }
12847
12848 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12849         LDKNodeAnnouncementInfo 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         LDKNodeFeatures ret = NodeAnnouncementInfo_get_features(&this_ptr_conv);
12853         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12854 }
12855
12856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12857         LDKNodeAnnouncementInfo 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         LDKNodeFeatures val_conv;
12861         val_conv.inner = (void*)(val & (~1));
12862         val_conv.is_owned = (val & 1) || (val == 0);
12863         // Warning: we may need a move here but can't clone!
12864         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
12865 }
12866
12867 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
12868         LDKNodeAnnouncementInfo this_ptr_conv;
12869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12870         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12871         jint ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
12872         return ret_val;
12873 }
12874
12875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12876         LDKNodeAnnouncementInfo this_ptr_conv;
12877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12878         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12879         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
12880 }
12881
12882 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
12883         LDKNodeAnnouncementInfo this_ptr_conv;
12884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12885         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12886         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
12887         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
12888         return ret_arr;
12889 }
12890
12891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12892         LDKNodeAnnouncementInfo this_ptr_conv;
12893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12894         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12895         LDKThreeBytes val_ref;
12896         CHECK((*_env)->GetArrayLength (_env, val) == 3);
12897         (*_env)->GetByteArrayRegion (_env, val, 0, 3, val_ref.data);
12898         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
12899 }
12900
12901 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
12902         LDKNodeAnnouncementInfo this_ptr_conv;
12903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12904         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12905         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
12906         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
12907         return ret_arr;
12908 }
12909
12910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12911         LDKNodeAnnouncementInfo this_ptr_conv;
12912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12913         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12914         LDKThirtyTwoBytes val_ref;
12915         CHECK((*_env)->GetArrayLength (_env, val) == 32);
12916         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
12917         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
12918 }
12919
12920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
12921         LDKNodeAnnouncementInfo this_ptr_conv;
12922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12923         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12924         LDKCVec_NetAddressZ val_constr;
12925         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
12926         if (val_constr.datalen > 0)
12927                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12928         else
12929                 val_constr.data = NULL;
12930         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
12931         for (size_t m = 0; m < val_constr.datalen; m++) {
12932                 long arr_conv_12 = val_vals[m];
12933                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
12934                 FREE((void*)arr_conv_12);
12935                 val_constr.data[m] = arr_conv_12_conv;
12936         }
12937         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
12938         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
12939 }
12940
12941 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
12942         LDKNodeAnnouncementInfo this_ptr_conv;
12943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12944         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12945         LDKNodeAnnouncement ret = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
12946         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12947 }
12948
12949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12950         LDKNodeAnnouncementInfo this_ptr_conv;
12951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12952         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12953         LDKNodeAnnouncement val_conv;
12954         val_conv.inner = (void*)(val & (~1));
12955         val_conv.is_owned = (val & 1) || (val == 0);
12956         if (val_conv.inner != NULL)
12957                 val_conv = NodeAnnouncement_clone(&val_conv);
12958         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
12959 }
12960
12961 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) {
12962         LDKNodeFeatures features_arg_conv;
12963         features_arg_conv.inner = (void*)(features_arg & (~1));
12964         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
12965         // Warning: we may need a move here but can't clone!
12966         LDKThreeBytes rgb_arg_ref;
12967         CHECK((*_env)->GetArrayLength (_env, rgb_arg) == 3);
12968         (*_env)->GetByteArrayRegion (_env, rgb_arg, 0, 3, rgb_arg_ref.data);
12969         LDKThirtyTwoBytes alias_arg_ref;
12970         CHECK((*_env)->GetArrayLength (_env, alias_arg) == 32);
12971         (*_env)->GetByteArrayRegion (_env, alias_arg, 0, 32, alias_arg_ref.data);
12972         LDKCVec_NetAddressZ addresses_arg_constr;
12973         addresses_arg_constr.datalen = (*_env)->GetArrayLength (_env, addresses_arg);
12974         if (addresses_arg_constr.datalen > 0)
12975                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12976         else
12977                 addresses_arg_constr.data = NULL;
12978         long* addresses_arg_vals = (*_env)->GetLongArrayElements (_env, addresses_arg, NULL);
12979         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
12980                 long arr_conv_12 = addresses_arg_vals[m];
12981                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
12982                 FREE((void*)arr_conv_12);
12983                 addresses_arg_constr.data[m] = arr_conv_12_conv;
12984         }
12985         (*_env)->ReleaseLongArrayElements (_env, addresses_arg, addresses_arg_vals, 0);
12986         LDKNodeAnnouncement announcement_message_arg_conv;
12987         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
12988         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
12989         if (announcement_message_arg_conv.inner != NULL)
12990                 announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
12991         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
12992         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12993 }
12994
12995 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
12996         LDKNodeAnnouncementInfo obj_conv;
12997         obj_conv.inner = (void*)(obj & (~1));
12998         obj_conv.is_owned = (obj & 1) || (obj == 0);
12999         LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
13000         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
13001         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
13002         return arg_arr;
13003 }
13004
13005 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
13006         LDKu8slice ser_ref;
13007         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
13008         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
13009         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_read(ser_ref);
13010         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
13011         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13012 }
13013
13014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
13015         LDKNodeInfo this_ptr_conv;
13016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13017         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13018         NodeInfo_free(this_ptr_conv);
13019 }
13020
13021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
13022         LDKNodeInfo this_ptr_conv;
13023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13024         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13025         LDKCVec_u64Z val_constr;
13026         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
13027         if (val_constr.datalen > 0)
13028                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
13029         else
13030                 val_constr.data = NULL;
13031         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
13032         for (size_t g = 0; g < val_constr.datalen; g++) {
13033                 long arr_conv_6 = val_vals[g];
13034                 val_constr.data[g] = arr_conv_6;
13035         }
13036         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
13037         NodeInfo_set_channels(&this_ptr_conv, val_constr);
13038 }
13039
13040 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
13041         LDKNodeInfo this_ptr_conv;
13042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13043         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13044         LDKRoutingFees ret = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
13045         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13046 }
13047
13048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
13049         LDKNodeInfo this_ptr_conv;
13050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13051         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13052         LDKRoutingFees val_conv;
13053         val_conv.inner = (void*)(val & (~1));
13054         val_conv.is_owned = (val & 1) || (val == 0);
13055         if (val_conv.inner != NULL)
13056                 val_conv = RoutingFees_clone(&val_conv);
13057         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
13058 }
13059
13060 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr) {
13061         LDKNodeInfo this_ptr_conv;
13062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13063         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13064         LDKNodeAnnouncementInfo ret = NodeInfo_get_announcement_info(&this_ptr_conv);
13065         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13066 }
13067
13068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
13069         LDKNodeInfo this_ptr_conv;
13070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13071         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13072         LDKNodeAnnouncementInfo val_conv;
13073         val_conv.inner = (void*)(val & (~1));
13074         val_conv.is_owned = (val & 1) || (val == 0);
13075         // Warning: we may need a move here but can't clone!
13076         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
13077 }
13078
13079 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) {
13080         LDKCVec_u64Z channels_arg_constr;
13081         channels_arg_constr.datalen = (*_env)->GetArrayLength (_env, channels_arg);
13082         if (channels_arg_constr.datalen > 0)
13083                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
13084         else
13085                 channels_arg_constr.data = NULL;
13086         long* channels_arg_vals = (*_env)->GetLongArrayElements (_env, channels_arg, NULL);
13087         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
13088                 long arr_conv_6 = channels_arg_vals[g];
13089                 channels_arg_constr.data[g] = arr_conv_6;
13090         }
13091         (*_env)->ReleaseLongArrayElements (_env, channels_arg, channels_arg_vals, 0);
13092         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
13093         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
13094         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
13095         if (lowest_inbound_channel_fees_arg_conv.inner != NULL)
13096                 lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
13097         LDKNodeAnnouncementInfo announcement_info_arg_conv;
13098         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
13099         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
13100         // Warning: we may need a move here but can't clone!
13101         LDKNodeInfo ret = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
13102         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13103 }
13104
13105 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
13106         LDKNodeInfo obj_conv;
13107         obj_conv.inner = (void*)(obj & (~1));
13108         obj_conv.is_owned = (obj & 1) || (obj == 0);
13109         LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
13110         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
13111         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
13112         return arg_arr;
13113 }
13114
13115 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
13116         LDKu8slice ser_ref;
13117         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
13118         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
13119         LDKNodeInfo ret = NodeInfo_read(ser_ref);
13120         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
13121         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13122 }
13123
13124 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv * _env, jclass _b, jlong obj) {
13125         LDKNetworkGraph obj_conv;
13126         obj_conv.inner = (void*)(obj & (~1));
13127         obj_conv.is_owned = (obj & 1) || (obj == 0);
13128         LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
13129         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
13130         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
13131         return arg_arr;
13132 }
13133
13134 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
13135         LDKu8slice ser_ref;
13136         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
13137         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
13138         LDKNetworkGraph ret = NetworkGraph_read(ser_ref);
13139         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
13140         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13141 }
13142
13143 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv * _env, jclass _b) {
13144         LDKNetworkGraph ret = NetworkGraph_new();
13145         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13146 }
13147
13148 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) {
13149         LDKNetworkGraph this_arg_conv;
13150         this_arg_conv.inner = (void*)(this_arg & (~1));
13151         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
13152         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
13153 }
13154