Properly free Vec<u8>s after conversion to byte[].
[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 = (long)err_var.inner & ~1;
480         return err_ref;
481 }
482 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) {
483         LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z");
484         LDKOutPoint a_conv;
485         a_conv.inner = (void*)(a & (~1));
486         a_conv.is_owned = (a & 1) || (a == 0);
487         if (a_conv.inner != NULL)
488                 a_conv = OutPoint_clone(&a_conv);
489         ret->a = a_conv;
490         LDKCVec_u8Z b_ref;
491         b_ref.data = (*_env)->GetByteArrayElements (_env, b, NULL);
492         b_ref.datalen = (*_env)->GetArrayLength (_env, b);
493         ret->b = b_ref;
494         //TODO: Really need to call (*_env)->ReleaseByteArrayElements(_env, b, (int8_t*)b_ref.data, 0); here
495         return (long)ret;
496 }
497 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
498         LDKCVecTempl_TxOut *vec = (LDKCVecTempl_TxOut*)ptr;
499         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTxOut));
500 }
501 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
502         LDKCVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_TxOut), "LDKCVecTempl_TxOut");
503         ret->datalen = (*env)->GetArrayLength(env, elems);
504         if (ret->datalen == 0) {
505                 ret->data = NULL;
506         } else {
507                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVecTempl_TxOut Data");
508                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
509                 for (size_t i = 0; i < ret->datalen; i++) {
510                         jlong arr_elem = java_elems[i];
511                         LDKTxOut arr_elem_conv = *(LDKTxOut*)arr_elem;
512                         FREE((void*)arr_elem);
513                         ret->data[i] = arr_elem_conv;
514                 }
515                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
516         }
517         return (long)ret;
518 }
519 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlongArray b) {
520         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut* ret = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
521         LDKThirtyTwoBytes a_ref;
522         CHECK((*_env)->GetArrayLength (_env, a) == 32);
523         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
524         ret->a = a_ref;
525         LDKCVecTempl_TxOut b_constr;
526         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
527         if (b_constr.datalen > 0)
528                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKTxOut), "LDKCVecTempl_TxOut Elements");
529         else
530                 b_constr.data = NULL;
531         long* b_vals = (*_env)->GetLongArrayElements (_env, b, NULL);
532         for (size_t h = 0; h < b_constr.datalen; h++) {
533                 long arr_conv_7 = b_vals[h];
534                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
535                 FREE((void*)arr_conv_7);
536                 b_constr.data[h] = arr_conv_7_conv;
537         }
538         (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0);
539         ret->b = b_constr;
540         return (long)ret;
541 }
542 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
543         LDKC2TupleTempl_u64__u64* ret = MALLOC(sizeof(LDKC2TupleTempl_u64__u64), "LDKC2TupleTempl_u64__u64");
544         ret->a = a;
545         ret->b = b;
546         return (long)ret;
547 }
548 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
549         LDKCVecTempl_Signature *vec = (LDKCVecTempl_Signature*)ptr;
550         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSignature));
551 }
552 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jbyteArray a, jobjectArray b) {
553         LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature");
554         LDKSignature a_ref;
555         CHECK((*_env)->GetArrayLength (_env, a) == 64);
556         (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form);
557         ret->a = a_ref;
558         LDKCVecTempl_Signature b_constr;
559         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
560         if (b_constr.datalen > 0)
561                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVecTempl_Signature Elements");
562         else
563                 b_constr.data = NULL;
564         for (size_t i = 0; i < b_constr.datalen; i++) {
565                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, b, i);
566                 LDKSignature arr_conv_8_ref;
567                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
568                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
569                 b_constr.data[i] = arr_conv_8_ref;
570         }
571         ret->b = b_constr;
572         return (long)ret;
573 }
574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
575         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
576 }
577 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
578         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
579         CHECK(val->result_ok);
580         long res_ref = (long)&(*val->contents.result);
581         return res_ref;
582 }
583 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
584         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
585         CHECK(!val->result_ok);
586         return *val->contents.err;
587 }
588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
589         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
590 }
591 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
592         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
593         CHECK(val->result_ok);
594         jbyteArray res_arr = (*_env)->NewByteArray(_env, 64);
595         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 64, (*val->contents.result).compact_form);
596         return res_arr;
597 }
598 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
599         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
600         CHECK(!val->result_ok);
601         return *val->contents.err;
602 }
603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
604         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
605 }
606 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
607         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
608         CHECK(val->result_ok);
609         LDKCVecTempl_Signature res_var = (*val->contents.result);
610         jobjectArray res_arr = (*_env)->NewObjectArray(_env, res_var.datalen, NULL, NULL);
611         for (size_t i = 0; i < res_var.datalen; i++) {
612                 jbyteArray arr_conv_8_arr = (*_env)->NewByteArray(_env, 64);
613                 (*_env)->SetByteArrayRegion(_env, arr_conv_8_arr, 0, 64, res_var.data[i].compact_form);
614                 (*_env)->SetObjectArrayElement(_env, res_arr, i, arr_conv_8_arr);
615         }
616         return res_arr;
617 }
618 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
619         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
620         CHECK(!val->result_ok);
621         return *val->contents.err;
622 }
623 static jclass LDKAPIError_APIMisuseError_class = NULL;
624 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
625 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
626 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
627 static jclass LDKAPIError_RouteError_class = NULL;
628 static jmethodID LDKAPIError_RouteError_meth = NULL;
629 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
630 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
631 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
632 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv * env, jclass _a) {
634         LDKAPIError_APIMisuseError_class =
635                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
636         CHECK(LDKAPIError_APIMisuseError_class != NULL);
637         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
638         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
639         LDKAPIError_FeeRateTooHigh_class =
640                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
641         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
642         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
643         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
644         LDKAPIError_RouteError_class =
645                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
646         CHECK(LDKAPIError_RouteError_class != NULL);
647         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
648         CHECK(LDKAPIError_RouteError_meth != NULL);
649         LDKAPIError_ChannelUnavailable_class =
650                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
651         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
652         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
653         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
654         LDKAPIError_MonitorUpdateFailed_class =
655                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
656         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
657         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
658         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
659 }
660 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
661         LDKAPIError *obj = (LDKAPIError*)ptr;
662         switch(obj->tag) {
663                 case LDKAPIError_APIMisuseError: {
664                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
665                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
666                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
667                         return (*_env)->NewObject(_env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
668                 }
669                 case LDKAPIError_FeeRateTooHigh: {
670                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
671                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
672                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
673                         return (*_env)->NewObject(_env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
674                 }
675                 case LDKAPIError_RouteError: {
676                         LDKStr err_str = obj->route_error.err;
677                         char* err_buf = MALLOC(err_str.len + 1, "str conv buf");
678                         memcpy(err_buf, err_str.chars, err_str.len);
679                         err_buf[err_str.len] = 0;
680                         jstring err_conv = (*_env)->NewStringUTF(_env, err_str.chars);
681                         FREE(err_buf);
682                         return (*_env)->NewObject(_env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
683                 }
684                 case LDKAPIError_ChannelUnavailable: {
685                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
686                         jbyteArray err_arr = (*_env)->NewByteArray(_env, err_var.datalen);
687                         (*_env)->SetByteArrayRegion(_env, err_arr, 0, err_var.datalen, err_var.data);
688                         return (*_env)->NewObject(_env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
689                 }
690                 case LDKAPIError_MonitorUpdateFailed: {
691                         return (*_env)->NewObject(_env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
692                 }
693                 default: abort();
694         }
695 }
696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
697         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
698 }
699 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
700         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
701         CHECK(val->result_ok);
702         return *val->contents.result;
703 }
704 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
705         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
706         CHECK(!val->result_ok);
707         long err_ref = (long)&(*val->contents.err);
708         return err_ref;
709 }
710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
711         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
712 }
713 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
714         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
715         CHECK(val->result_ok);
716         return *val->contents.result;
717 }
718 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
719         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
720         CHECK(!val->result_ok);
721         LDKPaymentSendFailure err_var = (*val->contents.err);
722         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
723         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
724         long err_ref = (long)err_var.inner & ~1;
725         return err_ref;
726 }
727 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) {
728         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate* ret = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
729         LDKChannelAnnouncement a_conv;
730         a_conv.inner = (void*)(a & (~1));
731         a_conv.is_owned = (a & 1) || (a == 0);
732         if (a_conv.inner != NULL)
733                 a_conv = ChannelAnnouncement_clone(&a_conv);
734         ret->a = a_conv;
735         LDKChannelUpdate b_conv;
736         b_conv.inner = (void*)(b & (~1));
737         b_conv.is_owned = (b & 1) || (b == 0);
738         if (b_conv.inner != NULL)
739                 b_conv = ChannelUpdate_clone(&b_conv);
740         ret->b = b_conv;
741         LDKChannelUpdate c_conv;
742         c_conv.inner = (void*)(c & (~1));
743         c_conv.is_owned = (c & 1) || (c == 0);
744         if (c_conv.inner != NULL)
745                 c_conv = ChannelUpdate_clone(&c_conv);
746         ret->c = c_conv;
747         return (long)ret;
748 }
749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
750         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
751 }
752 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
753         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
754         CHECK(val->result_ok);
755         return *val->contents.result;
756 }
757 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
758         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
759         CHECK(!val->result_ok);
760         LDKPeerHandleError err_var = (*val->contents.err);
761         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
762         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
763         long err_ref = (long)err_var.inner & ~1;
764         return err_ref;
765 }
766 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) {
767         LDKC2TupleTempl_HTLCOutputInCommitment__Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature), "LDKC2TupleTempl_HTLCOutputInCommitment__Signature");
768         LDKHTLCOutputInCommitment a_conv;
769         a_conv.inner = (void*)(a & (~1));
770         a_conv.is_owned = (a & 1) || (a == 0);
771         if (a_conv.inner != NULL)
772                 a_conv = HTLCOutputInCommitment_clone(&a_conv);
773         ret->a = a_conv;
774         LDKSignature b_ref;
775         CHECK((*_env)->GetArrayLength (_env, b) == 64);
776         (*_env)->GetByteArrayRegion (_env, b, 0, 64, b_ref.compact_form);
777         ret->b = b_ref;
778         return (long)ret;
779 }
780 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
781 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
782 static jclass LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class = NULL;
783 static jmethodID LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = NULL;
784 static jclass LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class = NULL;
785 static jmethodID LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = NULL;
786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv * env, jclass _a) {
787         LDKSpendableOutputDescriptor_StaticOutput_class =
788                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
789         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
790         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
791         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
792         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class =
793                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DynamicOutputP2WSH;"));
794         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class != NULL);
795         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, "<init>", "(J[BSJJ[B)V");
796         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth != NULL);
797         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class =
798                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutputCounterpartyPayment;"));
799         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class != NULL);
800         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, "<init>", "(JJJ)V");
801         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth != NULL);
802 }
803 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
804         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
805         switch(obj->tag) {
806                 case LDKSpendableOutputDescriptor_StaticOutput: {
807                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
808                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
809                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
810                         long outpoint_ref = (long)outpoint_var.inner & ~1;
811                         long output_ref = (long)&obj->static_output.output;
812                         return (*_env)->NewObject(_env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, output_ref);
813                 }
814                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
815                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
816                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
817                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
818                         long outpoint_ref = (long)outpoint_var.inner & ~1;
819                         jbyteArray per_commitment_point_arr = (*_env)->NewByteArray(_env, 33);
820                         (*_env)->SetByteArrayRegion(_env, per_commitment_point_arr, 0, 33, obj->dynamic_output_p2wsh.per_commitment_point.compressed_form);
821                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
822                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
823                         jbyteArray revocation_pubkey_arr = (*_env)->NewByteArray(_env, 33);
824                         (*_env)->SetByteArrayRegion(_env, revocation_pubkey_arr, 0, 33, obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form);
825                         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);
826                 }
827                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
828                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
829                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
830                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
831                         long outpoint_ref = (long)outpoint_var.inner & ~1;
832                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
833                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
834                         return (*_env)->NewObject(_env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth, outpoint_ref, output_ref, key_derivation_params_ref);
835                 }
836                 default: abort();
837         }
838 }
839 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
840         LDKCVecTempl_SpendableOutputDescriptor *vec = (LDKCVecTempl_SpendableOutputDescriptor*)ptr;
841         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSpendableOutputDescriptor));
842 }
843 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1new(JNIEnv *env, jclass _b, jlongArray elems){
844         LDKCVecTempl_SpendableOutputDescriptor *ret = MALLOC(sizeof(LDKCVecTempl_SpendableOutputDescriptor), "LDKCVecTempl_SpendableOutputDescriptor");
845         ret->datalen = (*env)->GetArrayLength(env, elems);
846         if (ret->datalen == 0) {
847                 ret->data = NULL;
848         } else {
849                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVecTempl_SpendableOutputDescriptor Data");
850                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
851                 for (size_t i = 0; i < ret->datalen; i++) {
852                         jlong arr_elem = java_elems[i];
853                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
854                         FREE((void*)arr_elem);
855                         ret->data[i] = arr_elem_conv;
856                 }
857                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
858         }
859         return (long)ret;
860 }
861 static jclass LDKEvent_FundingGenerationReady_class = NULL;
862 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
863 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
864 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
865 static jclass LDKEvent_PaymentReceived_class = NULL;
866 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
867 static jclass LDKEvent_PaymentSent_class = NULL;
868 static jmethodID LDKEvent_PaymentSent_meth = NULL;
869 static jclass LDKEvent_PaymentFailed_class = NULL;
870 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
871 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
872 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
873 static jclass LDKEvent_SpendableOutputs_class = NULL;
874 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv * env, jclass _a) {
876         LDKEvent_FundingGenerationReady_class =
877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
878         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
879         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
880         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
881         LDKEvent_FundingBroadcastSafe_class =
882                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
883         CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
884         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
885         CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
886         LDKEvent_PaymentReceived_class =
887                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
888         CHECK(LDKEvent_PaymentReceived_class != NULL);
889         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
890         CHECK(LDKEvent_PaymentReceived_meth != NULL);
891         LDKEvent_PaymentSent_class =
892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
893         CHECK(LDKEvent_PaymentSent_class != NULL);
894         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
895         CHECK(LDKEvent_PaymentSent_meth != NULL);
896         LDKEvent_PaymentFailed_class =
897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
898         CHECK(LDKEvent_PaymentFailed_class != NULL);
899         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
900         CHECK(LDKEvent_PaymentFailed_meth != NULL);
901         LDKEvent_PendingHTLCsForwardable_class =
902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
903         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
904         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
905         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
906         LDKEvent_SpendableOutputs_class =
907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
908         CHECK(LDKEvent_SpendableOutputs_class != NULL);
909         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
910         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
911 }
912 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
913         LDKEvent *obj = (LDKEvent*)ptr;
914         switch(obj->tag) {
915                 case LDKEvent_FundingGenerationReady: {
916                         jbyteArray temporary_channel_id_arr = (*_env)->NewByteArray(_env, 32);
917                         (*_env)->SetByteArrayRegion(_env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
918                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
919                         jbyteArray output_script_arr = (*_env)->NewByteArray(_env, output_script_var.datalen);
920                         (*_env)->SetByteArrayRegion(_env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
921                         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);
922                 }
923                 case LDKEvent_FundingBroadcastSafe: {
924                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
925                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
926                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
927                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
928                         return (*_env)->NewObject(_env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
929                 }
930                 case LDKEvent_PaymentReceived: {
931                         jbyteArray payment_hash_arr = (*_env)->NewByteArray(_env, 32);
932                         (*_env)->SetByteArrayRegion(_env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
933                         jbyteArray payment_secret_arr = (*_env)->NewByteArray(_env, 32);
934                         (*_env)->SetByteArrayRegion(_env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
935                         return (*_env)->NewObject(_env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
936                 }
937                 case LDKEvent_PaymentSent: {
938                         jbyteArray payment_preimage_arr = (*_env)->NewByteArray(_env, 32);
939                         (*_env)->SetByteArrayRegion(_env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
940                         return (*_env)->NewObject(_env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
941                 }
942                 case LDKEvent_PaymentFailed: {
943                         jbyteArray payment_hash_arr = (*_env)->NewByteArray(_env, 32);
944                         (*_env)->SetByteArrayRegion(_env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
945                         return (*_env)->NewObject(_env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
946                 }
947                 case LDKEvent_PendingHTLCsForwardable: {
948                         return (*_env)->NewObject(_env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
949                 }
950                 case LDKEvent_SpendableOutputs: {
951                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
952                         jlongArray outputs_arr = (*_env)->NewLongArray(_env, outputs_var.datalen);
953                         jlong *outputs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, outputs_arr, NULL);
954                         for (size_t b = 0; b < outputs_var.datalen; b++) {
955                                 long arr_conv_27_ref = (long)&outputs_var.data[b];
956                                 outputs_arr_ptr[b] = arr_conv_27_ref;
957                         }
958                         (*_env)->ReleasePrimitiveArrayCritical(_env, outputs_arr, outputs_arr_ptr, 0);
959                         return (*_env)->NewObject(_env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
960                 }
961                 default: abort();
962         }
963 }
964 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
965 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
966 static jclass LDKErrorAction_IgnoreError_class = NULL;
967 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
968 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
969 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv * env, jclass _a) {
971         LDKErrorAction_DisconnectPeer_class =
972                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
973         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
974         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
975         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
976         LDKErrorAction_IgnoreError_class =
977                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
978         CHECK(LDKErrorAction_IgnoreError_class != NULL);
979         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
980         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
981         LDKErrorAction_SendErrorMessage_class =
982                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
983         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
984         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
985         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
986 }
987 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
988         LDKErrorAction *obj = (LDKErrorAction*)ptr;
989         switch(obj->tag) {
990                 case LDKErrorAction_DisconnectPeer: {
991                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
992                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
993                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
994                         long msg_ref = (long)msg_var.inner & ~1;
995                         return (*_env)->NewObject(_env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
996                 }
997                 case LDKErrorAction_IgnoreError: {
998                         return (*_env)->NewObject(_env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
999                 }
1000                 case LDKErrorAction_SendErrorMessage: {
1001                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1002                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1003                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1004                         long msg_ref = (long)msg_var.inner & ~1;
1005                         return (*_env)->NewObject(_env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1006                 }
1007                 default: abort();
1008         }
1009 }
1010 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1011 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1012 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1013 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1014 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1015 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv * env, jclass _a) {
1017         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1018                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1019         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1020         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1021         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1022         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1023                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1024         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1025         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1026         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1027         LDKHTLCFailChannelUpdate_NodeFailure_class =
1028                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1029         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1030         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1031         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1032 }
1033 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
1034         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
1035         switch(obj->tag) {
1036                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1037                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1038                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1039                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1040                         long msg_ref = (long)msg_var.inner & ~1;
1041                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1042                 }
1043                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1044                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1045                 }
1046                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1047                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1048                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1049                         return (*_env)->NewObject(_env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1050                 }
1051                 default: abort();
1052         }
1053 }
1054 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1055 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1056 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1057 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1058 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1059 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1060 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1061 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1062 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1063 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1064 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1065 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1066 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1067 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1068 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1069 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1070 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1071 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1072 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1073 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1074 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1075 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1076 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1077 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1078 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1079 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1080 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1081 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1082 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1083 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1084 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1085 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv * env, jclass _a) {
1087         LDKMessageSendEvent_SendAcceptChannel_class =
1088                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1089         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1090         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1091         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1092         LDKMessageSendEvent_SendOpenChannel_class =
1093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1094         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1095         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1096         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1097         LDKMessageSendEvent_SendFundingCreated_class =
1098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1099         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1100         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1101         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1102         LDKMessageSendEvent_SendFundingSigned_class =
1103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1104         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1105         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1106         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1107         LDKMessageSendEvent_SendFundingLocked_class =
1108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1109         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1110         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1111         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1112         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1114         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1115         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1116         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1117         LDKMessageSendEvent_UpdateHTLCs_class =
1118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1119         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1120         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1121         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1122         LDKMessageSendEvent_SendRevokeAndACK_class =
1123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1124         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1125         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1126         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1127         LDKMessageSendEvent_SendClosingSigned_class =
1128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1129         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1130         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1131         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1132         LDKMessageSendEvent_SendShutdown_class =
1133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1134         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1135         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1136         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1137         LDKMessageSendEvent_SendChannelReestablish_class =
1138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1139         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1140         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1141         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1142         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1144         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1145         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1146         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1147         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1149         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1150         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1151         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1152         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1153                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1154         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1155         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1156         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1157         LDKMessageSendEvent_HandleError_class =
1158                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1159         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1160         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1161         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1162         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1163                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1164         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1165         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1166         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1167 }
1168 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
1169         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1170         switch(obj->tag) {
1171                 case LDKMessageSendEvent_SendAcceptChannel: {
1172                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1173                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1174                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1175                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1176                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1177                         long msg_ref = (long)msg_var.inner & ~1;
1178                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1179                 }
1180                 case LDKMessageSendEvent_SendOpenChannel: {
1181                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1182                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1183                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1184                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1185                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1186                         long msg_ref = (long)msg_var.inner & ~1;
1187                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1188                 }
1189                 case LDKMessageSendEvent_SendFundingCreated: {
1190                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1191                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1192                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1193                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1194                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1195                         long msg_ref = (long)msg_var.inner & ~1;
1196                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1197                 }
1198                 case LDKMessageSendEvent_SendFundingSigned: {
1199                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1200                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1201                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1202                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1203                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1204                         long msg_ref = (long)msg_var.inner & ~1;
1205                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1206                 }
1207                 case LDKMessageSendEvent_SendFundingLocked: {
1208                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1209                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1210                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1211                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1212                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1213                         long msg_ref = (long)msg_var.inner & ~1;
1214                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1215                 }
1216                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1217                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1218                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1219                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1220                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1221                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1222                         long msg_ref = (long)msg_var.inner & ~1;
1223                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1224                 }
1225                 case LDKMessageSendEvent_UpdateHTLCs: {
1226                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1227                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1228                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1229                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1230                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1231                         long updates_ref = (long)updates_var.inner & ~1;
1232                         return (*_env)->NewObject(_env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1233                 }
1234                 case LDKMessageSendEvent_SendRevokeAndACK: {
1235                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1236                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1237                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.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 = (long)msg_var.inner & ~1;
1241                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1242                 }
1243                 case LDKMessageSendEvent_SendClosingSigned: {
1244                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1245                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1246                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1247                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1248                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1249                         long msg_ref = (long)msg_var.inner & ~1;
1250                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1251                 }
1252                 case LDKMessageSendEvent_SendShutdown: {
1253                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1254                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1255                         LDKShutdown msg_var = obj->send_shutdown.msg;
1256                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1257                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1258                         long msg_ref = (long)msg_var.inner & ~1;
1259                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1260                 }
1261                 case LDKMessageSendEvent_SendChannelReestablish: {
1262                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1263                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1264                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1265                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1266                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1267                         long msg_ref = (long)msg_var.inner & ~1;
1268                         return (*_env)->NewObject(_env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1269                 }
1270                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1271                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1272                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1273                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1274                         long msg_ref = (long)msg_var.inner & ~1;
1275                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1276                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1277                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1278                         long update_msg_ref = (long)update_msg_var.inner & ~1;
1279                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1280                 }
1281                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1282                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1283                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1284                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1285                         long msg_ref = (long)msg_var.inner & ~1;
1286                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1287                 }
1288                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1289                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1290                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1291                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1292                         long msg_ref = (long)msg_var.inner & ~1;
1293                         return (*_env)->NewObject(_env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1294                 }
1295                 case LDKMessageSendEvent_HandleError: {
1296                         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
1297                         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1298                         long action_ref = (long)&obj->handle_error.action;
1299                         return (*_env)->NewObject(_env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1300                 }
1301                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1302                         long update_ref = (long)&obj->payment_failure_network_update.update;
1303                         return (*_env)->NewObject(_env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1304                 }
1305                 default: abort();
1306         }
1307 }
1308 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1309         LDKCVecTempl_MessageSendEvent *vec = (LDKCVecTempl_MessageSendEvent*)ptr;
1310         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKMessageSendEvent));
1311 }
1312 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1313         LDKCVecTempl_MessageSendEvent *ret = MALLOC(sizeof(LDKCVecTempl_MessageSendEvent), "LDKCVecTempl_MessageSendEvent");
1314         ret->datalen = (*env)->GetArrayLength(env, elems);
1315         if (ret->datalen == 0) {
1316                 ret->data = NULL;
1317         } else {
1318                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVecTempl_MessageSendEvent Data");
1319                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1320                 for (size_t i = 0; i < ret->datalen; i++) {
1321                         jlong arr_elem = java_elems[i];
1322                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
1323                         FREE((void*)arr_elem);
1324                         ret->data[i] = arr_elem_conv;
1325                 }
1326                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1327         }
1328         return (long)ret;
1329 }
1330 typedef struct LDKMessageSendEventsProvider_JCalls {
1331         atomic_size_t refcnt;
1332         JavaVM *vm;
1333         jweak o;
1334         jmethodID get_and_clear_pending_msg_events_meth;
1335 } LDKMessageSendEventsProvider_JCalls;
1336 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
1337         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1338         JNIEnv *_env;
1339         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1340         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1341         CHECK(obj != NULL);
1342         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_and_clear_pending_msg_events_meth);
1343         LDKCVec_MessageSendEventZ ret_constr;
1344         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
1345         if (ret_constr.datalen > 0)
1346                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
1347         else
1348                 ret_constr.data = NULL;
1349         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
1350         for (size_t s = 0; s < ret_constr.datalen; s++) {
1351                 long arr_conv_18 = ret_vals[s];
1352                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
1353                 FREE((void*)arr_conv_18);
1354                 ret_constr.data[s] = arr_conv_18_conv;
1355         }
1356         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
1357         return ret_constr;
1358 }
1359 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
1360         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1361         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1362                 JNIEnv *env;
1363                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1364                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1365                 FREE(j_calls);
1366         }
1367 }
1368 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
1369         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1370         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1371         return (void*) this_arg;
1372 }
1373 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1374         jclass c = (*env)->GetObjectClass(env, o);
1375         CHECK(c != NULL);
1376         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
1377         atomic_init(&calls->refcnt, 1);
1378         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1379         calls->o = (*env)->NewWeakGlobalRef(env, o);
1380         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
1381         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
1382
1383         LDKMessageSendEventsProvider ret = {
1384                 .this_arg = (void*) calls,
1385                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
1386                 .free = LDKMessageSendEventsProvider_JCalls_free,
1387         };
1388         return ret;
1389 }
1390 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1391         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
1392         *res_ptr = LDKMessageSendEventsProvider_init(env, _a, o);
1393         return (long)res_ptr;
1394 }
1395 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1396         jobject ret = (*env)->NewLocalRef(env, ((LDKMessageSendEventsProvider_JCalls*)val)->o);
1397         CHECK(ret != NULL);
1398         return ret;
1399 }
1400 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
1401         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
1402         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
1403         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
1404         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
1405         for (size_t s = 0; s < ret_var.datalen; s++) {
1406                 LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
1407                 *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
1408                 long arr_conv_18_ref = (long)arr_conv_18_copy;
1409                 ret_arr_ptr[s] = arr_conv_18_ref;
1410         }
1411         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
1412         CVec_MessageSendEventZ_free(ret_var);
1413         return ret_arr;
1414 }
1415
1416 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1417         LDKCVecTempl_Event *vec = (LDKCVecTempl_Event*)ptr;
1418         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKEvent));
1419 }
1420 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1new(JNIEnv *env, jclass _b, jlongArray elems){
1421         LDKCVecTempl_Event *ret = MALLOC(sizeof(LDKCVecTempl_Event), "LDKCVecTempl_Event");
1422         ret->datalen = (*env)->GetArrayLength(env, elems);
1423         if (ret->datalen == 0) {
1424                 ret->data = NULL;
1425         } else {
1426                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVecTempl_Event Data");
1427                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1428                 for (size_t i = 0; i < ret->datalen; i++) {
1429                         jlong arr_elem = java_elems[i];
1430                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
1431                         FREE((void*)arr_elem);
1432                         ret->data[i] = arr_elem_conv;
1433                 }
1434                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1435         }
1436         return (long)ret;
1437 }
1438 typedef struct LDKEventsProvider_JCalls {
1439         atomic_size_t refcnt;
1440         JavaVM *vm;
1441         jweak o;
1442         jmethodID get_and_clear_pending_events_meth;
1443 } LDKEventsProvider_JCalls;
1444 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
1445         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1446         JNIEnv *_env;
1447         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1448         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1449         CHECK(obj != NULL);
1450         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_and_clear_pending_events_meth);
1451         LDKCVec_EventZ ret_constr;
1452         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
1453         if (ret_constr.datalen > 0)
1454                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
1455         else
1456                 ret_constr.data = NULL;
1457         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
1458         for (size_t h = 0; h < ret_constr.datalen; h++) {
1459                 long arr_conv_7 = ret_vals[h];
1460                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
1461                 FREE((void*)arr_conv_7);
1462                 ret_constr.data[h] = arr_conv_7_conv;
1463         }
1464         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
1465         return ret_constr;
1466 }
1467 static void LDKEventsProvider_JCalls_free(void* this_arg) {
1468         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1469         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1470                 JNIEnv *env;
1471                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1472                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1473                 FREE(j_calls);
1474         }
1475 }
1476 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
1477         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1478         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1479         return (void*) this_arg;
1480 }
1481 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1482         jclass c = (*env)->GetObjectClass(env, o);
1483         CHECK(c != NULL);
1484         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
1485         atomic_init(&calls->refcnt, 1);
1486         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1487         calls->o = (*env)->NewWeakGlobalRef(env, o);
1488         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
1489         CHECK(calls->get_and_clear_pending_events_meth != NULL);
1490
1491         LDKEventsProvider ret = {
1492                 .this_arg = (void*) calls,
1493                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
1494                 .free = LDKEventsProvider_JCalls_free,
1495         };
1496         return ret;
1497 }
1498 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1499         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
1500         *res_ptr = LDKEventsProvider_init(env, _a, o);
1501         return (long)res_ptr;
1502 }
1503 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1504         jobject ret = (*env)->NewLocalRef(env, ((LDKEventsProvider_JCalls*)val)->o);
1505         CHECK(ret != NULL);
1506         return ret;
1507 }
1508 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
1509         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
1510         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
1511         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
1512         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
1513         for (size_t h = 0; h < ret_var.datalen; h++) {
1514                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
1515                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
1516                 long arr_conv_7_ref = (long)arr_conv_7_copy;
1517                 ret_arr_ptr[h] = arr_conv_7_ref;
1518         }
1519         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
1520         CVec_EventZ_free(ret_var);
1521         return ret_arr;
1522 }
1523
1524 typedef struct LDKLogger_JCalls {
1525         atomic_size_t refcnt;
1526         JavaVM *vm;
1527         jweak o;
1528         jmethodID log_meth;
1529 } LDKLogger_JCalls;
1530 void log_jcall(const void* this_arg, const char *record) {
1531         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1532         JNIEnv *_env;
1533         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1534         jstring record_conv = (*_env)->NewStringUTF(_env, record);
1535         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1536         CHECK(obj != NULL);
1537         return (*_env)->CallVoidMethod(_env, obj, j_calls->log_meth, record_conv);
1538 }
1539 static void LDKLogger_JCalls_free(void* this_arg) {
1540         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1541         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1542                 JNIEnv *env;
1543                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1544                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1545                 FREE(j_calls);
1546         }
1547 }
1548 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1549         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1550         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1551         return (void*) this_arg;
1552 }
1553 static inline LDKLogger LDKLogger_init (JNIEnv * env, jclass _a, jobject o) {
1554         jclass c = (*env)->GetObjectClass(env, o);
1555         CHECK(c != NULL);
1556         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1557         atomic_init(&calls->refcnt, 1);
1558         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1559         calls->o = (*env)->NewWeakGlobalRef(env, o);
1560         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
1561         CHECK(calls->log_meth != NULL);
1562
1563         LDKLogger ret = {
1564                 .this_arg = (void*) calls,
1565                 .log = log_jcall,
1566                 .free = LDKLogger_JCalls_free,
1567         };
1568         return ret;
1569 }
1570 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new (JNIEnv * env, jclass _a, jobject o) {
1571         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1572         *res_ptr = LDKLogger_init(env, _a, o);
1573         return (long)res_ptr;
1574 }
1575 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1576         jobject ret = (*env)->NewLocalRef(env, ((LDKLogger_JCalls*)val)->o);
1577         CHECK(ret != NULL);
1578         return ret;
1579 }
1580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
1581         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1582 }
1583 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
1584         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1585         CHECK(val->result_ok);
1586         long res_ref = (long)&(*val->contents.result);
1587         return res_ref;
1588 }
1589 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
1590         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1591         CHECK(!val->result_ok);
1592         jclass err_conv = LDKAccessError_to_java(_env, (*val->contents.err));
1593         return err_conv;
1594 }
1595 typedef struct LDKAccess_JCalls {
1596         atomic_size_t refcnt;
1597         JavaVM *vm;
1598         jweak o;
1599         jmethodID get_utxo_meth;
1600 } LDKAccess_JCalls;
1601 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) {
1602         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1603         JNIEnv *_env;
1604         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1605         jbyteArray genesis_hash_arr = (*_env)->NewByteArray(_env, 32);
1606         (*_env)->SetByteArrayRegion(_env, genesis_hash_arr, 0, 32, *genesis_hash);
1607         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1608         CHECK(obj != NULL);
1609         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
1610         LDKCResult_TxOutAccessErrorZ res = *ret;
1611         FREE(ret);
1612         return res;
1613 }
1614 static void LDKAccess_JCalls_free(void* this_arg) {
1615         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1616         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1617                 JNIEnv *env;
1618                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1619                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1620                 FREE(j_calls);
1621         }
1622 }
1623 static void* LDKAccess_JCalls_clone(const void* this_arg) {
1624         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1625         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1626         return (void*) this_arg;
1627 }
1628 static inline LDKAccess LDKAccess_init (JNIEnv * env, jclass _a, jobject o) {
1629         jclass c = (*env)->GetObjectClass(env, o);
1630         CHECK(c != NULL);
1631         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
1632         atomic_init(&calls->refcnt, 1);
1633         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1634         calls->o = (*env)->NewWeakGlobalRef(env, o);
1635         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
1636         CHECK(calls->get_utxo_meth != NULL);
1637
1638         LDKAccess ret = {
1639                 .this_arg = (void*) calls,
1640                 .get_utxo = get_utxo_jcall,
1641                 .free = LDKAccess_JCalls_free,
1642         };
1643         return ret;
1644 }
1645 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new (JNIEnv * env, jclass _a, jobject o) {
1646         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
1647         *res_ptr = LDKAccess_init(env, _a, o);
1648         return (long)res_ptr;
1649 }
1650 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAccess_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1651         jobject ret = (*env)->NewLocalRef(env, ((LDKAccess_JCalls*)val)->o);
1652         CHECK(ret != NULL);
1653         return ret;
1654 }
1655 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) {
1656         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
1657         unsigned char genesis_hash_arr[32];
1658         CHECK((*_env)->GetArrayLength (_env, genesis_hash) == 32);
1659         (*_env)->GetByteArrayRegion (_env, genesis_hash, 0, 32, genesis_hash_arr);
1660         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
1661         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
1662         *ret = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
1663         return (long)ret;
1664 }
1665
1666 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1667         LDKCVecTempl_HTLCOutputInCommitment *vec = (LDKCVecTempl_HTLCOutputInCommitment*)ptr;
1668         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
1669         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
1670         for (size_t i = 0; i < vec->datalen; i++) {
1671                 CHECK((((long)vec->data[i].inner) & 1) == 0);
1672                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
1673         }
1674         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
1675         return ret;
1676 }
1677 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1new(JNIEnv *env, jclass _b, jlongArray elems){
1678         LDKCVecTempl_HTLCOutputInCommitment *ret = MALLOC(sizeof(LDKCVecTempl_HTLCOutputInCommitment), "LDKCVecTempl_HTLCOutputInCommitment");
1679         ret->datalen = (*env)->GetArrayLength(env, elems);
1680         if (ret->datalen == 0) {
1681                 ret->data = NULL;
1682         } else {
1683                 ret->data = MALLOC(sizeof(LDKHTLCOutputInCommitment) * ret->datalen, "LDKCVecTempl_HTLCOutputInCommitment Data");
1684                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1685                 for (size_t i = 0; i < ret->datalen; i++) {
1686                         jlong arr_elem = java_elems[i];
1687                         LDKHTLCOutputInCommitment arr_elem_conv;
1688                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1689                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1690                         if (arr_elem_conv.inner != NULL)
1691                                 arr_elem_conv = HTLCOutputInCommitment_clone(&arr_elem_conv);
1692                         ret->data[i] = arr_elem_conv;
1693                 }
1694                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1695         }
1696         return (long)ret;
1697 }
1698 typedef struct LDKChannelKeys_JCalls {
1699         atomic_size_t refcnt;
1700         JavaVM *vm;
1701         jweak o;
1702         jmethodID get_per_commitment_point_meth;
1703         jmethodID release_commitment_secret_meth;
1704         jmethodID key_derivation_params_meth;
1705         jmethodID sign_counterparty_commitment_meth;
1706         jmethodID sign_holder_commitment_meth;
1707         jmethodID sign_holder_commitment_htlc_transactions_meth;
1708         jmethodID sign_justice_transaction_meth;
1709         jmethodID sign_counterparty_htlc_transaction_meth;
1710         jmethodID sign_closing_transaction_meth;
1711         jmethodID sign_channel_announcement_meth;
1712         jmethodID on_accept_meth;
1713 } LDKChannelKeys_JCalls;
1714 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1715         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1716         JNIEnv *_env;
1717         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1718         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1719         CHECK(obj != NULL);
1720         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_per_commitment_point_meth, idx);
1721         LDKPublicKey ret_ref;
1722         CHECK((*_env)->GetArrayLength (_env, ret) == 33);
1723         (*_env)->GetByteArrayRegion (_env, ret, 0, 33, ret_ref.compressed_form);
1724         return ret_ref;
1725 }
1726 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1727         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1728         JNIEnv *_env;
1729         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1730         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1731         CHECK(obj != NULL);
1732         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->release_commitment_secret_meth, idx);
1733         LDKThirtyTwoBytes ret_ref;
1734         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
1735         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.data);
1736         return ret_ref;
1737 }
1738 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1739         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1740         JNIEnv *_env;
1741         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1742         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1743         CHECK(obj != NULL);
1744         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*_env)->CallLongMethod(_env, obj, j_calls->key_derivation_params_meth);
1745         LDKC2Tuple_u64u64Z res = *ret;
1746         FREE(ret);
1747         return res;
1748 }
1749 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) {
1750         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1751         JNIEnv *_env;
1752         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1753         long commitment_tx_ref = (long)&commitment_tx;
1754         LDKCVec_HTLCOutputInCommitmentZ htlcs_var = htlcs;
1755         jlongArray htlcs_arr = (*_env)->NewLongArray(_env, htlcs_var.datalen);
1756         jlong *htlcs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, htlcs_arr, NULL);
1757         for (size_t y = 0; y < htlcs_var.datalen; y++) {
1758                 LDKHTLCOutputInCommitment arr_conv_24_var = htlcs_var.data[y];
1759                 CHECK((((long)arr_conv_24_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1760                 CHECK((((long)&arr_conv_24_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1761                 long arr_conv_24_ref;
1762                 if (arr_conv_24_var.is_owned) {
1763                         arr_conv_24_ref = (long)arr_conv_24_var.inner | 1;
1764                 } else {
1765                         arr_conv_24_ref = (long)arr_conv_24_var.inner & ~1;
1766                 }
1767                 htlcs_arr_ptr[y] = arr_conv_24_ref;
1768         }
1769         (*_env)->ReleasePrimitiveArrayCritical(_env, htlcs_arr, htlcs_arr_ptr, 0);
1770         FREE(htlcs_var.data);
1771         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1772         CHECK(obj != NULL);
1773         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);
1774         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret;
1775         FREE(ret);
1776         return res;
1777 }
1778 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1779         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1780         JNIEnv *_env;
1781         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1782         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1783         CHECK(obj != NULL);
1784         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_meth, holder_commitment_tx);
1785         LDKCResult_SignatureNoneZ res = *ret;
1786         FREE(ret);
1787         return res;
1788 }
1789 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1790         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1791         JNIEnv *_env;
1792         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1793         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1794         CHECK(obj != NULL);
1795         LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx);
1796         LDKCResult_CVec_SignatureZNoneZ res = *ret;
1797         FREE(ret);
1798         return res;
1799 }
1800 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) {
1801         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1802         JNIEnv *_env;
1803         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1804         long justice_tx_ref = (long)&justice_tx;
1805         jbyteArray per_commitment_key_arr = (*_env)->NewByteArray(_env, 32);
1806         (*_env)->SetByteArrayRegion(_env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1807         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1808         CHECK(obj != NULL);
1809         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);
1810         LDKCResult_SignatureNoneZ res = *ret;
1811         FREE(ret);
1812         return res;
1813 }
1814 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) {
1815         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1816         JNIEnv *_env;
1817         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1818         long htlc_tx_ref = (long)&htlc_tx;
1819         jbyteArray per_commitment_point_arr = (*_env)->NewByteArray(_env, 33);
1820         (*_env)->SetByteArrayRegion(_env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
1821         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1822         CHECK(obj != NULL);
1823         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);
1824         LDKCResult_SignatureNoneZ res = *ret;
1825         FREE(ret);
1826         return res;
1827 }
1828 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1829         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1830         JNIEnv *_env;
1831         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1832         long closing_tx_ref = (long)&closing_tx;
1833         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1834         CHECK(obj != NULL);
1835         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
1836         LDKCResult_SignatureNoneZ res = *ret;
1837         FREE(ret);
1838         return res;
1839 }
1840 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement *msg) {
1841         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1842         JNIEnv *_env;
1843         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1844         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1845         CHECK(obj != NULL);
1846         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_channel_announcement_meth, msg);
1847         LDKCResult_SignatureNoneZ res = *ret;
1848         FREE(ret);
1849         return res;
1850 }
1851 void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay) {
1852         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1853         JNIEnv *_env;
1854         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
1855         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
1856         CHECK(obj != NULL);
1857         return (*_env)->CallVoidMethod(_env, obj, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay);
1858 }
1859 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1860         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1861         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1862                 JNIEnv *env;
1863                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1864                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1865                 FREE(j_calls);
1866         }
1867 }
1868 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1869         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1870         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1871         return (void*) this_arg;
1872 }
1873 static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o) {
1874         jclass c = (*env)->GetObjectClass(env, o);
1875         CHECK(c != NULL);
1876         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1877         atomic_init(&calls->refcnt, 1);
1878         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1879         calls->o = (*env)->NewWeakGlobalRef(env, o);
1880         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
1881         CHECK(calls->get_per_commitment_point_meth != NULL);
1882         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
1883         CHECK(calls->release_commitment_secret_meth != NULL);
1884         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
1885         CHECK(calls->key_derivation_params_meth != NULL);
1886         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJ[J)J");
1887         CHECK(calls->sign_counterparty_commitment_meth != NULL);
1888         calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
1889         CHECK(calls->sign_holder_commitment_meth != NULL);
1890         calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
1891         CHECK(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
1892         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "(JJJ[BJ)J");
1893         CHECK(calls->sign_justice_transaction_meth != NULL);
1894         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "(JJJ[BJ)J");
1895         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
1896         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
1897         CHECK(calls->sign_closing_transaction_meth != NULL);
1898         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1899         CHECK(calls->sign_channel_announcement_meth != NULL);
1900         calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V");
1901         CHECK(calls->on_accept_meth != NULL);
1902
1903         LDKChannelKeys ret = {
1904                 .this_arg = (void*) calls,
1905                 .get_per_commitment_point = get_per_commitment_point_jcall,
1906                 .release_commitment_secret = release_commitment_secret_jcall,
1907                 .key_derivation_params = key_derivation_params_jcall,
1908                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1909                 .sign_holder_commitment = sign_holder_commitment_jcall,
1910                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1911                 .sign_justice_transaction = sign_justice_transaction_jcall,
1912                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1913                 .sign_closing_transaction = sign_closing_transaction_jcall,
1914                 .sign_channel_announcement = sign_channel_announcement_jcall,
1915                 .on_accept = on_accept_jcall,
1916                 .clone = LDKChannelKeys_JCalls_clone,
1917                 .free = LDKChannelKeys_JCalls_free,
1918         };
1919         return ret;
1920 }
1921 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o) {
1922         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1923         *res_ptr = LDKChannelKeys_init(env, _a, o);
1924         return (long)res_ptr;
1925 }
1926 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1927         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelKeys_JCalls*)val)->o);
1928         CHECK(ret != NULL);
1929         return ret;
1930 }
1931 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg, jlong idx) {
1932         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1933         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
1934         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
1935         return arg_arr;
1936 }
1937
1938 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1release_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_arg, jlong idx) {
1939         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1940         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
1941         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
1942         return arg_arr;
1943 }
1944
1945 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1key_1derivation_1params(JNIEnv * _env, jclass _b, jlong this_arg) {
1946         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1947         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1948         *ret = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
1949         return (long)ret;
1950 }
1951
1952 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) {
1953         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1954         LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx;
1955         FREE((void*)commitment_tx);
1956         LDKPreCalculatedTxCreationKeys keys_conv;
1957         keys_conv.inner = (void*)(keys & (~1));
1958         keys_conv.is_owned = (keys & 1) || (keys == 0);
1959         LDKCVec_HTLCOutputInCommitmentZ htlcs_constr;
1960         htlcs_constr.datalen = (*_env)->GetArrayLength (_env, htlcs);
1961         if (htlcs_constr.datalen > 0)
1962                 htlcs_constr.data = MALLOC(htlcs_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
1963         else
1964                 htlcs_constr.data = NULL;
1965         long* htlcs_vals = (*_env)->GetLongArrayElements (_env, htlcs, NULL);
1966         for (size_t y = 0; y < htlcs_constr.datalen; y++) {
1967                 long arr_conv_24 = htlcs_vals[y];
1968                 LDKHTLCOutputInCommitment arr_conv_24_conv;
1969                 arr_conv_24_conv.inner = (void*)(arr_conv_24 & (~1));
1970                 arr_conv_24_conv.is_owned = (arr_conv_24 & 1) || (arr_conv_24 == 0);
1971                 if (arr_conv_24_conv.inner != NULL)
1972                         arr_conv_24_conv = HTLCOutputInCommitment_clone(&arr_conv_24_conv);
1973                 htlcs_constr.data[y] = arr_conv_24_conv;
1974         }
1975         (*_env)->ReleaseLongArrayElements (_env, htlcs, htlcs_vals, 0);
1976         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1977         *ret = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, &keys_conv, htlcs_constr);
1978         return (long)ret;
1979 }
1980
1981 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1holder_1commitment(JNIEnv * _env, jclass _b, jlong this_arg, jlong holder_commitment_tx) {
1982         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1983         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
1984         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
1985         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
1986         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1987         *ret = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &holder_commitment_tx_conv);
1988         return (long)ret;
1989 }
1990
1991 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) {
1992         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1993         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
1994         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
1995         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
1996         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1997         *ret = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &holder_commitment_tx_conv);
1998         return (long)ret;
1999 }
2000
2001 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) {
2002         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2003         LDKTransaction justice_tx_conv = *(LDKTransaction*)justice_tx;
2004         FREE((void*)justice_tx);
2005         unsigned char per_commitment_key_arr[32];
2006         CHECK((*_env)->GetArrayLength (_env, per_commitment_key) == 32);
2007         (*_env)->GetByteArrayRegion (_env, per_commitment_key, 0, 32, per_commitment_key_arr);
2008         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2009         LDKHTLCOutputInCommitment htlc_conv;
2010         htlc_conv.inner = (void*)(htlc & (~1));
2011         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
2012         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2013         *ret = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_conv, input, amount, per_commitment_key_ref, &htlc_conv);
2014         return (long)ret;
2015 }
2016
2017 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) {
2018         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2019         LDKTransaction htlc_tx_conv = *(LDKTransaction*)htlc_tx;
2020         FREE((void*)htlc_tx);
2021         LDKPublicKey per_commitment_point_ref;
2022         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
2023         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2024         LDKHTLCOutputInCommitment htlc_conv;
2025         htlc_conv.inner = (void*)(htlc & (~1));
2026         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
2027         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2028         *ret = (this_arg_conv->sign_counterparty_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_conv, input, amount, per_commitment_point_ref, &htlc_conv);
2029         return (long)ret;
2030 }
2031
2032 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1closing_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong closing_tx) {
2033         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2034         LDKTransaction closing_tx_conv = *(LDKTransaction*)closing_tx;
2035         FREE((void*)closing_tx);
2036         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2037         *ret = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_conv);
2038         return (long)ret;
2039 }
2040
2041 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1channel_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
2042         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2043         LDKUnsignedChannelAnnouncement msg_conv;
2044         msg_conv.inner = (void*)(msg & (~1));
2045         msg_conv.is_owned = (msg & 1) || (msg == 0);
2046         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2047         *ret = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2048         return (long)ret;
2049 }
2050
2051 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) {
2052         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2053         LDKChannelPublicKeys channel_points_conv;
2054         channel_points_conv.inner = (void*)(channel_points & (~1));
2055         channel_points_conv.is_owned = (channel_points & 1) || (channel_points == 0);
2056         (this_arg_conv->on_accept)(this_arg_conv->this_arg, &channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
2057 }
2058
2059 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2060         LDKCVecTempl_MonitorEvent *vec = (LDKCVecTempl_MonitorEvent*)ptr;
2061         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2062         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2063         for (size_t i = 0; i < vec->datalen; i++) {
2064                 CHECK((((long)vec->data[i].inner) & 1) == 0);
2065                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2066         }
2067         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2068         return ret;
2069 }
2070 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
2071         LDKCVecTempl_MonitorEvent *ret = MALLOC(sizeof(LDKCVecTempl_MonitorEvent), "LDKCVecTempl_MonitorEvent");
2072         ret->datalen = (*env)->GetArrayLength(env, elems);
2073         if (ret->datalen == 0) {
2074                 ret->data = NULL;
2075         } else {
2076                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVecTempl_MonitorEvent Data");
2077                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2078                 for (size_t i = 0; i < ret->datalen; i++) {
2079                         jlong arr_elem = java_elems[i];
2080                         LDKMonitorEvent arr_elem_conv;
2081                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2082                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2083                         // Warning: we may need a move here but can't clone!
2084                         ret->data[i] = arr_elem_conv;
2085                 }
2086                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2087         }
2088         return (long)ret;
2089 }
2090 typedef struct LDKWatch_JCalls {
2091         atomic_size_t refcnt;
2092         JavaVM *vm;
2093         jweak o;
2094         jmethodID watch_channel_meth;
2095         jmethodID update_channel_meth;
2096         jmethodID release_pending_monitor_events_meth;
2097 } LDKWatch_JCalls;
2098 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2099         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2100         JNIEnv *_env;
2101         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2102         LDKOutPoint funding_txo_var = funding_txo;
2103         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2104         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2105         long funding_txo_ref;
2106         if (funding_txo_var.is_owned) {
2107                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2108         } else {
2109                 funding_txo_ref = (long)funding_txo_var.inner & ~1;
2110         }
2111         LDKChannelMonitor monitor_var = monitor;
2112         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2113         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2114         long monitor_ref;
2115         if (monitor_var.is_owned) {
2116                 monitor_ref = (long)monitor_var.inner | 1;
2117         } else {
2118                 monitor_ref = (long)monitor_var.inner & ~1;
2119         }
2120         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2121         CHECK(obj != NULL);
2122         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*_env)->CallLongMethod(_env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2123         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2124         FREE(ret);
2125         return res;
2126 }
2127 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2128         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2129         JNIEnv *_env;
2130         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2131         LDKOutPoint funding_txo_var = funding_txo;
2132         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2133         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2134         long funding_txo_ref;
2135         if (funding_txo_var.is_owned) {
2136                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2137         } else {
2138                 funding_txo_ref = (long)funding_txo_var.inner & ~1;
2139         }
2140         LDKChannelMonitorUpdate update_var = update;
2141         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2142         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2143         long update_ref;
2144         if (update_var.is_owned) {
2145                 update_ref = (long)update_var.inner | 1;
2146         } else {
2147                 update_ref = (long)update_var.inner & ~1;
2148         }
2149         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2150         CHECK(obj != NULL);
2151         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*_env)->CallLongMethod(_env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
2152         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2153         FREE(ret);
2154         return res;
2155 }
2156 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2157         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2158         JNIEnv *_env;
2159         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2160         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2161         CHECK(obj != NULL);
2162         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->release_pending_monitor_events_meth);
2163         LDKCVec_MonitorEventZ ret_constr;
2164         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
2165         if (ret_constr.datalen > 0)
2166                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2167         else
2168                 ret_constr.data = NULL;
2169         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
2170         for (size_t o = 0; o < ret_constr.datalen; o++) {
2171                 long arr_conv_14 = ret_vals[o];
2172                 LDKMonitorEvent arr_conv_14_conv;
2173                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
2174                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
2175                 // Warning: we may need a move here but can't clone!
2176                 ret_constr.data[o] = arr_conv_14_conv;
2177         }
2178         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
2179         return ret_constr;
2180 }
2181 static void LDKWatch_JCalls_free(void* this_arg) {
2182         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2183         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2184                 JNIEnv *env;
2185                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2186                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2187                 FREE(j_calls);
2188         }
2189 }
2190 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2191         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2192         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2193         return (void*) this_arg;
2194 }
2195 static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) {
2196         jclass c = (*env)->GetObjectClass(env, o);
2197         CHECK(c != NULL);
2198         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2199         atomic_init(&calls->refcnt, 1);
2200         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2201         calls->o = (*env)->NewWeakGlobalRef(env, o);
2202         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
2203         CHECK(calls->watch_channel_meth != NULL);
2204         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
2205         CHECK(calls->update_channel_meth != NULL);
2206         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
2207         CHECK(calls->release_pending_monitor_events_meth != NULL);
2208
2209         LDKWatch ret = {
2210                 .this_arg = (void*) calls,
2211                 .watch_channel = watch_channel_jcall,
2212                 .update_channel = update_channel_jcall,
2213                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2214                 .free = LDKWatch_JCalls_free,
2215         };
2216         return ret;
2217 }
2218 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new (JNIEnv * env, jclass _a, jobject o) {
2219         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2220         *res_ptr = LDKWatch_init(env, _a, o);
2221         return (long)res_ptr;
2222 }
2223 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2224         jobject ret = (*env)->NewLocalRef(env, ((LDKWatch_JCalls*)val)->o);
2225         CHECK(ret != NULL);
2226         return ret;
2227 }
2228 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong monitor) {
2229         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2230         LDKOutPoint funding_txo_conv;
2231         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2232         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2233         if (funding_txo_conv.inner != NULL)
2234                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2235         LDKChannelMonitor monitor_conv;
2236         monitor_conv.inner = (void*)(monitor & (~1));
2237         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2238         // Warning: we may need a move here but can't clone!
2239         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2240         *ret = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2241         return (long)ret;
2242 }
2243
2244 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong update) {
2245         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2246         LDKOutPoint funding_txo_conv;
2247         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2248         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2249         if (funding_txo_conv.inner != NULL)
2250                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2251         LDKChannelMonitorUpdate update_conv;
2252         update_conv.inner = (void*)(update & (~1));
2253         update_conv.is_owned = (update & 1) || (update == 0);
2254         if (update_conv.inner != NULL)
2255                 update_conv = ChannelMonitorUpdate_clone(&update_conv);
2256         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2257         *ret = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2258         return (long)ret;
2259 }
2260
2261 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
2262         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2263         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2264         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
2265         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
2266         for (size_t o = 0; o < ret_var.datalen; o++) {
2267                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
2268                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2269                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2270                 long arr_conv_14_ref;
2271                 if (arr_conv_14_var.is_owned) {
2272                         arr_conv_14_ref = (long)arr_conv_14_var.inner | 1;
2273                 } else {
2274                         arr_conv_14_ref = (long)arr_conv_14_var.inner & ~1;
2275                 }
2276                 ret_arr_ptr[o] = arr_conv_14_ref;
2277         }
2278         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
2279         FREE(ret_var.data);
2280         return ret_arr;
2281 }
2282
2283 typedef struct LDKFilter_JCalls {
2284         atomic_size_t refcnt;
2285         JavaVM *vm;
2286         jweak o;
2287         jmethodID register_tx_meth;
2288         jmethodID register_output_meth;
2289 } LDKFilter_JCalls;
2290 void register_tx_jcall(const void* this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey) {
2291         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2292         JNIEnv *_env;
2293         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2294         jbyteArray txid_arr = (*_env)->NewByteArray(_env, 32);
2295         (*_env)->SetByteArrayRegion(_env, txid_arr, 0, 32, *txid);
2296         LDKu8slice script_pubkey_var = script_pubkey;
2297         jbyteArray script_pubkey_arr = (*_env)->NewByteArray(_env, script_pubkey_var.datalen);
2298         (*_env)->SetByteArrayRegion(_env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
2299         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2300         CHECK(obj != NULL);
2301         return (*_env)->CallVoidMethod(_env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
2302 }
2303 void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey) {
2304         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2305         JNIEnv *_env;
2306         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2307         LDKu8slice script_pubkey_var = script_pubkey;
2308         jbyteArray script_pubkey_arr = (*_env)->NewByteArray(_env, script_pubkey_var.datalen);
2309         (*_env)->SetByteArrayRegion(_env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
2310         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2311         CHECK(obj != NULL);
2312         return (*_env)->CallVoidMethod(_env, obj, j_calls->register_output_meth, outpoint, script_pubkey_arr);
2313 }
2314 static void LDKFilter_JCalls_free(void* this_arg) {
2315         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2316         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2317                 JNIEnv *env;
2318                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2319                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2320                 FREE(j_calls);
2321         }
2322 }
2323 static void* LDKFilter_JCalls_clone(const void* this_arg) {
2324         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2325         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2326         return (void*) this_arg;
2327 }
2328 static inline LDKFilter LDKFilter_init (JNIEnv * env, jclass _a, jobject o) {
2329         jclass c = (*env)->GetObjectClass(env, o);
2330         CHECK(c != NULL);
2331         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
2332         atomic_init(&calls->refcnt, 1);
2333         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2334         calls->o = (*env)->NewWeakGlobalRef(env, o);
2335         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
2336         CHECK(calls->register_tx_meth != NULL);
2337         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V");
2338         CHECK(calls->register_output_meth != NULL);
2339
2340         LDKFilter ret = {
2341                 .this_arg = (void*) calls,
2342                 .register_tx = register_tx_jcall,
2343                 .register_output = register_output_jcall,
2344                 .free = LDKFilter_JCalls_free,
2345         };
2346         return ret;
2347 }
2348 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new (JNIEnv * env, jclass _a, jobject o) {
2349         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
2350         *res_ptr = LDKFilter_init(env, _a, o);
2351         return (long)res_ptr;
2352 }
2353 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFilter_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2354         jobject ret = (*env)->NewLocalRef(env, ((LDKFilter_JCalls*)val)->o);
2355         CHECK(ret != NULL);
2356         return ret;
2357 }
2358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray txid, jbyteArray script_pubkey) {
2359         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2360         unsigned char txid_arr[32];
2361         CHECK((*_env)->GetArrayLength (_env, txid) == 32);
2362         (*_env)->GetByteArrayRegion (_env, txid, 0, 32, txid_arr);
2363         unsigned char (*txid_ref)[32] = &txid_arr;
2364         LDKu8slice script_pubkey_ref;
2365         script_pubkey_ref.data = (*_env)->GetByteArrayElements (_env, script_pubkey, NULL);
2366         script_pubkey_ref.datalen = (*_env)->GetArrayLength (_env, script_pubkey);
2367         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
2368         (*_env)->ReleaseByteArrayElements(_env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
2369 }
2370
2371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv * _env, jclass _b, jlong this_arg, jlong outpoint, jbyteArray script_pubkey) {
2372         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2373         LDKOutPoint outpoint_conv;
2374         outpoint_conv.inner = (void*)(outpoint & (~1));
2375         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
2376         LDKu8slice script_pubkey_ref;
2377         script_pubkey_ref.data = (*_env)->GetByteArrayElements (_env, script_pubkey, NULL);
2378         script_pubkey_ref.datalen = (*_env)->GetArrayLength (_env, script_pubkey);
2379         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
2380         (*_env)->ReleaseByteArrayElements(_env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
2381 }
2382
2383 typedef struct LDKBroadcasterInterface_JCalls {
2384         atomic_size_t refcnt;
2385         JavaVM *vm;
2386         jweak o;
2387         jmethodID broadcast_transaction_meth;
2388 } LDKBroadcasterInterface_JCalls;
2389 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2390         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2391         JNIEnv *_env;
2392         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2393         long tx_ref = (long)&tx;
2394         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2395         CHECK(obj != NULL);
2396         return (*_env)->CallVoidMethod(_env, obj, j_calls->broadcast_transaction_meth, tx_ref);
2397 }
2398 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2399         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2400         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2401                 JNIEnv *env;
2402                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2403                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2404                 FREE(j_calls);
2405         }
2406 }
2407 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2408         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2409         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2410         return (void*) this_arg;
2411 }
2412 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv * env, jclass _a, jobject o) {
2413         jclass c = (*env)->GetObjectClass(env, o);
2414         CHECK(c != NULL);
2415         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2416         atomic_init(&calls->refcnt, 1);
2417         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2418         calls->o = (*env)->NewWeakGlobalRef(env, o);
2419         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "(J)V");
2420         CHECK(calls->broadcast_transaction_meth != NULL);
2421
2422         LDKBroadcasterInterface ret = {
2423                 .this_arg = (void*) calls,
2424                 .broadcast_transaction = broadcast_transaction_jcall,
2425                 .free = LDKBroadcasterInterface_JCalls_free,
2426         };
2427         return ret;
2428 }
2429 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2430         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2431         *res_ptr = LDKBroadcasterInterface_init(env, _a, o);
2432         return (long)res_ptr;
2433 }
2434 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2435         jobject ret = (*env)->NewLocalRef(env, ((LDKBroadcasterInterface_JCalls*)val)->o);
2436         CHECK(ret != NULL);
2437         return ret;
2438 }
2439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong tx) {
2440         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
2441         LDKTransaction tx_conv = *(LDKTransaction*)tx;
2442         FREE((void*)tx);
2443         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_conv);
2444 }
2445
2446 typedef struct LDKFeeEstimator_JCalls {
2447         atomic_size_t refcnt;
2448         JavaVM *vm;
2449         jweak o;
2450         jmethodID get_est_sat_per_1000_weight_meth;
2451 } LDKFeeEstimator_JCalls;
2452 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2453         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2454         JNIEnv *_env;
2455         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2456         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(_env, confirmation_target);
2457         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2458         CHECK(obj != NULL);
2459         return (*_env)->CallIntMethod(_env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2460 }
2461 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2462         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2463         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2464                 JNIEnv *env;
2465                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2466                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2467                 FREE(j_calls);
2468         }
2469 }
2470 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2471         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2472         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2473         return (void*) this_arg;
2474 }
2475 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv * env, jclass _a, jobject o) {
2476         jclass c = (*env)->GetObjectClass(env, o);
2477         CHECK(c != NULL);
2478         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2479         atomic_init(&calls->refcnt, 1);
2480         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2481         calls->o = (*env)->NewWeakGlobalRef(env, o);
2482         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
2483         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
2484
2485         LDKFeeEstimator ret = {
2486                 .this_arg = (void*) calls,
2487                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2488                 .free = LDKFeeEstimator_JCalls_free,
2489         };
2490         return ret;
2491 }
2492 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new (JNIEnv * env, jclass _a, jobject o) {
2493         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2494         *res_ptr = LDKFeeEstimator_init(env, _a, o);
2495         return (long)res_ptr;
2496 }
2497 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2498         jobject ret = (*env)->NewLocalRef(env, ((LDKFeeEstimator_JCalls*)val)->o);
2499         CHECK(ret != NULL);
2500         return ret;
2501 }
2502 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) {
2503         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
2504         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(_env, confirmation_target);
2505         jint ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2506         return ret_val;
2507 }
2508
2509 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2510         LDKCVecTempl_C2TupleTempl_usize__Transaction *vec = (LDKCVecTempl_C2TupleTempl_usize__Transaction*)ptr;
2511         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_usize__Transaction));
2512 }
2513 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2514         LDKCVecTempl_C2TupleTempl_usize__Transaction *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_usize__Transaction), "LDKCVecTempl_C2TupleTempl_usize__Transaction");
2515         ret->datalen = (*env)->GetArrayLength(env, elems);
2516         if (ret->datalen == 0) {
2517                 ret->data = NULL;
2518         } else {
2519                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction) * ret->datalen, "LDKCVecTempl_C2TupleTempl_usize__Transaction Data");
2520                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2521                 for (size_t i = 0; i < ret->datalen; i++) {
2522                         jlong arr_elem = java_elems[i];
2523                         LDKC2TupleTempl_usize__Transaction arr_elem_conv = *(LDKC2TupleTempl_usize__Transaction*)arr_elem;
2524                         FREE((void*)arr_elem);
2525                         ret->data[i] = arr_elem_conv;
2526                 }
2527                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2528         }
2529         return (long)ret;
2530 }
2531 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2532         LDKCVecTempl_Transaction *vec = (LDKCVecTempl_Transaction*)ptr;
2533         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTransaction));
2534 }
2535 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2536         LDKCVecTempl_Transaction *ret = MALLOC(sizeof(LDKCVecTempl_Transaction), "LDKCVecTempl_Transaction");
2537         ret->datalen = (*env)->GetArrayLength(env, elems);
2538         if (ret->datalen == 0) {
2539                 ret->data = NULL;
2540         } else {
2541                 ret->data = MALLOC(sizeof(LDKTransaction) * ret->datalen, "LDKCVecTempl_Transaction Data");
2542                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2543                 for (size_t i = 0; i < ret->datalen; i++) {
2544                         jlong arr_elem = java_elems[i];
2545                         LDKTransaction arr_elem_conv = *(LDKTransaction*)arr_elem;
2546                         FREE((void*)arr_elem);
2547                         ret->data[i] = arr_elem_conv;
2548                 }
2549                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2550         }
2551         return (long)ret;
2552 }
2553 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2554         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *vec = (LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)ptr;
2555         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut));
2556 }
2557 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
2558         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
2559         ret->datalen = (*env)->GetArrayLength(env, elems);
2560         if (ret->datalen == 0) {
2561                 ret->data = NULL;
2562         } else {
2563                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut) * ret->datalen, "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut Data");
2564                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2565                 for (size_t i = 0; i < ret->datalen; i++) {
2566                         jlong arr_elem = java_elems[i];
2567                         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut arr_elem_conv = *(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)arr_elem;
2568                         FREE((void*)arr_elem);
2569                         ret->data[i] = arr_elem_conv;
2570                 }
2571                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2572         }
2573         return (long)ret;
2574 }
2575 typedef struct LDKKeysInterface_JCalls {
2576         atomic_size_t refcnt;
2577         JavaVM *vm;
2578         jweak o;
2579         jmethodID get_node_secret_meth;
2580         jmethodID get_destination_script_meth;
2581         jmethodID get_shutdown_pubkey_meth;
2582         jmethodID get_channel_keys_meth;
2583         jmethodID get_secure_random_bytes_meth;
2584 } LDKKeysInterface_JCalls;
2585 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2586         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2587         JNIEnv *_env;
2588         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2589         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2590         CHECK(obj != NULL);
2591         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_node_secret_meth);
2592         LDKSecretKey ret_ref;
2593         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
2594         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.bytes);
2595         return ret_ref;
2596 }
2597 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
2598         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2599         JNIEnv *_env;
2600         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2601         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2602         CHECK(obj != NULL);
2603         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_destination_script_meth);
2604         LDKCVec_u8Z ret_ref;
2605         ret_ref.data = (*_env)->GetByteArrayElements (_env, ret, NULL);
2606         ret_ref.datalen = (*_env)->GetArrayLength (_env, ret);
2607         return ret_ref;
2608 }
2609 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
2610         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2611         JNIEnv *_env;
2612         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2613         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2614         CHECK(obj != NULL);
2615         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_shutdown_pubkey_meth);
2616         LDKPublicKey ret_ref;
2617         CHECK((*_env)->GetArrayLength (_env, ret) == 33);
2618         (*_env)->GetByteArrayRegion (_env, ret, 0, 33, ret_ref.compressed_form);
2619         return ret_ref;
2620 }
2621 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2622         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2623         JNIEnv *_env;
2624         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2625         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2626         CHECK(obj != NULL);
2627         LDKChannelKeys* ret = (LDKChannelKeys*)(*_env)->CallLongMethod(_env, obj, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
2628         LDKChannelKeys res = *ret;
2629         FREE(ret);
2630         return res;
2631 }
2632 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2633         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2634         JNIEnv *_env;
2635         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2636         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2637         CHECK(obj != NULL);
2638         jbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_secure_random_bytes_meth);
2639         LDKThirtyTwoBytes ret_ref;
2640         CHECK((*_env)->GetArrayLength (_env, ret) == 32);
2641         (*_env)->GetByteArrayRegion (_env, ret, 0, 32, ret_ref.data);
2642         return ret_ref;
2643 }
2644 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2645         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2646         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2647                 JNIEnv *env;
2648                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2649                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2650                 FREE(j_calls);
2651         }
2652 }
2653 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2654         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2655         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2656         return (void*) this_arg;
2657 }
2658 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv * env, jclass _a, jobject o) {
2659         jclass c = (*env)->GetObjectClass(env, o);
2660         CHECK(c != NULL);
2661         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2662         atomic_init(&calls->refcnt, 1);
2663         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2664         calls->o = (*env)->NewWeakGlobalRef(env, o);
2665         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
2666         CHECK(calls->get_node_secret_meth != NULL);
2667         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
2668         CHECK(calls->get_destination_script_meth != NULL);
2669         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
2670         CHECK(calls->get_shutdown_pubkey_meth != NULL);
2671         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
2672         CHECK(calls->get_channel_keys_meth != NULL);
2673         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
2674         CHECK(calls->get_secure_random_bytes_meth != NULL);
2675
2676         LDKKeysInterface ret = {
2677                 .this_arg = (void*) calls,
2678                 .get_node_secret = get_node_secret_jcall,
2679                 .get_destination_script = get_destination_script_jcall,
2680                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2681                 .get_channel_keys = get_channel_keys_jcall,
2682                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2683                 .free = LDKKeysInterface_JCalls_free,
2684         };
2685         return ret;
2686 }
2687 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2688         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2689         *res_ptr = LDKKeysInterface_init(env, _a, o);
2690         return (long)res_ptr;
2691 }
2692 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2693         jobject ret = (*env)->NewLocalRef(env, ((LDKKeysInterface_JCalls*)val)->o);
2694         CHECK(ret != NULL);
2695         return ret;
2696 }
2697 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv * _env, jclass _b, jlong this_arg) {
2698         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2699         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2700         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
2701         return arg_arr;
2702 }
2703
2704 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv * _env, jclass _b, jlong this_arg) {
2705         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2706         LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2707         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
2708         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
2709         CVec_u8Z_free(arg_var);
2710         return arg_arr;
2711 }
2712
2713 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_arg) {
2714         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2715         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
2716         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
2717         return arg_arr;
2718 }
2719
2720 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) {
2721         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2722         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2723         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2724         return (long)ret;
2725 }
2726
2727 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv * _env, jclass _b, jlong this_arg) {
2728         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2729         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2730         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
2731         return arg_arr;
2732 }
2733
2734 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2735         LDKCVecTempl_ChannelDetails *vec = (LDKCVecTempl_ChannelDetails*)ptr;
2736         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2737         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2738         for (size_t i = 0; i < vec->datalen; i++) {
2739                 CHECK((((long)vec->data[i].inner) & 1) == 0);
2740                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2741         }
2742         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2743         return ret;
2744 }
2745 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1new(JNIEnv *env, jclass _b, jlongArray elems){
2746         LDKCVecTempl_ChannelDetails *ret = MALLOC(sizeof(LDKCVecTempl_ChannelDetails), "LDKCVecTempl_ChannelDetails");
2747         ret->datalen = (*env)->GetArrayLength(env, elems);
2748         if (ret->datalen == 0) {
2749                 ret->data = NULL;
2750         } else {
2751                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVecTempl_ChannelDetails Data");
2752                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2753                 for (size_t i = 0; i < ret->datalen; i++) {
2754                         jlong arr_elem = java_elems[i];
2755                         LDKChannelDetails arr_elem_conv;
2756                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2757                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2758                         if (arr_elem_conv.inner != NULL)
2759                                 arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2760                         ret->data[i] = arr_elem_conv;
2761                 }
2762                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2763         }
2764         return (long)ret;
2765 }
2766 static jclass LDKNetAddress_IPv4_class = NULL;
2767 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2768 static jclass LDKNetAddress_IPv6_class = NULL;
2769 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2770 static jclass LDKNetAddress_OnionV2_class = NULL;
2771 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2772 static jclass LDKNetAddress_OnionV3_class = NULL;
2773 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv * env, jclass _a) {
2775         LDKNetAddress_IPv4_class =
2776                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2777         CHECK(LDKNetAddress_IPv4_class != NULL);
2778         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
2779         CHECK(LDKNetAddress_IPv4_meth != NULL);
2780         LDKNetAddress_IPv6_class =
2781                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2782         CHECK(LDKNetAddress_IPv6_class != NULL);
2783         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
2784         CHECK(LDKNetAddress_IPv6_meth != NULL);
2785         LDKNetAddress_OnionV2_class =
2786                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2787         CHECK(LDKNetAddress_OnionV2_class != NULL);
2788         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
2789         CHECK(LDKNetAddress_OnionV2_meth != NULL);
2790         LDKNetAddress_OnionV3_class =
2791                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2792         CHECK(LDKNetAddress_OnionV3_class != NULL);
2793         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2794         CHECK(LDKNetAddress_OnionV3_meth != NULL);
2795 }
2796 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {
2797         LDKNetAddress *obj = (LDKNetAddress*)ptr;
2798         switch(obj->tag) {
2799                 case LDKNetAddress_IPv4: {
2800                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 4);
2801                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 4, obj->i_pv4.addr.data);
2802                         return (*_env)->NewObject(_env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
2803                 }
2804                 case LDKNetAddress_IPv6: {
2805                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 16);
2806                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 16, obj->i_pv6.addr.data);
2807                         return (*_env)->NewObject(_env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
2808                 }
2809                 case LDKNetAddress_OnionV2: {
2810                         jbyteArray addr_arr = (*_env)->NewByteArray(_env, 10);
2811                         (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 10, obj->onion_v2.addr.data);
2812                         return (*_env)->NewObject(_env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
2813                 }
2814                 case LDKNetAddress_OnionV3: {
2815                         jbyteArray ed25519_pubkey_arr = (*_env)->NewByteArray(_env, 32);
2816                         (*_env)->SetByteArrayRegion(_env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2817                         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);
2818                 }
2819                 default: abort();
2820         }
2821 }
2822 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2823         LDKCVecTempl_NetAddress *vec = (LDKCVecTempl_NetAddress*)ptr;
2824         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKNetAddress));
2825 }
2826 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1new(JNIEnv *env, jclass _b, jlongArray elems){
2827         LDKCVecTempl_NetAddress *ret = MALLOC(sizeof(LDKCVecTempl_NetAddress), "LDKCVecTempl_NetAddress");
2828         ret->datalen = (*env)->GetArrayLength(env, elems);
2829         if (ret->datalen == 0) {
2830                 ret->data = NULL;
2831         } else {
2832                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVecTempl_NetAddress Data");
2833                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2834                 for (size_t i = 0; i < ret->datalen; i++) {
2835                         jlong arr_elem = java_elems[i];
2836                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
2837                         FREE((void*)arr_elem);
2838                         ret->data[i] = arr_elem_conv;
2839                 }
2840                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2841         }
2842         return (long)ret;
2843 }
2844 typedef struct LDKChannelMessageHandler_JCalls {
2845         atomic_size_t refcnt;
2846         JavaVM *vm;
2847         jweak o;
2848         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
2849         jmethodID handle_open_channel_meth;
2850         jmethodID handle_accept_channel_meth;
2851         jmethodID handle_funding_created_meth;
2852         jmethodID handle_funding_signed_meth;
2853         jmethodID handle_funding_locked_meth;
2854         jmethodID handle_shutdown_meth;
2855         jmethodID handle_closing_signed_meth;
2856         jmethodID handle_update_add_htlc_meth;
2857         jmethodID handle_update_fulfill_htlc_meth;
2858         jmethodID handle_update_fail_htlc_meth;
2859         jmethodID handle_update_fail_malformed_htlc_meth;
2860         jmethodID handle_commitment_signed_meth;
2861         jmethodID handle_revoke_and_ack_meth;
2862         jmethodID handle_update_fee_meth;
2863         jmethodID handle_announcement_signatures_meth;
2864         jmethodID peer_disconnected_meth;
2865         jmethodID peer_connected_meth;
2866         jmethodID handle_channel_reestablish_meth;
2867         jmethodID handle_error_meth;
2868 } LDKChannelMessageHandler_JCalls;
2869 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg) {
2870         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2871         JNIEnv *_env;
2872         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2873         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2874         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2875         LDKInitFeatures their_features_var = their_features;
2876         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2877         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2878         long their_features_ref;
2879         if (their_features_var.is_owned) {
2880                 their_features_ref = (long)their_features_var.inner | 1;
2881         } else {
2882                 their_features_ref = (long)their_features_var.inner & ~1;
2883         }
2884         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2885         CHECK(obj != NULL);
2886         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg);
2887 }
2888 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) {
2889         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2890         JNIEnv *_env;
2891         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2892         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2893         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2894         LDKInitFeatures their_features_var = their_features;
2895         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2896         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2897         long their_features_ref;
2898         if (their_features_var.is_owned) {
2899                 their_features_ref = (long)their_features_var.inner | 1;
2900         } else {
2901                 their_features_ref = (long)their_features_var.inner & ~1;
2902         }
2903         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2904         CHECK(obj != NULL);
2905         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg);
2906 }
2907 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg) {
2908         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2909         JNIEnv *_env;
2910         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2911         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2912         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2913         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2914         CHECK(obj != NULL);
2915         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg);
2916 }
2917 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) {
2918         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2919         JNIEnv *_env;
2920         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2921         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2922         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2923         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2924         CHECK(obj != NULL);
2925         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg);
2926 }
2927 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg) {
2928         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2929         JNIEnv *_env;
2930         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2931         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2932         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2933         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2934         CHECK(obj != NULL);
2935         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg);
2936 }
2937 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) {
2938         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2939         JNIEnv *_env;
2940         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2941         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2942         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2943         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2944         CHECK(obj != NULL);
2945         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg);
2946 }
2947 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) {
2948         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2949         JNIEnv *_env;
2950         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2951         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2952         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2953         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2954         CHECK(obj != NULL);
2955         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg);
2956 }
2957 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) {
2958         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2959         JNIEnv *_env;
2960         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2961         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2962         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2963         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2964         CHECK(obj != NULL);
2965         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg);
2966 }
2967 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) {
2968         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2969         JNIEnv *_env;
2970         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2971         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2972         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2973         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2974         CHECK(obj != NULL);
2975         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg);
2976 }
2977 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) {
2978         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2979         JNIEnv *_env;
2980         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2981         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2982         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2983         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2984         CHECK(obj != NULL);
2985         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg);
2986 }
2987 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) {
2988         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2989         JNIEnv *_env;
2990         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
2991         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
2992         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2993         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
2994         CHECK(obj != NULL);
2995         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg);
2996 }
2997 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) {
2998         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2999         JNIEnv *_env;
3000         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3001         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3002         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3003         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3004         CHECK(obj != NULL);
3005         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg);
3006 }
3007 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) {
3008         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3009         JNIEnv *_env;
3010         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3011         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3012         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3013         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3014         CHECK(obj != NULL);
3015         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg);
3016 }
3017 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) {
3018         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3019         JNIEnv *_env;
3020         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3021         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3022         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3023         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3024         CHECK(obj != NULL);
3025         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg);
3026 }
3027 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) {
3028         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3029         JNIEnv *_env;
3030         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3031         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3032         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3033         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3034         CHECK(obj != NULL);
3035         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg);
3036 }
3037 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
3038         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3039         JNIEnv *_env;
3040         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3041         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3042         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3043         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3044         CHECK(obj != NULL);
3045         return (*_env)->CallVoidMethod(_env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
3046 }
3047 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit *msg) {
3048         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3049         JNIEnv *_env;
3050         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3051         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3052         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3053         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3054         CHECK(obj != NULL);
3055         return (*_env)->CallVoidMethod(_env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg);
3056 }
3057 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) {
3058         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3059         JNIEnv *_env;
3060         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3061         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3062         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3063         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3064         CHECK(obj != NULL);
3065         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg);
3066 }
3067 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) {
3068         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3069         JNIEnv *_env;
3070         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3071         jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33);
3072         (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
3073         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3074         CHECK(obj != NULL);
3075         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_error_meth, their_node_id_arr, msg);
3076 }
3077 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
3078         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3079         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3080                 JNIEnv *env;
3081                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3082                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3083                 FREE(j_calls);
3084         }
3085 }
3086 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
3087         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3088         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3089         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
3090         return (void*) this_arg;
3091 }
3092 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
3093         jclass c = (*env)->GetObjectClass(env, o);
3094         CHECK(c != NULL);
3095         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
3096         atomic_init(&calls->refcnt, 1);
3097         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3098         calls->o = (*env)->NewWeakGlobalRef(env, o);
3099         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
3100         CHECK(calls->handle_open_channel_meth != NULL);
3101         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
3102         CHECK(calls->handle_accept_channel_meth != NULL);
3103         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
3104         CHECK(calls->handle_funding_created_meth != NULL);
3105         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
3106         CHECK(calls->handle_funding_signed_meth != NULL);
3107         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
3108         CHECK(calls->handle_funding_locked_meth != NULL);
3109         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
3110         CHECK(calls->handle_shutdown_meth != NULL);
3111         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
3112         CHECK(calls->handle_closing_signed_meth != NULL);
3113         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
3114         CHECK(calls->handle_update_add_htlc_meth != NULL);
3115         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
3116         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
3117         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
3118         CHECK(calls->handle_update_fail_htlc_meth != NULL);
3119         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
3120         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
3121         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
3122         CHECK(calls->handle_commitment_signed_meth != NULL);
3123         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
3124         CHECK(calls->handle_revoke_and_ack_meth != NULL);
3125         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
3126         CHECK(calls->handle_update_fee_meth != NULL);
3127         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
3128         CHECK(calls->handle_announcement_signatures_meth != NULL);
3129         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
3130         CHECK(calls->peer_disconnected_meth != NULL);
3131         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
3132         CHECK(calls->peer_connected_meth != NULL);
3133         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
3134         CHECK(calls->handle_channel_reestablish_meth != NULL);
3135         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
3136         CHECK(calls->handle_error_meth != NULL);
3137
3138         LDKChannelMessageHandler ret = {
3139                 .this_arg = (void*) calls,
3140                 .handle_open_channel = handle_open_channel_jcall,
3141                 .handle_accept_channel = handle_accept_channel_jcall,
3142                 .handle_funding_created = handle_funding_created_jcall,
3143                 .handle_funding_signed = handle_funding_signed_jcall,
3144                 .handle_funding_locked = handle_funding_locked_jcall,
3145                 .handle_shutdown = handle_shutdown_jcall,
3146                 .handle_closing_signed = handle_closing_signed_jcall,
3147                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3148                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3149                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3150                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3151                 .handle_commitment_signed = handle_commitment_signed_jcall,
3152                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3153                 .handle_update_fee = handle_update_fee_jcall,
3154                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3155                 .peer_disconnected = peer_disconnected_jcall,
3156                 .peer_connected = peer_connected_jcall,
3157                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3158                 .handle_error = handle_error_jcall,
3159                 .free = LDKChannelMessageHandler_JCalls_free,
3160                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, _a, MessageSendEventsProvider),
3161         };
3162         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3163         return ret;
3164 }
3165 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
3166         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3167         *res_ptr = LDKChannelMessageHandler_init(env, _a, o, MessageSendEventsProvider);
3168         return (long)res_ptr;
3169 }
3170 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3171         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelMessageHandler_JCalls*)val)->o);
3172         CHECK(ret != NULL);
3173         return ret;
3174 }
3175 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) {
3176         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3177         LDKPublicKey their_node_id_ref;
3178         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3179         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3180         LDKInitFeatures their_features_conv;
3181         their_features_conv.inner = (void*)(their_features & (~1));
3182         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3183         // Warning: we may need a move here but can't clone!
3184         LDKOpenChannel msg_conv;
3185         msg_conv.inner = (void*)(msg & (~1));
3186         msg_conv.is_owned = (msg & 1) || (msg == 0);
3187         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3188 }
3189
3190 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) {
3191         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3192         LDKPublicKey their_node_id_ref;
3193         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3194         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3195         LDKInitFeatures their_features_conv;
3196         their_features_conv.inner = (void*)(their_features & (~1));
3197         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3198         // Warning: we may need a move here but can't clone!
3199         LDKAcceptChannel msg_conv;
3200         msg_conv.inner = (void*)(msg & (~1));
3201         msg_conv.is_owned = (msg & 1) || (msg == 0);
3202         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3203 }
3204
3205 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) {
3206         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3207         LDKPublicKey their_node_id_ref;
3208         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3209         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3210         LDKFundingCreated msg_conv;
3211         msg_conv.inner = (void*)(msg & (~1));
3212         msg_conv.is_owned = (msg & 1) || (msg == 0);
3213         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3214 }
3215
3216 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) {
3217         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3218         LDKPublicKey their_node_id_ref;
3219         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3220         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3221         LDKFundingSigned msg_conv;
3222         msg_conv.inner = (void*)(msg & (~1));
3223         msg_conv.is_owned = (msg & 1) || (msg == 0);
3224         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3225 }
3226
3227 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) {
3228         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3229         LDKPublicKey their_node_id_ref;
3230         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3231         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3232         LDKFundingLocked msg_conv;
3233         msg_conv.inner = (void*)(msg & (~1));
3234         msg_conv.is_owned = (msg & 1) || (msg == 0);
3235         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3236 }
3237
3238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3239         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3240         LDKPublicKey their_node_id_ref;
3241         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3242         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3243         LDKShutdown msg_conv;
3244         msg_conv.inner = (void*)(msg & (~1));
3245         msg_conv.is_owned = (msg & 1) || (msg == 0);
3246         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3247 }
3248
3249 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) {
3250         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3251         LDKPublicKey their_node_id_ref;
3252         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3253         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3254         LDKClosingSigned msg_conv;
3255         msg_conv.inner = (void*)(msg & (~1));
3256         msg_conv.is_owned = (msg & 1) || (msg == 0);
3257         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3258 }
3259
3260 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) {
3261         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3262         LDKPublicKey their_node_id_ref;
3263         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3264         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3265         LDKUpdateAddHTLC msg_conv;
3266         msg_conv.inner = (void*)(msg & (~1));
3267         msg_conv.is_owned = (msg & 1) || (msg == 0);
3268         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3269 }
3270
3271 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) {
3272         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3273         LDKPublicKey their_node_id_ref;
3274         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3275         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3276         LDKUpdateFulfillHTLC msg_conv;
3277         msg_conv.inner = (void*)(msg & (~1));
3278         msg_conv.is_owned = (msg & 1) || (msg == 0);
3279         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3280 }
3281
3282 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) {
3283         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3284         LDKPublicKey their_node_id_ref;
3285         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3286         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3287         LDKUpdateFailHTLC msg_conv;
3288         msg_conv.inner = (void*)(msg & (~1));
3289         msg_conv.is_owned = (msg & 1) || (msg == 0);
3290         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3291 }
3292
3293 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) {
3294         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3295         LDKPublicKey their_node_id_ref;
3296         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3297         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3298         LDKUpdateFailMalformedHTLC msg_conv;
3299         msg_conv.inner = (void*)(msg & (~1));
3300         msg_conv.is_owned = (msg & 1) || (msg == 0);
3301         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3302 }
3303
3304 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) {
3305         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3306         LDKPublicKey their_node_id_ref;
3307         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3308         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3309         LDKCommitmentSigned msg_conv;
3310         msg_conv.inner = (void*)(msg & (~1));
3311         msg_conv.is_owned = (msg & 1) || (msg == 0);
3312         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3313 }
3314
3315 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) {
3316         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3317         LDKPublicKey their_node_id_ref;
3318         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3319         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3320         LDKRevokeAndACK msg_conv;
3321         msg_conv.inner = (void*)(msg & (~1));
3322         msg_conv.is_owned = (msg & 1) || (msg == 0);
3323         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3324 }
3325
3326 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) {
3327         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3328         LDKPublicKey their_node_id_ref;
3329         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3330         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3331         LDKUpdateFee msg_conv;
3332         msg_conv.inner = (void*)(msg & (~1));
3333         msg_conv.is_owned = (msg & 1) || (msg == 0);
3334         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3335 }
3336
3337 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) {
3338         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3339         LDKPublicKey their_node_id_ref;
3340         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3341         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3342         LDKAnnouncementSignatures msg_conv;
3343         msg_conv.inner = (void*)(msg & (~1));
3344         msg_conv.is_owned = (msg & 1) || (msg == 0);
3345         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3346 }
3347
3348 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) {
3349         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3350         LDKPublicKey their_node_id_ref;
3351         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3352         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3353         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
3354 }
3355
3356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3357         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3358         LDKPublicKey their_node_id_ref;
3359         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3360         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3361         LDKInit msg_conv;
3362         msg_conv.inner = (void*)(msg & (~1));
3363         msg_conv.is_owned = (msg & 1) || (msg == 0);
3364         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3365 }
3366
3367 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) {
3368         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3369         LDKPublicKey their_node_id_ref;
3370         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3371         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3372         LDKChannelReestablish msg_conv;
3373         msg_conv.inner = (void*)(msg & (~1));
3374         msg_conv.is_owned = (msg & 1) || (msg == 0);
3375         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3376 }
3377
3378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1error(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3379         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3380         LDKPublicKey their_node_id_ref;
3381         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3382         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3383         LDKErrorMessage msg_conv;
3384         msg_conv.inner = (void*)(msg & (~1));
3385         msg_conv.is_owned = (msg & 1) || (msg == 0);
3386         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3387 }
3388
3389 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3390         LDKCVecTempl_ChannelMonitor *vec = (LDKCVecTempl_ChannelMonitor*)ptr;
3391         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3392         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3393         for (size_t i = 0; i < vec->datalen; i++) {
3394                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3395                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3396         }
3397         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3398         return ret;
3399 }
3400 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1new(JNIEnv *env, jclass _b, jlongArray elems){
3401         LDKCVecTempl_ChannelMonitor *ret = MALLOC(sizeof(LDKCVecTempl_ChannelMonitor), "LDKCVecTempl_ChannelMonitor");
3402         ret->datalen = (*env)->GetArrayLength(env, elems);
3403         if (ret->datalen == 0) {
3404                 ret->data = NULL;
3405         } else {
3406                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVecTempl_ChannelMonitor Data");
3407                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3408                 for (size_t i = 0; i < ret->datalen; i++) {
3409                         jlong arr_elem = java_elems[i];
3410                         LDKChannelMonitor arr_elem_conv;
3411                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3412                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3413                         // Warning: we may need a move here but can't clone!
3414                         ret->data[i] = arr_elem_conv;
3415                 }
3416                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3417         }
3418         return (long)ret;
3419 }
3420 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3421         LDKCVecTempl_u64 *vec = (LDKCVecTempl_u64*)ptr;
3422         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint64_t));
3423 }
3424 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1new(JNIEnv *env, jclass _b, jlongArray elems){
3425         LDKCVecTempl_u64 *ret = MALLOC(sizeof(LDKCVecTempl_u64), "LDKCVecTempl_u64");
3426         ret->datalen = (*env)->GetArrayLength(env, elems);
3427         if (ret->datalen == 0) {
3428                 ret->data = NULL;
3429         } else {
3430                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVecTempl_u64 Data");
3431                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3432                 for (size_t i = 0; i < ret->datalen; i++) {
3433                         ret->data[i] = java_elems[i];
3434                 }
3435                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3436         }
3437         return (long)ret;
3438 }
3439 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3440         LDKCVecTempl_UpdateAddHTLC *vec = (LDKCVecTempl_UpdateAddHTLC*)ptr;
3441         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3442         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3443         for (size_t i = 0; i < vec->datalen; i++) {
3444                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3445                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3446         }
3447         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3448         return ret;
3449 }
3450 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3451         LDKCVecTempl_UpdateAddHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateAddHTLC), "LDKCVecTempl_UpdateAddHTLC");
3452         ret->datalen = (*env)->GetArrayLength(env, elems);
3453         if (ret->datalen == 0) {
3454                 ret->data = NULL;
3455         } else {
3456                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVecTempl_UpdateAddHTLC Data");
3457                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3458                 for (size_t i = 0; i < ret->datalen; i++) {
3459                         jlong arr_elem = java_elems[i];
3460                         LDKUpdateAddHTLC arr_elem_conv;
3461                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3462                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3463                         if (arr_elem_conv.inner != NULL)
3464                                 arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3465                         ret->data[i] = arr_elem_conv;
3466                 }
3467                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3468         }
3469         return (long)ret;
3470 }
3471 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3472         LDKCVecTempl_UpdateFulfillHTLC *vec = (LDKCVecTempl_UpdateFulfillHTLC*)ptr;
3473         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3474         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3475         for (size_t i = 0; i < vec->datalen; i++) {
3476                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3477                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3478         }
3479         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3480         return ret;
3481 }
3482 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3483         LDKCVecTempl_UpdateFulfillHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFulfillHTLC), "LDKCVecTempl_UpdateFulfillHTLC");
3484         ret->datalen = (*env)->GetArrayLength(env, elems);
3485         if (ret->datalen == 0) {
3486                 ret->data = NULL;
3487         } else {
3488                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVecTempl_UpdateFulfillHTLC Data");
3489                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3490                 for (size_t i = 0; i < ret->datalen; i++) {
3491                         jlong arr_elem = java_elems[i];
3492                         LDKUpdateFulfillHTLC arr_elem_conv;
3493                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3494                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3495                         if (arr_elem_conv.inner != NULL)
3496                                 arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3497                         ret->data[i] = arr_elem_conv;
3498                 }
3499                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3500         }
3501         return (long)ret;
3502 }
3503 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3504         LDKCVecTempl_UpdateFailHTLC *vec = (LDKCVecTempl_UpdateFailHTLC*)ptr;
3505         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3506         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3507         for (size_t i = 0; i < vec->datalen; i++) {
3508                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3509                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3510         }
3511         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3512         return ret;
3513 }
3514 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3515         LDKCVecTempl_UpdateFailHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailHTLC), "LDKCVecTempl_UpdateFailHTLC");
3516         ret->datalen = (*env)->GetArrayLength(env, elems);
3517         if (ret->datalen == 0) {
3518                 ret->data = NULL;
3519         } else {
3520                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailHTLC Data");
3521                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3522                 for (size_t i = 0; i < ret->datalen; i++) {
3523                         jlong arr_elem = java_elems[i];
3524                         LDKUpdateFailHTLC arr_elem_conv;
3525                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3526                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3527                         if (arr_elem_conv.inner != NULL)
3528                                 arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3529                         ret->data[i] = arr_elem_conv;
3530                 }
3531                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3532         }
3533         return (long)ret;
3534 }
3535 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3536         LDKCVecTempl_UpdateFailMalformedHTLC *vec = (LDKCVecTempl_UpdateFailMalformedHTLC*)ptr;
3537         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3538         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3539         for (size_t i = 0; i < vec->datalen; i++) {
3540                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3541                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3542         }
3543         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3544         return ret;
3545 }
3546 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3547         LDKCVecTempl_UpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailMalformedHTLC), "LDKCVecTempl_UpdateFailMalformedHTLC");
3548         ret->datalen = (*env)->GetArrayLength(env, elems);
3549         if (ret->datalen == 0) {
3550                 ret->data = NULL;
3551         } else {
3552                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailMalformedHTLC Data");
3553                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3554                 for (size_t i = 0; i < ret->datalen; i++) {
3555                         jlong arr_elem = java_elems[i];
3556                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3557                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3558                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3559                         if (arr_elem_conv.inner != NULL)
3560                                 arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3561                         ret->data[i] = arr_elem_conv;
3562                 }
3563                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3564         }
3565         return (long)ret;
3566 }
3567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3568         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3569 }
3570 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
3571         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
3572         CHECK(val->result_ok);
3573         return *val->contents.result;
3574 }
3575 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
3576         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
3577         CHECK(!val->result_ok);
3578         LDKLightningError err_var = (*val->contents.err);
3579         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3580         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3581         long err_ref = (long)err_var.inner & ~1;
3582         return err_ref;
3583 }
3584 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3585         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *vec = (LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)ptr;
3586         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate));
3587 }
3588 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *env, jclass _b, jlongArray elems){
3589         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *ret = MALLOC(sizeof(LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
3590         ret->datalen = (*env)->GetArrayLength(env, elems);
3591         if (ret->datalen == 0) {
3592                 ret->data = NULL;
3593         } else {
3594                 ret->data = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate) * ret->datalen, "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate Data");
3595                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3596                 for (size_t i = 0; i < ret->datalen; i++) {
3597                         jlong arr_elem = java_elems[i];
3598                         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate arr_elem_conv = *(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)arr_elem;
3599                         FREE((void*)arr_elem);
3600                         ret->data[i] = arr_elem_conv;
3601                 }
3602                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3603         }
3604         return (long)ret;
3605 }
3606 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3607         LDKCVecTempl_NodeAnnouncement *vec = (LDKCVecTempl_NodeAnnouncement*)ptr;
3608         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3609         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3610         for (size_t i = 0; i < vec->datalen; i++) {
3611                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3612                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3613         }
3614         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3615         return ret;
3616 }
3617 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1new(JNIEnv *env, jclass _b, jlongArray elems){
3618         LDKCVecTempl_NodeAnnouncement *ret = MALLOC(sizeof(LDKCVecTempl_NodeAnnouncement), "LDKCVecTempl_NodeAnnouncement");
3619         ret->datalen = (*env)->GetArrayLength(env, elems);
3620         if (ret->datalen == 0) {
3621                 ret->data = NULL;
3622         } else {
3623                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVecTempl_NodeAnnouncement Data");
3624                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3625                 for (size_t i = 0; i < ret->datalen; i++) {
3626                         jlong arr_elem = java_elems[i];
3627                         LDKNodeAnnouncement arr_elem_conv;
3628                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3629                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3630                         if (arr_elem_conv.inner != NULL)
3631                                 arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3632                         ret->data[i] = arr_elem_conv;
3633                 }
3634                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3635         }
3636         return (long)ret;
3637 }
3638 typedef struct LDKRoutingMessageHandler_JCalls {
3639         atomic_size_t refcnt;
3640         JavaVM *vm;
3641         jweak o;
3642         jmethodID handle_node_announcement_meth;
3643         jmethodID handle_channel_announcement_meth;
3644         jmethodID handle_channel_update_meth;
3645         jmethodID handle_htlc_fail_channel_update_meth;
3646         jmethodID get_next_channel_announcements_meth;
3647         jmethodID get_next_node_announcements_meth;
3648         jmethodID should_request_full_sync_meth;
3649 } LDKRoutingMessageHandler_JCalls;
3650 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement *msg) {
3651         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3652         JNIEnv *_env;
3653         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3654         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3655         CHECK(obj != NULL);
3656         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_node_announcement_meth, msg);
3657         LDKCResult_boolLightningErrorZ res = *ret;
3658         FREE(ret);
3659         return res;
3660 }
3661 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement *msg) {
3662         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3663         JNIEnv *_env;
3664         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3665         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3666         CHECK(obj != NULL);
3667         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_announcement_meth, msg);
3668         LDKCResult_boolLightningErrorZ res = *ret;
3669         FREE(ret);
3670         return res;
3671 }
3672 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate *msg) {
3673         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3674         JNIEnv *_env;
3675         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3676         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3677         CHECK(obj != NULL);
3678         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_update_meth, msg);
3679         LDKCResult_boolLightningErrorZ res = *ret;
3680         FREE(ret);
3681         return res;
3682 }
3683 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate *update) {
3684         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3685         JNIEnv *_env;
3686         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3687         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3688         CHECK(obj != NULL);
3689         return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_htlc_fail_channel_update_meth, update);
3690 }
3691 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
3692         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3693         JNIEnv *_env;
3694         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3695         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3696         CHECK(obj != NULL);
3697         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
3698         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
3699         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
3700         if (ret_constr.datalen > 0)
3701                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
3702         else
3703                 ret_constr.data = NULL;
3704         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
3705         for (size_t l = 0; l < ret_constr.datalen; l++) {
3706                 long arr_conv_63 = ret_vals[l];
3707                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
3708                 FREE((void*)arr_conv_63);
3709                 ret_constr.data[l] = arr_conv_63_conv;
3710         }
3711         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
3712         return ret_constr;
3713 }
3714 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
3715         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3716         JNIEnv *_env;
3717         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3718         jbyteArray starting_point_arr = (*_env)->NewByteArray(_env, 33);
3719         (*_env)->SetByteArrayRegion(_env, starting_point_arr, 0, 33, starting_point.compressed_form);
3720         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3721         CHECK(obj != NULL);
3722         jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
3723         LDKCVec_NodeAnnouncementZ ret_constr;
3724         ret_constr.datalen = (*_env)->GetArrayLength (_env, ret);
3725         if (ret_constr.datalen > 0)
3726                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
3727         else
3728                 ret_constr.data = NULL;
3729         long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL);
3730         for (size_t s = 0; s < ret_constr.datalen; s++) {
3731                 long arr_conv_18 = ret_vals[s];
3732                 LDKNodeAnnouncement arr_conv_18_conv;
3733                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
3734                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
3735                 if (arr_conv_18_conv.inner != NULL)
3736                         arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv);
3737                 ret_constr.data[s] = arr_conv_18_conv;
3738         }
3739         (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0);
3740         return ret_constr;
3741 }
3742 bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) {
3743         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3744         JNIEnv *_env;
3745         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3746         jbyteArray node_id_arr = (*_env)->NewByteArray(_env, 33);
3747         (*_env)->SetByteArrayRegion(_env, node_id_arr, 0, 33, node_id.compressed_form);
3748         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3749         CHECK(obj != NULL);
3750         return (*_env)->CallBooleanMethod(_env, obj, j_calls->should_request_full_sync_meth, node_id_arr);
3751 }
3752 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
3753         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3754         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3755                 JNIEnv *env;
3756                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3757                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3758                 FREE(j_calls);
3759         }
3760 }
3761 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
3762         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3763         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3764         return (void*) this_arg;
3765 }
3766 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * env, jclass _a, jobject o) {
3767         jclass c = (*env)->GetObjectClass(env, o);
3768         CHECK(c != NULL);
3769         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
3770         atomic_init(&calls->refcnt, 1);
3771         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3772         calls->o = (*env)->NewWeakGlobalRef(env, o);
3773         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
3774         CHECK(calls->handle_node_announcement_meth != NULL);
3775         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
3776         CHECK(calls->handle_channel_announcement_meth != NULL);
3777         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
3778         CHECK(calls->handle_channel_update_meth != NULL);
3779         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
3780         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
3781         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
3782         CHECK(calls->get_next_channel_announcements_meth != NULL);
3783         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
3784         CHECK(calls->get_next_node_announcements_meth != NULL);
3785         calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "([B)Z");
3786         CHECK(calls->should_request_full_sync_meth != NULL);
3787
3788         LDKRoutingMessageHandler ret = {
3789                 .this_arg = (void*) calls,
3790                 .handle_node_announcement = handle_node_announcement_jcall,
3791                 .handle_channel_announcement = handle_channel_announcement_jcall,
3792                 .handle_channel_update = handle_channel_update_jcall,
3793                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
3794                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
3795                 .get_next_node_announcements = get_next_node_announcements_jcall,
3796                 .should_request_full_sync = should_request_full_sync_jcall,
3797                 .free = LDKRoutingMessageHandler_JCalls_free,
3798         };
3799         return ret;
3800 }
3801 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new (JNIEnv * env, jclass _a, jobject o) {
3802         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
3803         *res_ptr = LDKRoutingMessageHandler_init(env, _a, o);
3804         return (long)res_ptr;
3805 }
3806 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3807         jobject ret = (*env)->NewLocalRef(env, ((LDKRoutingMessageHandler_JCalls*)val)->o);
3808         CHECK(ret != NULL);
3809         return ret;
3810 }
3811 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3812         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3813         LDKNodeAnnouncement msg_conv;
3814         msg_conv.inner = (void*)(msg & (~1));
3815         msg_conv.is_owned = (msg & 1) || (msg == 0);
3816         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3817         *ret = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
3818         return (long)ret;
3819 }
3820
3821 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3822         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3823         LDKChannelAnnouncement msg_conv;
3824         msg_conv.inner = (void*)(msg & (~1));
3825         msg_conv.is_owned = (msg & 1) || (msg == 0);
3826         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3827         *ret = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3828         return (long)ret;
3829 }
3830
3831 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3832         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3833         LDKChannelUpdate msg_conv;
3834         msg_conv.inner = (void*)(msg & (~1));
3835         msg_conv.is_owned = (msg & 1) || (msg == 0);
3836         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3837         *ret = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
3838         return (long)ret;
3839 }
3840
3841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong update) {
3842         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3843         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
3844         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
3845 }
3846
3847 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) {
3848         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3849         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
3850         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
3851         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
3852         for (size_t l = 0; l < ret_var.datalen; l++) {
3853                 /*XXX False */long arr_conv_63_ref = (long)&ret_var.data[l];
3854                 ret_arr_ptr[l] = arr_conv_63_ref;
3855         }
3856         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
3857         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(ret_var);
3858         return ret_arr;
3859 }
3860
3861 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) {
3862         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3863         LDKPublicKey starting_point_ref;
3864         CHECK((*_env)->GetArrayLength (_env, starting_point) == 33);
3865         (*_env)->GetByteArrayRegion (_env, starting_point, 0, 33, starting_point_ref.compressed_form);
3866         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
3867         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
3868         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
3869         for (size_t s = 0; s < ret_var.datalen; s++) {
3870                 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
3871                 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3872                 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3873                 long arr_conv_18_ref;
3874                 if (arr_conv_18_var.is_owned) {
3875                         arr_conv_18_ref = (long)arr_conv_18_var.inner | 1;
3876                 } else {
3877                         arr_conv_18_ref = (long)arr_conv_18_var.inner & ~1;
3878                 }
3879                 ret_arr_ptr[s] = arr_conv_18_ref;
3880         }
3881         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
3882         FREE(ret_var.data);
3883         return ret_arr;
3884 }
3885
3886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray node_id) {
3887         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3888         LDKPublicKey node_id_ref;
3889         CHECK((*_env)->GetArrayLength (_env, node_id) == 33);
3890         (*_env)->GetByteArrayRegion (_env, node_id, 0, 33, node_id_ref.compressed_form);
3891         jboolean ret_val = (this_arg_conv->should_request_full_sync)(this_arg_conv->this_arg, node_id_ref);
3892         return ret_val;
3893 }
3894
3895 typedef struct LDKSocketDescriptor_JCalls {
3896         atomic_size_t refcnt;
3897         JavaVM *vm;
3898         jweak o;
3899         jmethodID send_data_meth;
3900         jmethodID disconnect_socket_meth;
3901         jmethodID eq_meth;
3902         jmethodID hash_meth;
3903 } LDKSocketDescriptor_JCalls;
3904 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
3905         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3906         JNIEnv *_env;
3907         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3908         LDKu8slice data_var = data;
3909         jbyteArray data_arr = (*_env)->NewByteArray(_env, data_var.datalen);
3910         (*_env)->SetByteArrayRegion(_env, data_arr, 0, data_var.datalen, data_var.data);
3911         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3912         CHECK(obj != NULL);
3913         return (*_env)->CallLongMethod(_env, obj, j_calls->send_data_meth, data_arr, resume_read);
3914 }
3915 void disconnect_socket_jcall(void* this_arg) {
3916         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3917         JNIEnv *_env;
3918         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3919         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3920         CHECK(obj != NULL);
3921         return (*_env)->CallVoidMethod(_env, obj, j_calls->disconnect_socket_meth);
3922 }
3923 bool eq_jcall(const void* this_arg, const void *other_arg) {
3924         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3925         JNIEnv *_env;
3926         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3927         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3928         CHECK(obj != NULL);
3929         return (*_env)->CallBooleanMethod(_env, obj, j_calls->eq_meth, other_arg);
3930 }
3931 uint64_t hash_jcall(const void* this_arg) {
3932         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3933         JNIEnv *_env;
3934         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK);
3935         jobject obj = (*_env)->NewLocalRef(_env, j_calls->o);
3936         CHECK(obj != NULL);
3937         return (*_env)->CallLongMethod(_env, obj, j_calls->hash_meth);
3938 }
3939 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
3940         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3941         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3942                 JNIEnv *env;
3943                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3944                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3945                 FREE(j_calls);
3946         }
3947 }
3948 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
3949         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3950         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3951         return (void*) this_arg;
3952 }
3953 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv * env, jclass _a, jobject o) {
3954         jclass c = (*env)->GetObjectClass(env, o);
3955         CHECK(c != NULL);
3956         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
3957         atomic_init(&calls->refcnt, 1);
3958         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3959         calls->o = (*env)->NewWeakGlobalRef(env, o);
3960         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
3961         CHECK(calls->send_data_meth != NULL);
3962         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
3963         CHECK(calls->disconnect_socket_meth != NULL);
3964         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
3965         CHECK(calls->eq_meth != NULL);
3966         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
3967         CHECK(calls->hash_meth != NULL);
3968
3969         LDKSocketDescriptor ret = {
3970                 .this_arg = (void*) calls,
3971                 .send_data = send_data_jcall,
3972                 .disconnect_socket = disconnect_socket_jcall,
3973                 .eq = eq_jcall,
3974                 .hash = hash_jcall,
3975                 .clone = LDKSocketDescriptor_JCalls_clone,
3976                 .free = LDKSocketDescriptor_JCalls_free,
3977         };
3978         return ret;
3979 }
3980 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new (JNIEnv * env, jclass _a, jobject o) {
3981         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
3982         *res_ptr = LDKSocketDescriptor_init(env, _a, o);
3983         return (long)res_ptr;
3984 }
3985 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3986         jobject ret = (*env)->NewLocalRef(env, ((LDKSocketDescriptor_JCalls*)val)->o);
3987         CHECK(ret != NULL);
3988         return ret;
3989 }
3990 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray data, jboolean resume_read) {
3991         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
3992         LDKu8slice data_ref;
3993         data_ref.data = (*_env)->GetByteArrayElements (_env, data, NULL);
3994         data_ref.datalen = (*_env)->GetArrayLength (_env, data);
3995         jlong ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
3996         (*_env)->ReleaseByteArrayElements(_env, data, (int8_t*)data_ref.data, 0);
3997         return ret_val;
3998 }
3999
4000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv * _env, jclass _b, jlong this_arg) {
4001         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4002         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
4003 }
4004
4005 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv * _env, jclass _b, jlong this_arg) {
4006         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4007         jlong ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
4008         return ret_val;
4009 }
4010
4011 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4012         LDKCVecTempl_PublicKey *vec = (LDKCVecTempl_PublicKey*)ptr;
4013         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKPublicKey));
4014 }
4015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4016         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4017 }
4018 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4019         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4020         CHECK(val->result_ok);
4021         LDKCVecTempl_u8 res_var = (*val->contents.result);
4022         jbyteArray res_arr = (*_env)->NewByteArray(_env, res_var.datalen);
4023         (*_env)->SetByteArrayRegion(_env, res_arr, 0, res_var.datalen, res_var.data);
4024         return res_arr;
4025 }
4026 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4027         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4028         CHECK(!val->result_ok);
4029         LDKPeerHandleError err_var = (*val->contents.err);
4030         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4031         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4032         long err_ref = (long)err_var.inner & ~1;
4033         return err_ref;
4034 }
4035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4036         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4037 }
4038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4039         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
4040         CHECK(val->result_ok);
4041         return *val->contents.result;
4042 }
4043 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4044         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
4045         CHECK(!val->result_ok);
4046         LDKPeerHandleError err_var = (*val->contents.err);
4047         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4048         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4049         long err_ref = (long)err_var.inner & ~1;
4050         return err_ref;
4051 }
4052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4053         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
4054 }
4055 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4056         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
4057         CHECK(val->result_ok);
4058         jbyteArray res_arr = (*_env)->NewByteArray(_env, 32);
4059         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 32, (*val->contents.result).bytes);
4060         return res_arr;
4061 }
4062 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4063         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
4064         CHECK(!val->result_ok);
4065         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4066         return err_conv;
4067 }
4068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4069         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
4070 }
4071 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4072         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
4073         CHECK(val->result_ok);
4074         jbyteArray res_arr = (*_env)->NewByteArray(_env, 33);
4075         (*_env)->SetByteArrayRegion(_env, res_arr, 0, 33, (*val->contents.result).compressed_form);
4076         return res_arr;
4077 }
4078 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4079         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
4080         CHECK(!val->result_ok);
4081         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4082         return err_conv;
4083 }
4084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4085         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
4086 }
4087 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4088         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4089         CHECK(val->result_ok);
4090         LDKTxCreationKeys res_var = (*val->contents.result);
4091         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4092         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4093         long res_ref = (long)res_var.inner & ~1;
4094         return res_ref;
4095 }
4096 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4097         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4098         CHECK(!val->result_ok);
4099         jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err));
4100         return err_conv;
4101 }
4102 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4103         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *vec = (LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature*)ptr;
4104         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature));
4105 }
4106 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
4107         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature), "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature");
4108         ret->datalen = (*env)->GetArrayLength(env, elems);
4109         if (ret->datalen == 0) {
4110                 ret->data = NULL;
4111         } else {
4112                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature) * ret->datalen, "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature Data");
4113                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4114                 for (size_t i = 0; i < ret->datalen; i++) {
4115                         jlong arr_elem = java_elems[i];
4116                         LDKC2TupleTempl_HTLCOutputInCommitment__Signature arr_elem_conv = *(LDKC2TupleTempl_HTLCOutputInCommitment__Signature*)arr_elem;
4117                         FREE((void*)arr_elem);
4118                         ret->data[i] = arr_elem_conv;
4119                 }
4120                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4121         }
4122         return (long)ret;
4123 }
4124 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4125         LDKCVecTempl_RouteHop *vec = (LDKCVecTempl_RouteHop*)ptr;
4126         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
4127         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
4128         for (size_t i = 0; i < vec->datalen; i++) {
4129                 CHECK((((long)vec->data[i].inner) & 1) == 0);
4130                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
4131         }
4132         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
4133         return ret;
4134 }
4135 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
4136         LDKCVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_RouteHop), "LDKCVecTempl_RouteHop");
4137         ret->datalen = (*env)->GetArrayLength(env, elems);
4138         if (ret->datalen == 0) {
4139                 ret->data = NULL;
4140         } else {
4141                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVecTempl_RouteHop Data");
4142                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4143                 for (size_t i = 0; i < ret->datalen; i++) {
4144                         jlong arr_elem = java_elems[i];
4145                         LDKRouteHop arr_elem_conv;
4146                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4147                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4148                         if (arr_elem_conv.inner != NULL)
4149                                 arr_elem_conv = RouteHop_clone(&arr_elem_conv);
4150                         ret->data[i] = arr_elem_conv;
4151                 }
4152                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4153         }
4154         return (long)ret;
4155 }
4156 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4157         LDKCVecTempl_CVecTempl_RouteHop *vec = (LDKCVecTempl_CVecTempl_RouteHop*)ptr;
4158         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVecTempl_RouteHop));
4159 }
4160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
4161         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
4162 }
4163 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {
4164         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
4165         CHECK(val->result_ok);
4166         LDKRoute res_var = (*val->contents.result);
4167         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4168         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4169         long res_ref = (long)res_var.inner & ~1;
4170         return res_ref;
4171 }
4172 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {
4173         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
4174         CHECK(!val->result_ok);
4175         LDKLightningError err_var = (*val->contents.err);
4176         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4177         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4178         long err_ref = (long)err_var.inner & ~1;
4179         return err_ref;
4180 }
4181 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
4182         LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr;
4183         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
4184         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
4185         for (size_t i = 0; i < vec->datalen; i++) {
4186                 CHECK((((long)vec->data[i].inner) & 1) == 0);
4187                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
4188         }
4189         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
4190         return ret;
4191 }
4192 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1new(JNIEnv *env, jclass _b, jlongArray elems){
4193         LDKCVecTempl_RouteHint *ret = MALLOC(sizeof(LDKCVecTempl_RouteHint), "LDKCVecTempl_RouteHint");
4194         ret->datalen = (*env)->GetArrayLength(env, elems);
4195         if (ret->datalen == 0) {
4196                 ret->data = NULL;
4197         } else {
4198                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVecTempl_RouteHint Data");
4199                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4200                 for (size_t i = 0; i < ret->datalen; i++) {
4201                         jlong arr_elem = java_elems[i];
4202                         LDKRouteHint arr_elem_conv;
4203                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4204                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4205                         if (arr_elem_conv.inner != NULL)
4206                                 arr_elem_conv = RouteHint_clone(&arr_elem_conv);
4207                         ret->data[i] = arr_elem_conv;
4208                 }
4209                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4210         }
4211         return (long)ret;
4212 }
4213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4214         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arg_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arg;
4215         FREE((void*)arg);
4216         C2Tuple_HTLCOutputInCommitmentSignatureZ_free(arg_conv);
4217 }
4218
4219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4220         LDKC2Tuple_OutPointScriptZ arg_conv = *(LDKC2Tuple_OutPointScriptZ*)arg;
4221         FREE((void*)arg);
4222         C2Tuple_OutPointScriptZ_free(arg_conv);
4223 }
4224
4225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4226         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4227         FREE((void*)arg);
4228         C2Tuple_SignatureCVec_SignatureZZ_free(arg_conv);
4229 }
4230
4231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4232         LDKC2Tuple_TxidCVec_TxOutZZ arg_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arg;
4233         FREE((void*)arg);
4234         C2Tuple_TxidCVec_TxOutZZ_free(arg_conv);
4235 }
4236
4237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4238         LDKC2Tuple_u64u64Z arg_conv = *(LDKC2Tuple_u64u64Z*)arg;
4239         FREE((void*)arg);
4240         C2Tuple_u64u64Z_free(arg_conv);
4241 }
4242
4243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4244         LDKC2Tuple_usizeTransactionZ arg_conv = *(LDKC2Tuple_usizeTransactionZ*)arg;
4245         FREE((void*)arg);
4246         C2Tuple_usizeTransactionZ_free(arg_conv);
4247 }
4248
4249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4250         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arg_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arg;
4251         FREE((void*)arg);
4252         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(arg_conv);
4253 }
4254
4255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4256         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ arg_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
4257         FREE((void*)arg);
4258         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(arg_conv);
4259 }
4260
4261 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4262         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4263         FREE((void*)arg);
4264         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4265         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(arg_conv);
4266         return (long)ret;
4267 }
4268
4269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4270         LDKCResult_CVec_SignatureZNoneZ arg_conv = *(LDKCResult_CVec_SignatureZNoneZ*)arg;
4271         FREE((void*)arg);
4272         CResult_CVec_SignatureZNoneZ_free(arg_conv);
4273 }
4274
4275 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jobjectArray arg) {
4276         LDKCVec_SignatureZ arg_constr;
4277         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4278         if (arg_constr.datalen > 0)
4279                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4280         else
4281                 arg_constr.data = NULL;
4282         for (size_t i = 0; i < arg_constr.datalen; i++) {
4283                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
4284                 LDKSignature arr_conv_8_ref;
4285                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
4286                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
4287                 arg_constr.data[i] = arr_conv_8_ref;
4288         }
4289         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4290         *ret = CResult_CVec_SignatureZNoneZ_ok(arg_constr);
4291         return (long)ret;
4292 }
4293
4294 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4295         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4296         FREE((void*)arg);
4297         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4298         *ret = CResult_CVec_u8ZPeerHandleErrorZ_err(arg_conv);
4299         return (long)ret;
4300 }
4301
4302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4303         LDKCResult_CVec_u8ZPeerHandleErrorZ arg_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4304         FREE((void*)arg);
4305         CResult_CVec_u8ZPeerHandleErrorZ_free(arg_conv);
4306 }
4307
4308 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4309         LDKCVec_u8Z arg_ref;
4310         arg_ref.data = (*_env)->GetByteArrayElements (_env, arg, NULL);
4311         arg_ref.datalen = (*_env)->GetArrayLength (_env, arg);
4312         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4313         *ret = CResult_CVec_u8ZPeerHandleErrorZ_ok(arg_ref);
4314         (*_env)->ReleaseByteArrayElements(_env, arg, (int8_t*)arg_ref.data, 0);
4315         return (long)ret;
4316 }
4317
4318 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4319         LDKAPIError arg_conv = *(LDKAPIError*)arg;
4320         FREE((void*)arg);
4321         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4322         *ret = CResult_NoneAPIErrorZ_err(arg_conv);
4323         return (long)ret;
4324 }
4325
4326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4327         LDKCResult_NoneAPIErrorZ arg_conv = *(LDKCResult_NoneAPIErrorZ*)arg;
4328         FREE((void*)arg);
4329         CResult_NoneAPIErrorZ_free(arg_conv);
4330 }
4331
4332 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4333         LDKChannelMonitorUpdateErr arg_conv = *(LDKChannelMonitorUpdateErr*)arg;
4334         FREE((void*)arg);
4335         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4336         *ret = CResult_NoneChannelMonitorUpdateErrZ_err(arg_conv);
4337         return (long)ret;
4338 }
4339
4340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4341         LDKCResult_NoneChannelMonitorUpdateErrZ arg_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
4342         FREE((void*)arg);
4343         CResult_NoneChannelMonitorUpdateErrZ_free(arg_conv);
4344 }
4345
4346 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4347         LDKMonitorUpdateError arg_conv = *(LDKMonitorUpdateError*)arg;
4348         FREE((void*)arg);
4349         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4350         *ret = CResult_NoneMonitorUpdateErrorZ_err(arg_conv);
4351         return (long)ret;
4352 }
4353
4354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4355         LDKCResult_NoneMonitorUpdateErrorZ arg_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)arg;
4356         FREE((void*)arg);
4357         CResult_NoneMonitorUpdateErrorZ_free(arg_conv);
4358 }
4359
4360 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4361         LDKPaymentSendFailure arg_conv = *(LDKPaymentSendFailure*)arg;
4362         FREE((void*)arg);
4363         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4364         *ret = CResult_NonePaymentSendFailureZ_err(arg_conv);
4365         return (long)ret;
4366 }
4367
4368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4369         LDKCResult_NonePaymentSendFailureZ arg_conv = *(LDKCResult_NonePaymentSendFailureZ*)arg;
4370         FREE((void*)arg);
4371         CResult_NonePaymentSendFailureZ_free(arg_conv);
4372 }
4373
4374 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4375         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4376         FREE((void*)arg);
4377         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4378         *ret = CResult_NonePeerHandleErrorZ_err(arg_conv);
4379         return (long)ret;
4380 }
4381
4382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4383         LDKCResult_NonePeerHandleErrorZ arg_conv = *(LDKCResult_NonePeerHandleErrorZ*)arg;
4384         FREE((void*)arg);
4385         CResult_NonePeerHandleErrorZ_free(arg_conv);
4386 }
4387
4388 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4389         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4390         FREE((void*)arg);
4391         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4392         *ret = CResult_PublicKeySecpErrorZ_err(arg_conv);
4393         return (long)ret;
4394 }
4395
4396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4397         LDKCResult_PublicKeySecpErrorZ arg_conv = *(LDKCResult_PublicKeySecpErrorZ*)arg;
4398         FREE((void*)arg);
4399         CResult_PublicKeySecpErrorZ_free(arg_conv);
4400 }
4401
4402 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4403         LDKPublicKey arg_ref;
4404         CHECK((*_env)->GetArrayLength (_env, arg) == 33);
4405         (*_env)->GetByteArrayRegion (_env, arg, 0, 33, arg_ref.compressed_form);
4406         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4407         *ret = CResult_PublicKeySecpErrorZ_ok(arg_ref);
4408         return (long)ret;
4409 }
4410
4411 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4412         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4413         FREE((void*)arg);
4414         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4415         *ret = CResult_RouteLightningErrorZ_err(arg_conv);
4416         return (long)ret;
4417 }
4418
4419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4420         LDKCResult_RouteLightningErrorZ arg_conv = *(LDKCResult_RouteLightningErrorZ*)arg;
4421         FREE((void*)arg);
4422         CResult_RouteLightningErrorZ_free(arg_conv);
4423 }
4424
4425 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4426         LDKRoute arg_conv = *(LDKRoute*)arg;
4427         FREE((void*)arg);
4428         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4429         *ret = CResult_RouteLightningErrorZ_ok(arg_conv);
4430         return (long)ret;
4431 }
4432
4433 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4434         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4435         FREE((void*)arg);
4436         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4437         *ret = CResult_SecretKeySecpErrorZ_err(arg_conv);
4438         return (long)ret;
4439 }
4440
4441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4442         LDKCResult_SecretKeySecpErrorZ arg_conv = *(LDKCResult_SecretKeySecpErrorZ*)arg;
4443         FREE((void*)arg);
4444         CResult_SecretKeySecpErrorZ_free(arg_conv);
4445 }
4446
4447 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4448         LDKSecretKey arg_ref;
4449         CHECK((*_env)->GetArrayLength (_env, arg) == 32);
4450         (*_env)->GetByteArrayRegion (_env, arg, 0, 32, arg_ref.bytes);
4451         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4452         *ret = CResult_SecretKeySecpErrorZ_ok(arg_ref);
4453         return (long)ret;
4454 }
4455
4456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4457         LDKCResult_SignatureNoneZ arg_conv = *(LDKCResult_SignatureNoneZ*)arg;
4458         FREE((void*)arg);
4459         CResult_SignatureNoneZ_free(arg_conv);
4460 }
4461
4462 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4463         LDKSignature arg_ref;
4464         CHECK((*_env)->GetArrayLength (_env, arg) == 64);
4465         (*_env)->GetByteArrayRegion (_env, arg, 0, 64, arg_ref.compact_form);
4466         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4467         *ret = CResult_SignatureNoneZ_ok(arg_ref);
4468         return (long)ret;
4469 }
4470
4471 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4472         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4473         FREE((void*)arg);
4474         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4475         *ret = CResult_TxCreationKeysSecpErrorZ_err(arg_conv);
4476         return (long)ret;
4477 }
4478
4479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4480         LDKCResult_TxCreationKeysSecpErrorZ arg_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4481         FREE((void*)arg);
4482         CResult_TxCreationKeysSecpErrorZ_free(arg_conv);
4483 }
4484
4485 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4486         LDKTxCreationKeys arg_conv = *(LDKTxCreationKeys*)arg;
4487         FREE((void*)arg);
4488         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4489         *ret = CResult_TxCreationKeysSecpErrorZ_ok(arg_conv);
4490         return (long)ret;
4491 }
4492
4493 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4494         LDKAccessError arg_conv = *(LDKAccessError*)arg;
4495         FREE((void*)arg);
4496         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4497         *ret = CResult_TxOutAccessErrorZ_err(arg_conv);
4498         return (long)ret;
4499 }
4500
4501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4502         LDKCResult_TxOutAccessErrorZ arg_conv = *(LDKCResult_TxOutAccessErrorZ*)arg;
4503         FREE((void*)arg);
4504         CResult_TxOutAccessErrorZ_free(arg_conv);
4505 }
4506
4507 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4508         LDKTxOut arg_conv = *(LDKTxOut*)arg;
4509         FREE((void*)arg);
4510         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4511         *ret = CResult_TxOutAccessErrorZ_ok(arg_conv);
4512         return (long)ret;
4513 }
4514
4515 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4516         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4517         FREE((void*)arg);
4518         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4519         *ret = CResult_boolLightningErrorZ_err(arg_conv);
4520         return (long)ret;
4521 }
4522
4523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4524         LDKCResult_boolLightningErrorZ arg_conv = *(LDKCResult_boolLightningErrorZ*)arg;
4525         FREE((void*)arg);
4526         CResult_boolLightningErrorZ_free(arg_conv);
4527 }
4528
4529 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4530         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4531         *ret = CResult_boolLightningErrorZ_ok(arg);
4532         return (long)ret;
4533 }
4534
4535 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4536         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4537         FREE((void*)arg);
4538         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4539         *ret = CResult_boolPeerHandleErrorZ_err(arg_conv);
4540         return (long)ret;
4541 }
4542
4543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4544         LDKCResult_boolPeerHandleErrorZ arg_conv = *(LDKCResult_boolPeerHandleErrorZ*)arg;
4545         FREE((void*)arg);
4546         CResult_boolPeerHandleErrorZ_free(arg_conv);
4547 }
4548
4549 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4550         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4551         *ret = CResult_boolPeerHandleErrorZ_ok(arg);
4552         return (long)ret;
4553 }
4554
4555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4556         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_constr;
4557         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4558         if (arg_constr.datalen > 0)
4559                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
4560         else
4561                 arg_constr.data = NULL;
4562         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4563         for (size_t q = 0; q < arg_constr.datalen; q++) {
4564                 long arr_conv_42 = arg_vals[q];
4565                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
4566                 FREE((void*)arr_conv_42);
4567                 arg_constr.data[q] = arr_conv_42_conv;
4568         }
4569         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4570         CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_constr);
4571 }
4572
4573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4574         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_constr;
4575         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4576         if (arg_constr.datalen > 0)
4577                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ Elements");
4578         else
4579                 arg_constr.data = NULL;
4580         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4581         for (size_t b = 0; b < arg_constr.datalen; b++) {
4582                 long arr_conv_27 = arg_vals[b];
4583                 LDKC2Tuple_TxidCVec_TxOutZZ arr_conv_27_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arr_conv_27;
4584                 FREE((void*)arr_conv_27);
4585                 arg_constr.data[b] = arr_conv_27_conv;
4586         }
4587         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4588         CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_constr);
4589 }
4590
4591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4592         LDKCVec_C2Tuple_usizeTransactionZZ arg_constr;
4593         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4594         if (arg_constr.datalen > 0)
4595                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
4596         else
4597                 arg_constr.data = NULL;
4598         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4599         for (size_t d = 0; d < arg_constr.datalen; d++) {
4600                 long arr_conv_29 = arg_vals[d];
4601                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
4602                 FREE((void*)arr_conv_29);
4603                 arg_constr.data[d] = arr_conv_29_conv;
4604         }
4605         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4606         CVec_C2Tuple_usizeTransactionZZ_free(arg_constr);
4607 }
4608
4609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4610         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_constr;
4611         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4612         if (arg_constr.datalen > 0)
4613                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
4614         else
4615                 arg_constr.data = NULL;
4616         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4617         for (size_t l = 0; l < arg_constr.datalen; l++) {
4618                 long arr_conv_63 = arg_vals[l];
4619                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
4620                 FREE((void*)arr_conv_63);
4621                 arg_constr.data[l] = arr_conv_63_conv;
4622         }
4623         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4624         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_constr);
4625 }
4626
4627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
4628         LDKCVec_CVec_RouteHopZZ arg_constr;
4629         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4630         if (arg_constr.datalen > 0)
4631                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
4632         else
4633                 arg_constr.data = NULL;
4634         for (size_t m = 0; m < arg_constr.datalen; m++) {
4635                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, arg, m);
4636                 LDKCVec_RouteHopZ arr_conv_12_constr;
4637                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
4638                 if (arr_conv_12_constr.datalen > 0)
4639                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
4640                 else
4641                         arr_conv_12_constr.data = NULL;
4642                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
4643                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
4644                         long arr_conv_10 = arr_conv_12_vals[k];
4645                         LDKRouteHop arr_conv_10_conv;
4646                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
4647                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
4648                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
4649                 }
4650                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
4651                 arg_constr.data[m] = arr_conv_12_constr;
4652         }
4653         CVec_CVec_RouteHopZZ_free(arg_constr);
4654 }
4655
4656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4657         LDKCVec_ChannelDetailsZ arg_constr;
4658         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4659         if (arg_constr.datalen > 0)
4660                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
4661         else
4662                 arg_constr.data = NULL;
4663         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4664         for (size_t q = 0; q < arg_constr.datalen; q++) {
4665                 long arr_conv_16 = arg_vals[q];
4666                 LDKChannelDetails arr_conv_16_conv;
4667                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4668                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4669                 arg_constr.data[q] = arr_conv_16_conv;
4670         }
4671         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4672         CVec_ChannelDetailsZ_free(arg_constr);
4673 }
4674
4675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4676         LDKCVec_ChannelMonitorZ arg_constr;
4677         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4678         if (arg_constr.datalen > 0)
4679                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
4680         else
4681                 arg_constr.data = NULL;
4682         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4683         for (size_t q = 0; q < arg_constr.datalen; q++) {
4684                 long arr_conv_16 = arg_vals[q];
4685                 LDKChannelMonitor arr_conv_16_conv;
4686                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4687                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4688                 arg_constr.data[q] = arr_conv_16_conv;
4689         }
4690         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4691         CVec_ChannelMonitorZ_free(arg_constr);
4692 }
4693
4694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4695         LDKCVec_EventZ arg_constr;
4696         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4697         if (arg_constr.datalen > 0)
4698                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4699         else
4700                 arg_constr.data = NULL;
4701         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4702         for (size_t h = 0; h < arg_constr.datalen; h++) {
4703                 long arr_conv_7 = arg_vals[h];
4704                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
4705                 FREE((void*)arr_conv_7);
4706                 arg_constr.data[h] = arr_conv_7_conv;
4707         }
4708         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4709         CVec_EventZ_free(arg_constr);
4710 }
4711
4712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4713         LDKCVec_HTLCOutputInCommitmentZ arg_constr;
4714         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4715         if (arg_constr.datalen > 0)
4716                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
4717         else
4718                 arg_constr.data = NULL;
4719         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4720         for (size_t y = 0; y < arg_constr.datalen; y++) {
4721                 long arr_conv_24 = arg_vals[y];
4722                 LDKHTLCOutputInCommitment arr_conv_24_conv;
4723                 arr_conv_24_conv.inner = (void*)(arr_conv_24 & (~1));
4724                 arr_conv_24_conv.is_owned = (arr_conv_24 & 1) || (arr_conv_24 == 0);
4725                 arg_constr.data[y] = arr_conv_24_conv;
4726         }
4727         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4728         CVec_HTLCOutputInCommitmentZ_free(arg_constr);
4729 }
4730
4731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4732         LDKCVec_MessageSendEventZ arg_constr;
4733         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4734         if (arg_constr.datalen > 0)
4735                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4736         else
4737                 arg_constr.data = NULL;
4738         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4739         for (size_t s = 0; s < arg_constr.datalen; s++) {
4740                 long arr_conv_18 = arg_vals[s];
4741                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
4742                 FREE((void*)arr_conv_18);
4743                 arg_constr.data[s] = arr_conv_18_conv;
4744         }
4745         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4746         CVec_MessageSendEventZ_free(arg_constr);
4747 }
4748
4749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4750         LDKCVec_MonitorEventZ arg_constr;
4751         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4752         if (arg_constr.datalen > 0)
4753                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4754         else
4755                 arg_constr.data = NULL;
4756         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4757         for (size_t o = 0; o < arg_constr.datalen; o++) {
4758                 long arr_conv_14 = arg_vals[o];
4759                 LDKMonitorEvent arr_conv_14_conv;
4760                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
4761                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
4762                 arg_constr.data[o] = arr_conv_14_conv;
4763         }
4764         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4765         CVec_MonitorEventZ_free(arg_constr);
4766 }
4767
4768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4769         LDKCVec_NetAddressZ arg_constr;
4770         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4771         if (arg_constr.datalen > 0)
4772                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
4773         else
4774                 arg_constr.data = NULL;
4775         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4776         for (size_t m = 0; m < arg_constr.datalen; m++) {
4777                 long arr_conv_12 = arg_vals[m];
4778                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
4779                 FREE((void*)arr_conv_12);
4780                 arg_constr.data[m] = arr_conv_12_conv;
4781         }
4782         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4783         CVec_NetAddressZ_free(arg_constr);
4784 }
4785
4786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4787         LDKCVec_NodeAnnouncementZ arg_constr;
4788         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4789         if (arg_constr.datalen > 0)
4790                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
4791         else
4792                 arg_constr.data = NULL;
4793         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4794         for (size_t s = 0; s < arg_constr.datalen; s++) {
4795                 long arr_conv_18 = arg_vals[s];
4796                 LDKNodeAnnouncement arr_conv_18_conv;
4797                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
4798                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
4799                 arg_constr.data[s] = arr_conv_18_conv;
4800         }
4801         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4802         CVec_NodeAnnouncementZ_free(arg_constr);
4803 }
4804
4805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
4806         LDKCVec_PublicKeyZ arg_constr;
4807         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4808         if (arg_constr.datalen > 0)
4809                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
4810         else
4811                 arg_constr.data = NULL;
4812         for (size_t i = 0; i < arg_constr.datalen; i++) {
4813                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
4814                 LDKPublicKey arr_conv_8_ref;
4815                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 33);
4816                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 33, arr_conv_8_ref.compressed_form);
4817                 arg_constr.data[i] = arr_conv_8_ref;
4818         }
4819         CVec_PublicKeyZ_free(arg_constr);
4820 }
4821
4822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4823         LDKCVec_RouteHintZ arg_constr;
4824         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4825         if (arg_constr.datalen > 0)
4826                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
4827         else
4828                 arg_constr.data = NULL;
4829         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4830         for (size_t l = 0; l < arg_constr.datalen; l++) {
4831                 long arr_conv_11 = arg_vals[l];
4832                 LDKRouteHint arr_conv_11_conv;
4833                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
4834                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
4835                 arg_constr.data[l] = arr_conv_11_conv;
4836         }
4837         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4838         CVec_RouteHintZ_free(arg_constr);
4839 }
4840
4841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4842         LDKCVec_RouteHopZ arg_constr;
4843         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4844         if (arg_constr.datalen > 0)
4845                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
4846         else
4847                 arg_constr.data = NULL;
4848         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4849         for (size_t k = 0; k < arg_constr.datalen; k++) {
4850                 long arr_conv_10 = arg_vals[k];
4851                 LDKRouteHop arr_conv_10_conv;
4852                 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
4853                 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
4854                 arg_constr.data[k] = arr_conv_10_conv;
4855         }
4856         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4857         CVec_RouteHopZ_free(arg_constr);
4858 }
4859
4860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) {
4861         LDKCVec_SignatureZ arg_constr;
4862         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4863         if (arg_constr.datalen > 0)
4864                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4865         else
4866                 arg_constr.data = NULL;
4867         for (size_t i = 0; i < arg_constr.datalen; i++) {
4868                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i);
4869                 LDKSignature arr_conv_8_ref;
4870                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
4871                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
4872                 arg_constr.data[i] = arr_conv_8_ref;
4873         }
4874         CVec_SignatureZ_free(arg_constr);
4875 }
4876
4877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4878         LDKCVec_SpendableOutputDescriptorZ 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(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
4882         else
4883                 arg_constr.data = NULL;
4884         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4885         for (size_t b = 0; b < arg_constr.datalen; b++) {
4886                 long arr_conv_27 = arg_vals[b];
4887                 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)arr_conv_27;
4888                 FREE((void*)arr_conv_27);
4889                 arg_constr.data[b] = arr_conv_27_conv;
4890         }
4891         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4892         CVec_SpendableOutputDescriptorZ_free(arg_constr);
4893 }
4894
4895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4896         LDKCVec_TransactionZ 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(LDKTransaction), "LDKCVec_TransactionZ Elements");
4900         else
4901                 arg_constr.data = NULL;
4902         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4903         for (size_t n = 0; n < arg_constr.datalen; n++) {
4904                 long arr_conv_13 = arg_vals[n];
4905                 LDKTransaction arr_conv_13_conv = *(LDKTransaction*)arr_conv_13;
4906                 FREE((void*)arr_conv_13);
4907                 arg_constr.data[n] = arr_conv_13_conv;
4908         }
4909         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4910         CVec_TransactionZ_free(arg_constr);
4911 }
4912
4913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4914         LDKCVec_TxOutZ arg_constr;
4915         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4916         if (arg_constr.datalen > 0)
4917                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
4918         else
4919                 arg_constr.data = NULL;
4920         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4921         for (size_t h = 0; h < arg_constr.datalen; h++) {
4922                 long arr_conv_7 = arg_vals[h];
4923                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
4924                 FREE((void*)arr_conv_7);
4925                 arg_constr.data[h] = arr_conv_7_conv;
4926         }
4927         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4928         CVec_TxOutZ_free(arg_constr);
4929 }
4930
4931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4932         LDKCVec_UpdateAddHTLCZ arg_constr;
4933         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4934         if (arg_constr.datalen > 0)
4935                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
4936         else
4937                 arg_constr.data = NULL;
4938         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4939         for (size_t p = 0; p < arg_constr.datalen; p++) {
4940                 long arr_conv_15 = arg_vals[p];
4941                 LDKUpdateAddHTLC arr_conv_15_conv;
4942                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
4943                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
4944                 arg_constr.data[p] = arr_conv_15_conv;
4945         }
4946         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4947         CVec_UpdateAddHTLCZ_free(arg_constr);
4948 }
4949
4950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4951         LDKCVec_UpdateFailHTLCZ arg_constr;
4952         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4953         if (arg_constr.datalen > 0)
4954                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
4955         else
4956                 arg_constr.data = NULL;
4957         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4958         for (size_t q = 0; q < arg_constr.datalen; q++) {
4959                 long arr_conv_16 = arg_vals[q];
4960                 LDKUpdateFailHTLC arr_conv_16_conv;
4961                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4962                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4963                 arg_constr.data[q] = arr_conv_16_conv;
4964         }
4965         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4966         CVec_UpdateFailHTLCZ_free(arg_constr);
4967 }
4968
4969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4970         LDKCVec_UpdateFailMalformedHTLCZ arg_constr;
4971         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4972         if (arg_constr.datalen > 0)
4973                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
4974         else
4975                 arg_constr.data = NULL;
4976         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4977         for (size_t z = 0; z < arg_constr.datalen; z++) {
4978                 long arr_conv_25 = arg_vals[z];
4979                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
4980                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
4981                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
4982                 arg_constr.data[z] = arr_conv_25_conv;
4983         }
4984         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
4985         CVec_UpdateFailMalformedHTLCZ_free(arg_constr);
4986 }
4987
4988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
4989         LDKCVec_UpdateFulfillHTLCZ arg_constr;
4990         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
4991         if (arg_constr.datalen > 0)
4992                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
4993         else
4994                 arg_constr.data = NULL;
4995         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
4996         for (size_t t = 0; t < arg_constr.datalen; t++) {
4997                 long arr_conv_19 = arg_vals[t];
4998                 LDKUpdateFulfillHTLC arr_conv_19_conv;
4999                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
5000                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
5001                 arg_constr.data[t] = arr_conv_19_conv;
5002         }
5003         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5004         CVec_UpdateFulfillHTLCZ_free(arg_constr);
5005 }
5006
5007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlongArray arg) {
5008         LDKCVec_u64Z arg_constr;
5009         arg_constr.datalen = (*_env)->GetArrayLength (_env, arg);
5010         if (arg_constr.datalen > 0)
5011                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
5012         else
5013                 arg_constr.data = NULL;
5014         long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL);
5015         for (size_t g = 0; g < arg_constr.datalen; g++) {
5016                 long arr_conv_6 = arg_vals[g];
5017                 arg_constr.data[g] = arr_conv_6;
5018         }
5019         (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0);
5020         CVec_u64Z_free(arg_constr);
5021 }
5022
5023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv * _env, jclass _b, jbyteArray arg) {
5024         LDKCVec_u8Z arg_ref;
5025         arg_ref.data = (*_env)->GetByteArrayElements (_env, arg, NULL);
5026         arg_ref.datalen = (*_env)->GetArrayLength (_env, arg);
5027         CVec_u8Z_free(arg_ref);
5028         (*_env)->ReleaseByteArrayElements(_env, arg, (int8_t*)arg_ref.data, 0);
5029 }
5030
5031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv * _env, jclass _b, jlong _res) {
5032         LDKTransaction _res_conv = *(LDKTransaction*)_res;
5033         FREE((void*)_res);
5034         Transaction_free(_res_conv);
5035 }
5036
5037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv * _env, jclass _b, jlong _res) {
5038         LDKTxOut _res_conv = *(LDKTxOut*)_res;
5039         FREE((void*)_res);
5040         TxOut_free(_res_conv);
5041 }
5042
5043 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
5044         LDKTransaction b_conv = *(LDKTransaction*)b;
5045         FREE((void*)b);
5046         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5047         *ret = C2Tuple_usizeTransactionZ_new(a, b_conv);
5048         return (long)ret;
5049 }
5050
5051 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv * _env, jclass _b) {
5052         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5053         *ret = CResult_NoneChannelMonitorUpdateErrZ_ok();
5054         return (long)ret;
5055 }
5056
5057 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv * _env, jclass _b) {
5058         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
5059         *ret = CResult_NoneMonitorUpdateErrorZ_ok();
5060         return (long)ret;
5061 }
5062
5063 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv * _env, jclass _b, jlong a, jbyteArray b) {
5064         LDKOutPoint a_conv;
5065         a_conv.inner = (void*)(a & (~1));
5066         a_conv.is_owned = (a & 1) || (a == 0);
5067         if (a_conv.inner != NULL)
5068                 a_conv = OutPoint_clone(&a_conv);
5069         LDKCVec_u8Z b_ref;
5070         b_ref.data = (*_env)->GetByteArrayElements (_env, b, NULL);
5071         b_ref.datalen = (*_env)->GetArrayLength (_env, b);
5072         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5073         *ret = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
5074         (*_env)->ReleaseByteArrayElements(_env, b, (int8_t*)b_ref.data, 0);
5075         return (long)ret;
5076 }
5077
5078 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlongArray b) {
5079         LDKThirtyTwoBytes a_ref;
5080         CHECK((*_env)->GetArrayLength (_env, a) == 32);
5081         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
5082         LDKCVec_TxOutZ b_constr;
5083         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
5084         if (b_constr.datalen > 0)
5085                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
5086         else
5087                 b_constr.data = NULL;
5088         long* b_vals = (*_env)->GetLongArrayElements (_env, b, NULL);
5089         for (size_t h = 0; h < b_constr.datalen; h++) {
5090                 long arr_conv_7 = b_vals[h];
5091                 LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7;
5092                 FREE((void*)arr_conv_7);
5093                 b_constr.data[h] = arr_conv_7_conv;
5094         }
5095         (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0);
5096         LDKC2Tuple_TxidCVec_TxOutZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKC2Tuple_TxidCVec_TxOutZZ");
5097         *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_constr);
5098         return (long)ret;
5099 }
5100
5101 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
5102         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
5103         *ret = C2Tuple_u64u64Z_new(a, b);
5104         return (long)ret;
5105 }
5106
5107 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jobjectArray b) {
5108         LDKSignature a_ref;
5109         CHECK((*_env)->GetArrayLength (_env, a) == 64);
5110         (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form);
5111         LDKCVec_SignatureZ b_constr;
5112         b_constr.datalen = (*_env)->GetArrayLength (_env, b);
5113         if (b_constr.datalen > 0)
5114                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5115         else
5116                 b_constr.data = NULL;
5117         for (size_t i = 0; i < b_constr.datalen; i++) {
5118                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, b, i);
5119                 LDKSignature arr_conv_8_ref;
5120                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
5121                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
5122                 b_constr.data[i] = arr_conv_8_ref;
5123         }
5124         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5125         *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
5126         return (long)ret;
5127 }
5128
5129 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv * _env, jclass _b) {
5130         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5131         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
5132         return (long)ret;
5133 }
5134
5135 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv * _env, jclass _b) {
5136         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5137         *ret = CResult_SignatureNoneZ_err();
5138         return (long)ret;
5139 }
5140
5141 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv * _env, jclass _b) {
5142         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5143         *ret = CResult_CVec_SignatureZNoneZ_err();
5144         return (long)ret;
5145 }
5146
5147 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv * _env, jclass _b) {
5148         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5149         *ret = CResult_NoneAPIErrorZ_ok();
5150         return (long)ret;
5151 }
5152
5153 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv * _env, jclass _b) {
5154         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5155         *ret = CResult_NonePaymentSendFailureZ_ok();
5156         return (long)ret;
5157 }
5158
5159 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b, jlong c) {
5160         LDKChannelAnnouncement a_conv;
5161         a_conv.inner = (void*)(a & (~1));
5162         a_conv.is_owned = (a & 1) || (a == 0);
5163         if (a_conv.inner != NULL)
5164                 a_conv = ChannelAnnouncement_clone(&a_conv);
5165         LDKChannelUpdate b_conv;
5166         b_conv.inner = (void*)(b & (~1));
5167         b_conv.is_owned = (b & 1) || (b == 0);
5168         if (b_conv.inner != NULL)
5169                 b_conv = ChannelUpdate_clone(&b_conv);
5170         LDKChannelUpdate c_conv;
5171         c_conv.inner = (void*)(c & (~1));
5172         c_conv.is_owned = (c & 1) || (c == 0);
5173         if (c_conv.inner != NULL)
5174                 c_conv = ChannelUpdate_clone(&c_conv);
5175         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5176         *ret = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5177         return (long)ret;
5178 }
5179
5180 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b) {
5181         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5182         *ret = CResult_NonePeerHandleErrorZ_ok();
5183         return (long)ret;
5184 }
5185
5186 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1new(JNIEnv * _env, jclass _b, jlong a, jbyteArray b) {
5187         LDKHTLCOutputInCommitment a_conv;
5188         a_conv.inner = (void*)(a & (~1));
5189         a_conv.is_owned = (a & 1) || (a == 0);
5190         if (a_conv.inner != NULL)
5191                 a_conv = HTLCOutputInCommitment_clone(&a_conv);
5192         LDKSignature b_ref;
5193         CHECK((*_env)->GetArrayLength (_env, b) == 64);
5194         (*_env)->GetByteArrayRegion (_env, b, 0, 64, b_ref.compact_form);
5195         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* ret = MALLOC(sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKC2Tuple_HTLCOutputInCommitmentSignatureZ");
5196         *ret = C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a_conv, b_ref);
5197         return (long)ret;
5198 }
5199
5200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5201         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
5202         FREE((void*)this_ptr);
5203         Event_free(this_ptr_conv);
5204 }
5205
5206 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5207         LDKEvent* orig_conv = (LDKEvent*)orig;
5208         LDKEvent* ret = MALLOC(sizeof(LDKEvent), "LDKEvent");
5209         *ret = Event_clone(orig_conv);
5210         return (long)ret;
5211 }
5212
5213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5214         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
5215         FREE((void*)this_ptr);
5216         MessageSendEvent_free(this_ptr_conv);
5217 }
5218
5219 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5220         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
5221         LDKMessageSendEvent* ret = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5222         *ret = MessageSendEvent_clone(orig_conv);
5223         return (long)ret;
5224 }
5225
5226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5227         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
5228         FREE((void*)this_ptr);
5229         MessageSendEventsProvider_free(this_ptr_conv);
5230 }
5231
5232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5233         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
5234         FREE((void*)this_ptr);
5235         EventsProvider_free(this_ptr_conv);
5236 }
5237
5238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5239         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
5240         FREE((void*)this_ptr);
5241         APIError_free(this_ptr_conv);
5242 }
5243
5244 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5245         LDKAPIError* orig_conv = (LDKAPIError*)orig;
5246         LDKAPIError* ret = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5247         *ret = APIError_clone(orig_conv);
5248         return (long)ret;
5249 }
5250
5251 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5252         LDKLevel* orig_conv = (LDKLevel*)orig;
5253         jclass ret = LDKLevel_to_java(_env, Level_clone(orig_conv));
5254         return ret;
5255 }
5256
5257 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv * _env, jclass _b) {
5258         jclass ret = LDKLevel_to_java(_env, Level_max());
5259         return ret;
5260 }
5261
5262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5263         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
5264         FREE((void*)this_ptr);
5265         Logger_free(this_ptr_conv);
5266 }
5267
5268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5269         LDKChannelHandshakeConfig this_ptr_conv;
5270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5271         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5272         ChannelHandshakeConfig_free(this_ptr_conv);
5273 }
5274
5275 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5276         LDKChannelHandshakeConfig orig_conv;
5277         orig_conv.inner = (void*)(orig & (~1));
5278         orig_conv.is_owned = (orig & 1) || (orig == 0);
5279         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_clone(&orig_conv);
5280         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5281 }
5282
5283 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
5284         LDKChannelHandshakeConfig this_ptr_conv;
5285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5286         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5287         jint ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
5288         return ret_val;
5289 }
5290
5291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5292         LDKChannelHandshakeConfig this_ptr_conv;
5293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5294         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5295         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
5296 }
5297
5298 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
5299         LDKChannelHandshakeConfig this_ptr_conv;
5300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5301         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5302         jshort ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
5303         return ret_val;
5304 }
5305
5306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5307         LDKChannelHandshakeConfig this_ptr_conv;
5308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5309         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5310         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
5311 }
5312
5313 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5314         LDKChannelHandshakeConfig this_ptr_conv;
5315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5316         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5317         jlong ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
5318         return ret_val;
5319 }
5320
5321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5322         LDKChannelHandshakeConfig this_ptr_conv;
5323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5324         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5325         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
5326 }
5327
5328 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) {
5329         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
5330         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5331 }
5332
5333 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv * _env, jclass _b) {
5334         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_default();
5335         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5336 }
5337
5338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5339         LDKChannelHandshakeLimits this_ptr_conv;
5340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5341         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5342         ChannelHandshakeLimits_free(this_ptr_conv);
5343 }
5344
5345 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5346         LDKChannelHandshakeLimits orig_conv;
5347         orig_conv.inner = (void*)(orig & (~1));
5348         orig_conv.is_owned = (orig & 1) || (orig == 0);
5349         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_clone(&orig_conv);
5350         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5351 }
5352
5353 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5354         LDKChannelHandshakeLimits this_ptr_conv;
5355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5356         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5357         jlong ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
5358         return ret_val;
5359 }
5360
5361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5362         LDKChannelHandshakeLimits this_ptr_conv;
5363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5364         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5365         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
5366 }
5367
5368 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5369         LDKChannelHandshakeLimits this_ptr_conv;
5370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5371         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5372         jlong ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
5373         return ret_val;
5374 }
5375
5376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5377         LDKChannelHandshakeLimits this_ptr_conv;
5378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5379         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5380         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
5381 }
5382
5383 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5384         LDKChannelHandshakeLimits this_ptr_conv;
5385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5386         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5387         jlong ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
5388         return ret_val;
5389 }
5390
5391 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) {
5392         LDKChannelHandshakeLimits this_ptr_conv;
5393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5394         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5395         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
5396 }
5397
5398 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5399         LDKChannelHandshakeLimits this_ptr_conv;
5400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5401         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5402         jlong ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
5403         return ret_val;
5404 }
5405
5406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5407         LDKChannelHandshakeLimits this_ptr_conv;
5408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5409         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5410         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
5411 }
5412
5413 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
5414         LDKChannelHandshakeLimits this_ptr_conv;
5415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5416         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5417         jshort ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
5418         return ret_val;
5419 }
5420
5421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5422         LDKChannelHandshakeLimits this_ptr_conv;
5423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5424         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5425         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
5426 }
5427
5428 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5429         LDKChannelHandshakeLimits this_ptr_conv;
5430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5431         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5432         jlong ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
5433         return ret_val;
5434 }
5435
5436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5437         LDKChannelHandshakeLimits this_ptr_conv;
5438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5439         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5440         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
5441 }
5442
5443 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5444         LDKChannelHandshakeLimits this_ptr_conv;
5445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5446         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5447         jlong ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
5448         return ret_val;
5449 }
5450
5451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5452         LDKChannelHandshakeLimits this_ptr_conv;
5453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5454         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5455         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
5456 }
5457
5458 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
5459         LDKChannelHandshakeLimits this_ptr_conv;
5460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5462         jint ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
5463         return ret_val;
5464 }
5465
5466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5467         LDKChannelHandshakeLimits this_ptr_conv;
5468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5469         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5470         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
5471 }
5472
5473 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr) {
5474         LDKChannelHandshakeLimits this_ptr_conv;
5475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5476         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5477         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
5478         return ret_val;
5479 }
5480
5481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5482         LDKChannelHandshakeLimits this_ptr_conv;
5483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5484         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5485         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
5486 }
5487
5488 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
5489         LDKChannelHandshakeLimits this_ptr_conv;
5490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5491         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5492         jshort ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
5493         return ret_val;
5494 }
5495
5496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5497         LDKChannelHandshakeLimits this_ptr_conv;
5498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5499         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5500         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
5501 }
5502
5503 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) {
5504         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);
5505         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5506 }
5507
5508 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv * _env, jclass _b) {
5509         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_default();
5510         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5511 }
5512
5513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5514         LDKChannelConfig this_ptr_conv;
5515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5516         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5517         ChannelConfig_free(this_ptr_conv);
5518 }
5519
5520 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5521         LDKChannelConfig orig_conv;
5522         orig_conv.inner = (void*)(orig & (~1));
5523         orig_conv.is_owned = (orig & 1) || (orig == 0);
5524         LDKChannelConfig ret = ChannelConfig_clone(&orig_conv);
5525         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5526 }
5527
5528 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
5529         LDKChannelConfig this_ptr_conv;
5530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5531         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5532         jint ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
5533         return ret_val;
5534 }
5535
5536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
5537         LDKChannelConfig this_ptr_conv;
5538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5539         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5540         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
5541 }
5542
5543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr) {
5544         LDKChannelConfig this_ptr_conv;
5545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5546         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5547         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
5548         return ret_val;
5549 }
5550
5551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5552         LDKChannelConfig this_ptr_conv;
5553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5554         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5555         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
5556 }
5557
5558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
5559         LDKChannelConfig this_ptr_conv;
5560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5561         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5562         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
5563         return ret_val;
5564 }
5565
5566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5567         LDKChannelConfig this_ptr_conv;
5568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5569         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5570         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
5571 }
5572
5573 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) {
5574         LDKChannelConfig ret = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
5575         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5576 }
5577
5578 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv * _env, jclass _b) {
5579         LDKChannelConfig ret = ChannelConfig_default();
5580         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5581 }
5582
5583 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv * _env, jclass _b, jlong obj) {
5584         LDKChannelConfig obj_conv;
5585         obj_conv.inner = (void*)(obj & (~1));
5586         obj_conv.is_owned = (obj & 1) || (obj == 0);
5587         LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
5588         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
5589         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
5590         CVec_u8Z_free(arg_var);
5591         return arg_arr;
5592 }
5593
5594 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
5595         LDKu8slice ser_ref;
5596         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
5597         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
5598         LDKChannelConfig ret = ChannelConfig_read(ser_ref);
5599         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
5600         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5601 }
5602
5603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5604         LDKUserConfig this_ptr_conv;
5605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5606         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5607         UserConfig_free(this_ptr_conv);
5608 }
5609
5610 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5611         LDKUserConfig orig_conv;
5612         orig_conv.inner = (void*)(orig & (~1));
5613         orig_conv.is_owned = (orig & 1) || (orig == 0);
5614         LDKUserConfig ret = UserConfig_clone(&orig_conv);
5615         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5616 }
5617
5618 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
5619         LDKUserConfig this_ptr_conv;
5620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5621         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5622         LDKChannelHandshakeConfig ret = UserConfig_get_own_channel_config(&this_ptr_conv);
5623         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5624 }
5625
5626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5627         LDKUserConfig this_ptr_conv;
5628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5629         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5630         LDKChannelHandshakeConfig val_conv;
5631         val_conv.inner = (void*)(val & (~1));
5632         val_conv.is_owned = (val & 1) || (val == 0);
5633         if (val_conv.inner != NULL)
5634                 val_conv = ChannelHandshakeConfig_clone(&val_conv);
5635         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
5636 }
5637
5638 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr) {
5639         LDKUserConfig this_ptr_conv;
5640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5641         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5642         LDKChannelHandshakeLimits ret = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
5643         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5644 }
5645
5646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5647         LDKUserConfig this_ptr_conv;
5648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5649         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5650         LDKChannelHandshakeLimits val_conv;
5651         val_conv.inner = (void*)(val & (~1));
5652         val_conv.is_owned = (val & 1) || (val == 0);
5653         if (val_conv.inner != NULL)
5654                 val_conv = ChannelHandshakeLimits_clone(&val_conv);
5655         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
5656 }
5657
5658 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr) {
5659         LDKUserConfig this_ptr_conv;
5660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5661         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5662         LDKChannelConfig ret = UserConfig_get_channel_options(&this_ptr_conv);
5663         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5664 }
5665
5666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5667         LDKUserConfig this_ptr_conv;
5668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5669         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5670         LDKChannelConfig val_conv;
5671         val_conv.inner = (void*)(val & (~1));
5672         val_conv.is_owned = (val & 1) || (val == 0);
5673         if (val_conv.inner != NULL)
5674                 val_conv = ChannelConfig_clone(&val_conv);
5675         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
5676 }
5677
5678 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) {
5679         LDKChannelHandshakeConfig own_channel_config_arg_conv;
5680         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
5681         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
5682         if (own_channel_config_arg_conv.inner != NULL)
5683                 own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
5684         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
5685         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
5686         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
5687         if (peer_channel_config_limits_arg_conv.inner != NULL)
5688                 peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
5689         LDKChannelConfig channel_options_arg_conv;
5690         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
5691         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
5692         if (channel_options_arg_conv.inner != NULL)
5693                 channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
5694         LDKUserConfig ret = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
5695         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5696 }
5697
5698 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv * _env, jclass _b) {
5699         LDKUserConfig ret = UserConfig_default();
5700         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5701 }
5702
5703 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5704         LDKAccessError* orig_conv = (LDKAccessError*)orig;
5705         jclass ret = LDKAccessError_to_java(_env, AccessError_clone(orig_conv));
5706         return ret;
5707 }
5708
5709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5710         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
5711         FREE((void*)this_ptr);
5712         Access_free(this_ptr_conv);
5713 }
5714
5715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5716         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
5717         FREE((void*)this_ptr);
5718         Watch_free(this_ptr_conv);
5719 }
5720
5721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5722         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
5723         FREE((void*)this_ptr);
5724         Filter_free(this_ptr_conv);
5725 }
5726
5727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5728         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
5729         FREE((void*)this_ptr);
5730         BroadcasterInterface_free(this_ptr_conv);
5731 }
5732
5733 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5734         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)orig;
5735         jclass ret = LDKConfirmationTarget_to_java(_env, ConfirmationTarget_clone(orig_conv));
5736         return ret;
5737 }
5738
5739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5740         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
5741         FREE((void*)this_ptr);
5742         FeeEstimator_free(this_ptr_conv);
5743 }
5744
5745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5746         LDKChainMonitor this_ptr_conv;
5747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5748         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5749         ChainMonitor_free(this_ptr_conv);
5750 }
5751
5752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height) {
5753         LDKChainMonitor this_arg_conv;
5754         this_arg_conv.inner = (void*)(this_arg & (~1));
5755         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5756         unsigned char header_arr[80];
5757         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5758         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5759         unsigned char (*header_ref)[80] = &header_arr;
5760         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5761         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
5762         if (txdata_constr.datalen > 0)
5763                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5764         else
5765                 txdata_constr.data = NULL;
5766         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
5767         for (size_t d = 0; d < txdata_constr.datalen; d++) {
5768                 long arr_conv_29 = txdata_vals[d];
5769                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
5770                 FREE((void*)arr_conv_29);
5771                 txdata_constr.data[d] = arr_conv_29_conv;
5772         }
5773         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
5774         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
5775 }
5776
5777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint disconnected_height) {
5778         LDKChainMonitor this_arg_conv;
5779         this_arg_conv.inner = (void*)(this_arg & (~1));
5780         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5781         unsigned char header_arr[80];
5782         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5783         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5784         unsigned char (*header_ref)[80] = &header_arr;
5785         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
5786 }
5787
5788 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv * _env, jclass _b, jlong chain_source, jlong broadcaster, jlong logger, jlong feeest) {
5789         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
5790         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5791         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5793                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5794         }
5795         LDKLogger logger_conv = *(LDKLogger*)logger;
5796         if (logger_conv.free == LDKLogger_JCalls_free) {
5797                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5798                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5799         }
5800         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
5801         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
5802                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5803                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
5804         }
5805         LDKChainMonitor ret = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv);
5806         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5807 }
5808
5809 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv * _env, jclass _b, jlong this_arg) {
5810         LDKChainMonitor this_arg_conv;
5811         this_arg_conv.inner = (void*)(this_arg & (~1));
5812         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5813         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
5814         *ret = ChainMonitor_as_Watch(&this_arg_conv);
5815         return (long)ret;
5816 }
5817
5818 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5819         LDKChainMonitor this_arg_conv;
5820         this_arg_conv.inner = (void*)(this_arg & (~1));
5821         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5822         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5823         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
5824         return (long)ret;
5825 }
5826
5827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5828         LDKChannelMonitorUpdate this_ptr_conv;
5829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5830         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5831         ChannelMonitorUpdate_free(this_ptr_conv);
5832 }
5833
5834 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5835         LDKChannelMonitorUpdate orig_conv;
5836         orig_conv.inner = (void*)(orig & (~1));
5837         orig_conv.is_owned = (orig & 1) || (orig == 0);
5838         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_clone(&orig_conv);
5839         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5840 }
5841
5842 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5843         LDKChannelMonitorUpdate this_ptr_conv;
5844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5845         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5846         jlong ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
5847         return ret_val;
5848 }
5849
5850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5851         LDKChannelMonitorUpdate this_ptr_conv;
5852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5853         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5854         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
5855 }
5856
5857 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5858         LDKChannelMonitorUpdate obj_conv;
5859         obj_conv.inner = (void*)(obj & (~1));
5860         obj_conv.is_owned = (obj & 1) || (obj == 0);
5861         LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
5862         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
5863         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
5864         CVec_u8Z_free(arg_var);
5865         return arg_arr;
5866 }
5867
5868 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
5869         LDKu8slice ser_ref;
5870         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
5871         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
5872         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_read(ser_ref);
5873         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
5874         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5875 }
5876
5877 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5878         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)orig;
5879         jclass ret = LDKChannelMonitorUpdateErr_to_java(_env, ChannelMonitorUpdateErr_clone(orig_conv));
5880         return ret;
5881 }
5882
5883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5884         LDKMonitorUpdateError this_ptr_conv;
5885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5886         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5887         MonitorUpdateError_free(this_ptr_conv);
5888 }
5889
5890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5891         LDKMonitorEvent this_ptr_conv;
5892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5893         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5894         MonitorEvent_free(this_ptr_conv);
5895 }
5896
5897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5898         LDKHTLCUpdate this_ptr_conv;
5899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5900         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5901         HTLCUpdate_free(this_ptr_conv);
5902 }
5903
5904 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5905         LDKHTLCUpdate orig_conv;
5906         orig_conv.inner = (void*)(orig & (~1));
5907         orig_conv.is_owned = (orig & 1) || (orig == 0);
5908         LDKHTLCUpdate ret = HTLCUpdate_clone(&orig_conv);
5909         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5910 }
5911
5912 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5913         LDKHTLCUpdate obj_conv;
5914         obj_conv.inner = (void*)(obj & (~1));
5915         obj_conv.is_owned = (obj & 1) || (obj == 0);
5916         LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
5917         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
5918         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
5919         CVec_u8Z_free(arg_var);
5920         return arg_arr;
5921 }
5922
5923 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
5924         LDKu8slice ser_ref;
5925         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
5926         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
5927         LDKHTLCUpdate ret = HTLCUpdate_read(ser_ref);
5928         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
5929         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5930 }
5931
5932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5933         LDKChannelMonitor this_ptr_conv;
5934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5935         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5936         ChannelMonitor_free(this_ptr_conv);
5937 }
5938
5939 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv * _env, jclass _b, jlong this_arg, jlong updates, jlong broadcaster, jlong logger) {
5940         LDKChannelMonitor this_arg_conv;
5941         this_arg_conv.inner = (void*)(this_arg & (~1));
5942         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5943         LDKChannelMonitorUpdate updates_conv;
5944         updates_conv.inner = (void*)(updates & (~1));
5945         updates_conv.is_owned = (updates & 1) || (updates == 0);
5946         if (updates_conv.inner != NULL)
5947                 updates_conv = ChannelMonitorUpdate_clone(&updates_conv);
5948         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
5949         LDKLogger* logger_conv = (LDKLogger*)logger;
5950         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
5951         *ret = ChannelMonitor_update_monitor(&this_arg_conv, updates_conv, broadcaster_conv, logger_conv);
5952         return (long)ret;
5953 }
5954
5955 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5956         LDKChannelMonitor this_arg_conv;
5957         this_arg_conv.inner = (void*)(this_arg & (~1));
5958         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5959         jlong ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
5960         return ret_val;
5961 }
5962
5963 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv * _env, jclass _b, jlong this_arg) {
5964         LDKChannelMonitor this_arg_conv;
5965         this_arg_conv.inner = (void*)(this_arg & (~1));
5966         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5967         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5968         *ret = ChannelMonitor_get_funding_txo(&this_arg_conv);
5969         return (long)ret;
5970 }
5971
5972 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
5973         LDKChannelMonitor this_arg_conv;
5974         this_arg_conv.inner = (void*)(this_arg & (~1));
5975         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5976         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
5977         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
5978         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
5979         for (size_t o = 0; o < ret_var.datalen; o++) {
5980                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
5981                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5982                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5983                 long arr_conv_14_ref;
5984                 if (arr_conv_14_var.is_owned) {
5985                         arr_conv_14_ref = (long)arr_conv_14_var.inner | 1;
5986                 } else {
5987                         arr_conv_14_ref = (long)arr_conv_14_var.inner & ~1;
5988                 }
5989                 ret_arr_ptr[o] = arr_conv_14_ref;
5990         }
5991         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
5992         FREE(ret_var.data);
5993         return ret_arr;
5994 }
5995
5996 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
5997         LDKChannelMonitor this_arg_conv;
5998         this_arg_conv.inner = (void*)(this_arg & (~1));
5999         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6000         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
6001         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6002         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6003         for (size_t h = 0; h < ret_var.datalen; h++) {
6004                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6005                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
6006                 long arr_conv_7_ref = (long)arr_conv_7_copy;
6007                 ret_arr_ptr[h] = arr_conv_7_ref;
6008         }
6009         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6010         CVec_EventZ_free(ret_var);
6011         return ret_arr;
6012 }
6013
6014 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) {
6015         LDKChannelMonitor this_arg_conv;
6016         this_arg_conv.inner = (void*)(this_arg & (~1));
6017         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6018         LDKLogger* logger_conv = (LDKLogger*)logger;
6019         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
6020         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6021         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6022         for (size_t n = 0; n < ret_var.datalen; n++) {
6023                 long arr_conv_13_ref = (long)&ret_var.data[n];
6024                 ret_arr_ptr[n] = arr_conv_13_ref;
6025         }
6026         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6027         CVec_TransactionZ_free(ret_var);
6028         return ret_arr;
6029 }
6030
6031 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) {
6032         LDKChannelMonitor this_arg_conv;
6033         this_arg_conv.inner = (void*)(this_arg & (~1));
6034         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6035         unsigned char header_arr[80];
6036         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6037         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6038         unsigned char (*header_ref)[80] = &header_arr;
6039         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6040         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
6041         if (txdata_constr.datalen > 0)
6042                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6043         else
6044                 txdata_constr.data = NULL;
6045         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
6046         for (size_t d = 0; d < txdata_constr.datalen; d++) {
6047                 long arr_conv_29 = txdata_vals[d];
6048                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
6049                 FREE((void*)arr_conv_29);
6050                 txdata_constr.data[d] = arr_conv_29_conv;
6051         }
6052         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
6053         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6054         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6055                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6056                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
6057         }
6058         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6059         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6060                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6061                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6062         }
6063         LDKLogger logger_conv = *(LDKLogger*)logger;
6064         if (logger_conv.free == LDKLogger_JCalls_free) {
6065                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6066                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6067         }
6068         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
6069         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6070         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6071         for (size_t b = 0; b < ret_var.datalen; b++) {
6072                 /*XXX False */long arr_conv_27_ref = (long)&ret_var.data[b];
6073                 ret_arr_ptr[b] = arr_conv_27_ref;
6074         }
6075         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6076         CVec_C2Tuple_TxidCVec_TxOutZZZ_free(ret_var);
6077         return ret_arr;
6078 }
6079
6080 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) {
6081         LDKChannelMonitor this_arg_conv;
6082         this_arg_conv.inner = (void*)(this_arg & (~1));
6083         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6084         unsigned char header_arr[80];
6085         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6086         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6087         unsigned char (*header_ref)[80] = &header_arr;
6088         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6089         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6090                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6091                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
6092         }
6093         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6094         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6095                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6096                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6097         }
6098         LDKLogger logger_conv = *(LDKLogger*)logger;
6099         if (logger_conv.free == LDKLogger_JCalls_free) {
6100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6101                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6102         }
6103         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
6104 }
6105
6106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6107         LDKOutPoint this_ptr_conv;
6108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6109         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6110         OutPoint_free(this_ptr_conv);
6111 }
6112
6113 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6114         LDKOutPoint orig_conv;
6115         orig_conv.inner = (void*)(orig & (~1));
6116         orig_conv.is_owned = (orig & 1) || (orig == 0);
6117         LDKOutPoint ret = OutPoint_clone(&orig_conv);
6118         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6119 }
6120
6121 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
6122         LDKOutPoint this_ptr_conv;
6123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6124         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6125         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6126         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
6127         return ret_arr;
6128 }
6129
6130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6131         LDKOutPoint this_ptr_conv;
6132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6133         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6134         LDKThirtyTwoBytes val_ref;
6135         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6136         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6137         OutPoint_set_txid(&this_ptr_conv, val_ref);
6138 }
6139
6140 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
6141         LDKOutPoint this_ptr_conv;
6142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6143         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6144         jshort ret_val = OutPoint_get_index(&this_ptr_conv);
6145         return ret_val;
6146 }
6147
6148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6149         LDKOutPoint this_ptr_conv;
6150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6151         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6152         OutPoint_set_index(&this_ptr_conv, val);
6153 }
6154
6155 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv * _env, jclass _b, jbyteArray txid_arg, jshort index_arg) {
6156         LDKThirtyTwoBytes txid_arg_ref;
6157         CHECK((*_env)->GetArrayLength (_env, txid_arg) == 32);
6158         (*_env)->GetByteArrayRegion (_env, txid_arg, 0, 32, txid_arg_ref.data);
6159         LDKOutPoint ret = OutPoint_new(txid_arg_ref, index_arg);
6160         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6161 }
6162
6163 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6164         LDKOutPoint this_arg_conv;
6165         this_arg_conv.inner = (void*)(this_arg & (~1));
6166         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6167         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
6168         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
6169         return arg_arr;
6170 }
6171
6172 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv * _env, jclass _b, jlong obj) {
6173         LDKOutPoint obj_conv;
6174         obj_conv.inner = (void*)(obj & (~1));
6175         obj_conv.is_owned = (obj & 1) || (obj == 0);
6176         LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
6177         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
6178         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
6179         CVec_u8Z_free(arg_var);
6180         return arg_arr;
6181 }
6182
6183 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
6184         LDKu8slice ser_ref;
6185         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
6186         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
6187         LDKOutPoint ret = OutPoint_read(ser_ref);
6188         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
6189         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6190 }
6191
6192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6193         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
6194         FREE((void*)this_ptr);
6195         SpendableOutputDescriptor_free(this_ptr_conv);
6196 }
6197
6198 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6199         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
6200         LDKSpendableOutputDescriptor* ret = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
6201         *ret = SpendableOutputDescriptor_clone(orig_conv);
6202         return (long)ret;
6203 }
6204
6205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6206         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
6207         FREE((void*)this_ptr);
6208         ChannelKeys_free(this_ptr_conv);
6209 }
6210
6211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6212         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
6213         FREE((void*)this_ptr);
6214         KeysInterface_free(this_ptr_conv);
6215 }
6216
6217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6218         LDKInMemoryChannelKeys this_ptr_conv;
6219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6220         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6221         InMemoryChannelKeys_free(this_ptr_conv);
6222 }
6223
6224 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6225         LDKInMemoryChannelKeys orig_conv;
6226         orig_conv.inner = (void*)(orig & (~1));
6227         orig_conv.is_owned = (orig & 1) || (orig == 0);
6228         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_clone(&orig_conv);
6229         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6230 }
6231
6232 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6233         LDKInMemoryChannelKeys this_ptr_conv;
6234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6235         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6236         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6237         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv));
6238         return ret_arr;
6239 }
6240
6241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6242         LDKInMemoryChannelKeys 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         LDKSecretKey val_ref;
6246         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6247         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6248         InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
6249 }
6250
6251 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6252         LDKInMemoryChannelKeys this_ptr_conv;
6253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6254         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6255         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6256         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv));
6257         return ret_arr;
6258 }
6259
6260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6261         LDKInMemoryChannelKeys this_ptr_conv;
6262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6263         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6264         LDKSecretKey val_ref;
6265         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6266         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6267         InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
6268 }
6269
6270 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6271         LDKInMemoryChannelKeys this_ptr_conv;
6272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6273         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6274         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6275         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv));
6276         return ret_arr;
6277 }
6278
6279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6280         LDKInMemoryChannelKeys this_ptr_conv;
6281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6282         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6283         LDKSecretKey val_ref;
6284         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6285         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6286         InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
6287 }
6288
6289 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6290         LDKInMemoryChannelKeys this_ptr_conv;
6291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6292         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6293         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6294         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv));
6295         return ret_arr;
6296 }
6297
6298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6299         LDKInMemoryChannelKeys this_ptr_conv;
6300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6301         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6302         LDKSecretKey val_ref;
6303         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6304         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6305         InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
6306 }
6307
6308 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
6309         LDKInMemoryChannelKeys this_ptr_conv;
6310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6311         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6312         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6313         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv));
6314         return ret_arr;
6315 }
6316
6317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
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         LDKSecretKey val_ref;
6322         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6323         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
6324         InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
6325 }
6326
6327 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr) {
6328         LDKInMemoryChannelKeys this_ptr_conv;
6329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6330         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6331         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6332         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv));
6333         return ret_arr;
6334 }
6335
6336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
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         LDKThirtyTwoBytes val_ref;
6341         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6342         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6343         InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
6344 }
6345
6346 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) {
6347         LDKSecretKey funding_key_ref;
6348         CHECK((*_env)->GetArrayLength (_env, funding_key) == 32);
6349         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_ref.bytes);
6350         LDKSecretKey revocation_base_key_ref;
6351         CHECK((*_env)->GetArrayLength (_env, revocation_base_key) == 32);
6352         (*_env)->GetByteArrayRegion (_env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
6353         LDKSecretKey payment_key_ref;
6354         CHECK((*_env)->GetArrayLength (_env, payment_key) == 32);
6355         (*_env)->GetByteArrayRegion (_env, payment_key, 0, 32, payment_key_ref.bytes);
6356         LDKSecretKey delayed_payment_base_key_ref;
6357         CHECK((*_env)->GetArrayLength (_env, delayed_payment_base_key) == 32);
6358         (*_env)->GetByteArrayRegion (_env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
6359         LDKSecretKey htlc_base_key_ref;
6360         CHECK((*_env)->GetArrayLength (_env, htlc_base_key) == 32);
6361         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
6362         LDKThirtyTwoBytes commitment_seed_ref;
6363         CHECK((*_env)->GetArrayLength (_env, commitment_seed) == 32);
6364         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_ref.data);
6365         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
6366         FREE((void*)key_derivation_params);
6367         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);
6368         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6369 }
6370
6371 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
6372         LDKInMemoryChannelKeys this_arg_conv;
6373         this_arg_conv.inner = (void*)(this_arg & (~1));
6374         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6375         LDKChannelPublicKeys ret = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
6376         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6377 }
6378
6379 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
6380         LDKInMemoryChannelKeys this_arg_conv;
6381         this_arg_conv.inner = (void*)(this_arg & (~1));
6382         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6383         jshort ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
6384         return ret_val;
6385 }
6386
6387 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1holder_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
6388         LDKInMemoryChannelKeys this_arg_conv;
6389         this_arg_conv.inner = (void*)(this_arg & (~1));
6390         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6391         jshort ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
6392         return ret_val;
6393 }
6394
6395 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1as_1ChannelKeys(JNIEnv * _env, jclass _b, jlong this_arg) {
6396         LDKInMemoryChannelKeys this_arg_conv;
6397         this_arg_conv.inner = (void*)(this_arg & (~1));
6398         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6399         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
6400         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
6401         return (long)ret;
6402 }
6403
6404 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
6405         LDKInMemoryChannelKeys obj_conv;
6406         obj_conv.inner = (void*)(obj & (~1));
6407         obj_conv.is_owned = (obj & 1) || (obj == 0);
6408         LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
6409         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
6410         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
6411         CVec_u8Z_free(arg_var);
6412         return arg_arr;
6413 }
6414
6415 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
6416         LDKu8slice ser_ref;
6417         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
6418         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
6419         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_read(ser_ref);
6420         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
6421         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6422 }
6423
6424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6425         LDKKeysManager this_ptr_conv;
6426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6427         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6428         KeysManager_free(this_ptr_conv);
6429 }
6430
6431 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) {
6432         unsigned char seed_arr[32];
6433         CHECK((*_env)->GetArrayLength (_env, seed) == 32);
6434         (*_env)->GetByteArrayRegion (_env, seed, 0, 32, seed_arr);
6435         unsigned char (*seed_ref)[32] = &seed_arr;
6436         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
6437         LDKKeysManager ret = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
6438         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6439 }
6440
6441 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) {
6442         LDKKeysManager this_arg_conv;
6443         this_arg_conv.inner = (void*)(this_arg & (~1));
6444         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6445         LDKInMemoryChannelKeys ret = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
6446         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6447 }
6448
6449 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv * _env, jclass _b, jlong this_arg) {
6450         LDKKeysManager this_arg_conv;
6451         this_arg_conv.inner = (void*)(this_arg & (~1));
6452         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6453         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6454         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
6455         return (long)ret;
6456 }
6457
6458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6459         LDKChannelManager this_ptr_conv;
6460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6462         ChannelManager_free(this_ptr_conv);
6463 }
6464
6465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6466         LDKChannelDetails this_ptr_conv;
6467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6468         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6469         ChannelDetails_free(this_ptr_conv);
6470 }
6471
6472 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6473         LDKChannelDetails orig_conv;
6474         orig_conv.inner = (void*)(orig & (~1));
6475         orig_conv.is_owned = (orig & 1) || (orig == 0);
6476         LDKChannelDetails ret = ChannelDetails_clone(&orig_conv);
6477         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6478 }
6479
6480 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6481         LDKChannelDetails this_ptr_conv;
6482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6483         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6484         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6485         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
6486         return ret_arr;
6487 }
6488
6489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6490         LDKChannelDetails this_ptr_conv;
6491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6492         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6493         LDKThirtyTwoBytes val_ref;
6494         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6495         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6496         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
6497 }
6498
6499 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6500         LDKChannelDetails this_ptr_conv;
6501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6502         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6503         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6504         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
6505         return arg_arr;
6506 }
6507
6508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6509         LDKChannelDetails 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         LDKPublicKey val_ref;
6513         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6514         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6515         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
6516 }
6517
6518 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
6519         LDKChannelDetails this_ptr_conv;
6520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6521         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6522         LDKInitFeatures ret = ChannelDetails_get_counterparty_features(&this_ptr_conv);
6523         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6524 }
6525
6526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6527         LDKChannelDetails this_ptr_conv;
6528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6529         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6530         LDKInitFeatures val_conv;
6531         val_conv.inner = (void*)(val & (~1));
6532         val_conv.is_owned = (val & 1) || (val == 0);
6533         // Warning: we may need a move here but can't clone!
6534         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
6535 }
6536
6537 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6538         LDKChannelDetails this_ptr_conv;
6539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6540         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6541         jlong ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
6542         return ret_val;
6543 }
6544
6545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6546         LDKChannelDetails this_ptr_conv;
6547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6548         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6549         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
6550 }
6551
6552 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6553         LDKChannelDetails this_ptr_conv;
6554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6555         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6556         jlong ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
6557         return ret_val;
6558 }
6559
6560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6561         LDKChannelDetails this_ptr_conv;
6562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6563         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6564         ChannelDetails_set_user_id(&this_ptr_conv, val);
6565 }
6566
6567 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6568         LDKChannelDetails this_ptr_conv;
6569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6570         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6571         jlong ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
6572         return ret_val;
6573 }
6574
6575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6576         LDKChannelDetails this_ptr_conv;
6577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6578         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6579         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
6580 }
6581
6582 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6583         LDKChannelDetails this_ptr_conv;
6584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6585         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6586         jlong ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
6587         return ret_val;
6588 }
6589
6590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6591         LDKChannelDetails this_ptr_conv;
6592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6593         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6594         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
6595 }
6596
6597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr) {
6598         LDKChannelDetails this_ptr_conv;
6599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6600         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6601         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
6602         return ret_val;
6603 }
6604
6605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
6606         LDKChannelDetails this_ptr_conv;
6607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6608         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6609         ChannelDetails_set_is_live(&this_ptr_conv, val);
6610 }
6611
6612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6613         LDKPaymentSendFailure this_ptr_conv;
6614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6615         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6616         PaymentSendFailure_free(this_ptr_conv);
6617 }
6618
6619 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) {
6620         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
6621         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
6622         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
6623                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6624                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
6625         }
6626         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
6627         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
6628                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6629                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
6630         }
6631         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
6632         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6633                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6634                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
6635         }
6636         LDKLogger logger_conv = *(LDKLogger*)logger;
6637         if (logger_conv.free == LDKLogger_JCalls_free) {
6638                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6639                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6640         }
6641         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
6642         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
6643                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6644                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
6645         }
6646         LDKUserConfig config_conv;
6647         config_conv.inner = (void*)(config & (~1));
6648         config_conv.is_owned = (config & 1) || (config == 0);
6649         if (config_conv.inner != NULL)
6650                 config_conv = UserConfig_clone(&config_conv);
6651         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);
6652         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6653 }
6654
6655 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) {
6656         LDKChannelManager this_arg_conv;
6657         this_arg_conv.inner = (void*)(this_arg & (~1));
6658         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6659         LDKPublicKey their_network_key_ref;
6660         CHECK((*_env)->GetArrayLength (_env, their_network_key) == 33);
6661         (*_env)->GetByteArrayRegion (_env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
6662         LDKUserConfig override_config_conv;
6663         override_config_conv.inner = (void*)(override_config & (~1));
6664         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
6665         if (override_config_conv.inner != NULL)
6666                 override_config_conv = UserConfig_clone(&override_config_conv);
6667         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6668         *ret = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
6669         return (long)ret;
6670 }
6671
6672 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6673         LDKChannelManager this_arg_conv;
6674         this_arg_conv.inner = (void*)(this_arg & (~1));
6675         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6676         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
6677         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6678         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6679         for (size_t q = 0; q < ret_var.datalen; q++) {
6680                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
6681                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6682                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6683                 long arr_conv_16_ref;
6684                 if (arr_conv_16_var.is_owned) {
6685                         arr_conv_16_ref = (long)arr_conv_16_var.inner | 1;
6686                 } else {
6687                         arr_conv_16_ref = (long)arr_conv_16_var.inner & ~1;
6688                 }
6689                 ret_arr_ptr[q] = arr_conv_16_ref;
6690         }
6691         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6692         FREE(ret_var.data);
6693         return ret_arr;
6694 }
6695
6696 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6697         LDKChannelManager this_arg_conv;
6698         this_arg_conv.inner = (void*)(this_arg & (~1));
6699         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6700         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
6701         jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen);
6702         jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL);
6703         for (size_t q = 0; q < ret_var.datalen; q++) {
6704                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
6705                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6706                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6707                 long arr_conv_16_ref;
6708                 if (arr_conv_16_var.is_owned) {
6709                         arr_conv_16_ref = (long)arr_conv_16_var.inner | 1;
6710                 } else {
6711                         arr_conv_16_ref = (long)arr_conv_16_var.inner & ~1;
6712                 }
6713                 ret_arr_ptr[q] = arr_conv_16_ref;
6714         }
6715         (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0);
6716         FREE(ret_var.data);
6717         return ret_arr;
6718 }
6719
6720 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
6721         LDKChannelManager this_arg_conv;
6722         this_arg_conv.inner = (void*)(this_arg & (~1));
6723         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6724         unsigned char channel_id_arr[32];
6725         CHECK((*_env)->GetArrayLength (_env, channel_id) == 32);
6726         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
6727         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6728         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6729         *ret = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
6730         return (long)ret;
6731 }
6732
6733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
6734         LDKChannelManager this_arg_conv;
6735         this_arg_conv.inner = (void*)(this_arg & (~1));
6736         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6737         unsigned char channel_id_arr[32];
6738         CHECK((*_env)->GetArrayLength (_env, channel_id) == 32);
6739         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
6740         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6741         ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
6742 }
6743
6744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6745         LDKChannelManager this_arg_conv;
6746         this_arg_conv.inner = (void*)(this_arg & (~1));
6747         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6748         ChannelManager_force_close_all_channels(&this_arg_conv);
6749 }
6750
6751 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) {
6752         LDKChannelManager this_arg_conv;
6753         this_arg_conv.inner = (void*)(this_arg & (~1));
6754         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6755         LDKRoute route_conv;
6756         route_conv.inner = (void*)(route & (~1));
6757         route_conv.is_owned = (route & 1) || (route == 0);
6758         LDKThirtyTwoBytes payment_hash_ref;
6759         CHECK((*_env)->GetArrayLength (_env, payment_hash) == 32);
6760         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_ref.data);
6761         LDKThirtyTwoBytes payment_secret_ref;
6762         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6763         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6764         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
6765         *ret = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
6766         return (long)ret;
6767 }
6768
6769 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) {
6770         LDKChannelManager this_arg_conv;
6771         this_arg_conv.inner = (void*)(this_arg & (~1));
6772         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6773         unsigned char temporary_channel_id_arr[32];
6774         CHECK((*_env)->GetArrayLength (_env, temporary_channel_id) == 32);
6775         (*_env)->GetByteArrayRegion (_env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
6776         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
6777         LDKOutPoint funding_txo_conv;
6778         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6779         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6780         if (funding_txo_conv.inner != NULL)
6781                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6782         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
6783 }
6784
6785 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) {
6786         LDKChannelManager this_arg_conv;
6787         this_arg_conv.inner = (void*)(this_arg & (~1));
6788         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6789         LDKThreeBytes rgb_ref;
6790         CHECK((*_env)->GetArrayLength (_env, rgb) == 3);
6791         (*_env)->GetByteArrayRegion (_env, rgb, 0, 3, rgb_ref.data);
6792         LDKThirtyTwoBytes alias_ref;
6793         CHECK((*_env)->GetArrayLength (_env, alias) == 32);
6794         (*_env)->GetByteArrayRegion (_env, alias, 0, 32, alias_ref.data);
6795         LDKCVec_NetAddressZ addresses_constr;
6796         addresses_constr.datalen = (*_env)->GetArrayLength (_env, addresses);
6797         if (addresses_constr.datalen > 0)
6798                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
6799         else
6800                 addresses_constr.data = NULL;
6801         long* addresses_vals = (*_env)->GetLongArrayElements (_env, addresses, NULL);
6802         for (size_t m = 0; m < addresses_constr.datalen; m++) {
6803                 long arr_conv_12 = addresses_vals[m];
6804                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
6805                 FREE((void*)arr_conv_12);
6806                 addresses_constr.data[m] = arr_conv_12_conv;
6807         }
6808         (*_env)->ReleaseLongArrayElements (_env, addresses, addresses_vals, 0);
6809         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
6810 }
6811
6812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv * _env, jclass _b, jlong this_arg) {
6813         LDKChannelManager this_arg_conv;
6814         this_arg_conv.inner = (void*)(this_arg & (~1));
6815         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6816         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
6817 }
6818
6819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv * _env, jclass _b, jlong this_arg) {
6820         LDKChannelManager this_arg_conv;
6821         this_arg_conv.inner = (void*)(this_arg & (~1));
6822         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6823         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
6824 }
6825
6826 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) {
6827         LDKChannelManager this_arg_conv;
6828         this_arg_conv.inner = (void*)(this_arg & (~1));
6829         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6830         unsigned char payment_hash_arr[32];
6831         CHECK((*_env)->GetArrayLength (_env, payment_hash) == 32);
6832         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_arr);
6833         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
6834         LDKThirtyTwoBytes payment_secret_ref;
6835         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6836         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6837         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
6838         return ret_val;
6839 }
6840
6841 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) {
6842         LDKChannelManager this_arg_conv;
6843         this_arg_conv.inner = (void*)(this_arg & (~1));
6844         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6845         LDKThirtyTwoBytes payment_preimage_ref;
6846         CHECK((*_env)->GetArrayLength (_env, payment_preimage) == 32);
6847         (*_env)->GetByteArrayRegion (_env, payment_preimage, 0, 32, payment_preimage_ref.data);
6848         LDKThirtyTwoBytes payment_secret_ref;
6849         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6850         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6851         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
6852         return ret_val;
6853 }
6854
6855 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6856         LDKChannelManager this_arg_conv;
6857         this_arg_conv.inner = (void*)(this_arg & (~1));
6858         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6859         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6860         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
6861         return arg_arr;
6862 }
6863
6864 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) {
6865         LDKChannelManager this_arg_conv;
6866         this_arg_conv.inner = (void*)(this_arg & (~1));
6867         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6868         LDKOutPoint funding_txo_conv;
6869         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6870         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6871         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
6872 }
6873
6874 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6875         LDKChannelManager this_arg_conv;
6876         this_arg_conv.inner = (void*)(this_arg & (~1));
6877         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6878         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6879         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
6880         return (long)ret;
6881 }
6882
6883 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6884         LDKChannelManager this_arg_conv;
6885         this_arg_conv.inner = (void*)(this_arg & (~1));
6886         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6887         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6888         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
6889         return (long)ret;
6890 }
6891
6892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height) {
6893         LDKChannelManager this_arg_conv;
6894         this_arg_conv.inner = (void*)(this_arg & (~1));
6895         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6896         unsigned char header_arr[80];
6897         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6898         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6899         unsigned char (*header_ref)[80] = &header_arr;
6900         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6901         txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata);
6902         if (txdata_constr.datalen > 0)
6903                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6904         else
6905                 txdata_constr.data = NULL;
6906         long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL);
6907         for (size_t d = 0; d < txdata_constr.datalen; d++) {
6908                 long arr_conv_29 = txdata_vals[d];
6909                 LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29;
6910                 FREE((void*)arr_conv_29);
6911                 txdata_constr.data[d] = arr_conv_29_conv;
6912         }
6913         (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0);
6914         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
6915 }
6916
6917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header) {
6918         LDKChannelManager this_arg_conv;
6919         this_arg_conv.inner = (void*)(this_arg & (~1));
6920         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6921         unsigned char header_arr[80];
6922         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6923         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6924         unsigned char (*header_ref)[80] = &header_arr;
6925         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
6926 }
6927
6928 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
6929         LDKChannelManager this_arg_conv;
6930         this_arg_conv.inner = (void*)(this_arg & (~1));
6931         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6932         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6933         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
6934         return (long)ret;
6935 }
6936
6937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6938         LDKChannelManagerReadArgs this_ptr_conv;
6939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6940         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6941         ChannelManagerReadArgs_free(this_ptr_conv);
6942 }
6943
6944 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr) {
6945         LDKChannelManagerReadArgs this_ptr_conv;
6946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6947         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6948         long ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
6949         return ret;
6950 }
6951
6952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6953         LDKChannelManagerReadArgs this_ptr_conv;
6954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6955         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6956         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
6957         if (val_conv.free == LDKKeysInterface_JCalls_free) {
6958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6959                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
6960         }
6961         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
6962 }
6963
6964 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr) {
6965         LDKChannelManagerReadArgs this_ptr_conv;
6966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6967         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6968         long ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
6969         return ret;
6970 }
6971
6972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6973         LDKChannelManagerReadArgs this_ptr_conv;
6974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6975         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6976         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
6977         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
6978                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6979                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
6980         }
6981         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
6982 }
6983
6984 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr) {
6985         LDKChannelManagerReadArgs this_ptr_conv;
6986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6987         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6988         long ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
6989         return ret;
6990 }
6991
6992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6993         LDKChannelManagerReadArgs this_ptr_conv;
6994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6995         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6996         LDKWatch val_conv = *(LDKWatch*)val;
6997         if (val_conv.free == LDKWatch_JCalls_free) {
6998                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6999                 LDKWatch_JCalls_clone(val_conv.this_arg);
7000         }
7001         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
7002 }
7003
7004 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr) {
7005         LDKChannelManagerReadArgs this_ptr_conv;
7006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7007         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7008         long ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
7009         return ret;
7010 }
7011
7012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7013         LDKChannelManagerReadArgs this_ptr_conv;
7014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7015         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7016         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
7017         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
7018                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7019                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
7020         }
7021         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
7022 }
7023
7024 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv * _env, jclass _b, jlong this_ptr) {
7025         LDKChannelManagerReadArgs this_ptr_conv;
7026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7027         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7028         long ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
7029         return ret;
7030 }
7031
7032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7033         LDKChannelManagerReadArgs this_ptr_conv;
7034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7035         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7036         LDKLogger val_conv = *(LDKLogger*)val;
7037         if (val_conv.free == LDKLogger_JCalls_free) {
7038                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7039                 LDKLogger_JCalls_clone(val_conv.this_arg);
7040         }
7041         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
7042 }
7043
7044 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
7045         LDKChannelManagerReadArgs this_ptr_conv;
7046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7047         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7048         LDKUserConfig ret = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
7049         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7050 }
7051
7052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7053         LDKChannelManagerReadArgs this_ptr_conv;
7054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7055         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7056         LDKUserConfig val_conv;
7057         val_conv.inner = (void*)(val & (~1));
7058         val_conv.is_owned = (val & 1) || (val == 0);
7059         if (val_conv.inner != NULL)
7060                 val_conv = UserConfig_clone(&val_conv);
7061         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
7062 }
7063
7064 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) {
7065         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
7066         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
7067                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7068                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
7069         }
7070         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
7071         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
7072                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7073                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
7074         }
7075         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
7076         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
7077                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7078                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
7079         }
7080         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
7081         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
7082                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7083                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
7084         }
7085         LDKLogger logger_conv = *(LDKLogger*)logger;
7086         if (logger_conv.free == LDKLogger_JCalls_free) {
7087                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7088                 LDKLogger_JCalls_clone(logger_conv.this_arg);
7089         }
7090         LDKUserConfig default_config_conv;
7091         default_config_conv.inner = (void*)(default_config & (~1));
7092         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
7093         if (default_config_conv.inner != NULL)
7094                 default_config_conv = UserConfig_clone(&default_config_conv);
7095         LDKCVec_ChannelMonitorZ channel_monitors_constr;
7096         channel_monitors_constr.datalen = (*_env)->GetArrayLength (_env, channel_monitors);
7097         if (channel_monitors_constr.datalen > 0)
7098                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7099         else
7100                 channel_monitors_constr.data = NULL;
7101         long* channel_monitors_vals = (*_env)->GetLongArrayElements (_env, channel_monitors, NULL);
7102         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
7103                 long arr_conv_16 = channel_monitors_vals[q];
7104                 LDKChannelMonitor arr_conv_16_conv;
7105                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
7106                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
7107                 // Warning: we may need a move here but can't clone!
7108                 channel_monitors_constr.data[q] = arr_conv_16_conv;
7109         }
7110         (*_env)->ReleaseLongArrayElements (_env, channel_monitors, channel_monitors_vals, 0);
7111         LDKChannelManagerReadArgs ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
7112         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7113 }
7114
7115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7116         LDKDecodeError this_ptr_conv;
7117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7118         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7119         DecodeError_free(this_ptr_conv);
7120 }
7121
7122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7123         LDKInit this_ptr_conv;
7124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7125         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7126         Init_free(this_ptr_conv);
7127 }
7128
7129 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7130         LDKInit orig_conv;
7131         orig_conv.inner = (void*)(orig & (~1));
7132         orig_conv.is_owned = (orig & 1) || (orig == 0);
7133         LDKInit ret = Init_clone(&orig_conv);
7134         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7135 }
7136
7137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7138         LDKErrorMessage this_ptr_conv;
7139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7140         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7141         ErrorMessage_free(this_ptr_conv);
7142 }
7143
7144 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7145         LDKErrorMessage orig_conv;
7146         orig_conv.inner = (void*)(orig & (~1));
7147         orig_conv.is_owned = (orig & 1) || (orig == 0);
7148         LDKErrorMessage ret = ErrorMessage_clone(&orig_conv);
7149         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7150 }
7151
7152 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7153         LDKErrorMessage this_ptr_conv;
7154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7155         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7156         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7157         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
7158         return ret_arr;
7159 }
7160
7161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7162         LDKErrorMessage this_ptr_conv;
7163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7164         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7165         LDKThirtyTwoBytes val_ref;
7166         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7167         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7168         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
7169 }
7170
7171 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) {
7172         LDKErrorMessage this_ptr_conv;
7173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7174         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7175         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
7176         char* _buf = MALLOC(_str.len + 1, "str conv buf");
7177         memcpy(_buf, _str.chars, _str.len);
7178         _buf[_str.len] = 0;
7179         jstring _conv = (*_env)->NewStringUTF(_env, _str.chars);
7180         FREE(_buf);
7181         return _conv;
7182 }
7183
7184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7185         LDKErrorMessage this_ptr_conv;
7186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7187         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7188         LDKCVec_u8Z val_ref;
7189         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
7190         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
7191         ErrorMessage_set_data(&this_ptr_conv, val_ref);
7192         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
7193 }
7194
7195 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray data_arg) {
7196         LDKThirtyTwoBytes channel_id_arg_ref;
7197         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7198         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7199         LDKCVec_u8Z data_arg_ref;
7200         data_arg_ref.data = (*_env)->GetByteArrayElements (_env, data_arg, NULL);
7201         data_arg_ref.datalen = (*_env)->GetArrayLength (_env, data_arg);
7202         LDKErrorMessage ret = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
7203         (*_env)->ReleaseByteArrayElements(_env, data_arg, (int8_t*)data_arg_ref.data, 0);
7204         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7205 }
7206
7207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7208         LDKPing this_ptr_conv;
7209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7210         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7211         Ping_free(this_ptr_conv);
7212 }
7213
7214 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7215         LDKPing orig_conv;
7216         orig_conv.inner = (void*)(orig & (~1));
7217         orig_conv.is_owned = (orig & 1) || (orig == 0);
7218         LDKPing ret = Ping_clone(&orig_conv);
7219         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7220 }
7221
7222 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7223         LDKPing this_ptr_conv;
7224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7225         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7226         jshort ret_val = Ping_get_ponglen(&this_ptr_conv);
7227         return ret_val;
7228 }
7229
7230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7231         LDKPing this_ptr_conv;
7232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7233         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7234         Ping_set_ponglen(&this_ptr_conv, val);
7235 }
7236
7237 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7238         LDKPing this_ptr_conv;
7239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7240         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7241         jshort ret_val = Ping_get_byteslen(&this_ptr_conv);
7242         return ret_val;
7243 }
7244
7245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7246         LDKPing 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         Ping_set_byteslen(&this_ptr_conv, val);
7250 }
7251
7252 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv * _env, jclass _b, jshort ponglen_arg, jshort byteslen_arg) {
7253         LDKPing ret = Ping_new(ponglen_arg, byteslen_arg);
7254         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7255 }
7256
7257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7258         LDKPong this_ptr_conv;
7259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7260         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7261         Pong_free(this_ptr_conv);
7262 }
7263
7264 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7265         LDKPong orig_conv;
7266         orig_conv.inner = (void*)(orig & (~1));
7267         orig_conv.is_owned = (orig & 1) || (orig == 0);
7268         LDKPong ret = Pong_clone(&orig_conv);
7269         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7270 }
7271
7272 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
7273         LDKPong this_ptr_conv;
7274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7275         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7276         jshort ret_val = Pong_get_byteslen(&this_ptr_conv);
7277         return ret_val;
7278 }
7279
7280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7281         LDKPong this_ptr_conv;
7282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7283         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7284         Pong_set_byteslen(&this_ptr_conv, val);
7285 }
7286
7287 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv * _env, jclass _b, jshort byteslen_arg) {
7288         LDKPong ret = Pong_new(byteslen_arg);
7289         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7290 }
7291
7292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7293         LDKOpenChannel this_ptr_conv;
7294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7295         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7296         OpenChannel_free(this_ptr_conv);
7297 }
7298
7299 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7300         LDKOpenChannel orig_conv;
7301         orig_conv.inner = (void*)(orig & (~1));
7302         orig_conv.is_owned = (orig & 1) || (orig == 0);
7303         LDKOpenChannel ret = OpenChannel_clone(&orig_conv);
7304         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7305 }
7306
7307 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7308         LDKOpenChannel this_ptr_conv;
7309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7310         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7311         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7312         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
7313         return ret_arr;
7314 }
7315
7316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7317         LDKOpenChannel this_ptr_conv;
7318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7319         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7320         LDKThirtyTwoBytes val_ref;
7321         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7322         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7323         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
7324 }
7325
7326 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7327         LDKOpenChannel this_ptr_conv;
7328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7329         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7330         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7331         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
7332         return ret_arr;
7333 }
7334
7335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7336         LDKOpenChannel this_ptr_conv;
7337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7338         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7339         LDKThirtyTwoBytes val_ref;
7340         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7341         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7342         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7343 }
7344
7345 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7346         LDKOpenChannel this_ptr_conv;
7347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7348         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7349         jlong ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
7350         return ret_val;
7351 }
7352
7353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7354         LDKOpenChannel this_ptr_conv;
7355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7356         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7357         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
7358 }
7359
7360 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7361         LDKOpenChannel this_ptr_conv;
7362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7363         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7364         jlong ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
7365         return ret_val;
7366 }
7367
7368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7369         LDKOpenChannel this_ptr_conv;
7370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7371         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7372         OpenChannel_set_push_msat(&this_ptr_conv, val);
7373 }
7374
7375 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7376         LDKOpenChannel this_ptr_conv;
7377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7378         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7379         jlong ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
7380         return ret_val;
7381 }
7382
7383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7384         LDKOpenChannel this_ptr_conv;
7385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7386         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7387         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7388 }
7389
7390 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7391         LDKOpenChannel this_ptr_conv;
7392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7393         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7394         jlong ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7395         return ret_val;
7396 }
7397
7398 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) {
7399         LDKOpenChannel this_ptr_conv;
7400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7401         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7402         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7403 }
7404
7405 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7406         LDKOpenChannel this_ptr_conv;
7407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7408         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7409         jlong ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7410         return ret_val;
7411 }
7412
7413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7414         LDKOpenChannel this_ptr_conv;
7415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7416         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7417         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7418 }
7419
7420 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7421         LDKOpenChannel this_ptr_conv;
7422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7423         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7424         jlong ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
7425         return ret_val;
7426 }
7427
7428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7429         LDKOpenChannel this_ptr_conv;
7430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7431         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7432         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7433 }
7434
7435 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
7436         LDKOpenChannel this_ptr_conv;
7437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7438         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7439         jint ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
7440         return ret_val;
7441 }
7442
7443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7444         LDKOpenChannel this_ptr_conv;
7445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7446         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7447         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
7448 }
7449
7450 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
7451         LDKOpenChannel this_ptr_conv;
7452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7453         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7454         jshort ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
7455         return ret_val;
7456 }
7457
7458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7459         LDKOpenChannel this_ptr_conv;
7460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7462         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
7463 }
7464
7465 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
7466         LDKOpenChannel this_ptr_conv;
7467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7468         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7469         jshort ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
7470         return ret_val;
7471 }
7472
7473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7474         LDKOpenChannel this_ptr_conv;
7475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7476         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7477         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7478 }
7479
7480 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
7481         LDKOpenChannel this_ptr_conv;
7482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7483         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7484         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7485         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
7486         return arg_arr;
7487 }
7488
7489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
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         LDKPublicKey val_ref;
7494         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7495         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7496         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7497 }
7498
7499 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7500         LDKOpenChannel this_ptr_conv;
7501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7502         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7503         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7504         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
7505         return arg_arr;
7506 }
7507
7508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7509         LDKOpenChannel this_ptr_conv;
7510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7511         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7512         LDKPublicKey val_ref;
7513         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7514         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7515         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7516 }
7517
7518 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7519         LDKOpenChannel this_ptr_conv;
7520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7521         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7522         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7523         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
7524         return arg_arr;
7525 }
7526
7527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray 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         LDKPublicKey val_ref;
7532         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7533         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7534         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
7535 }
7536
7537 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7538         LDKOpenChannel this_ptr_conv;
7539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7540         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7541         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7542         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
7543         return arg_arr;
7544 }
7545
7546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7547         LDKOpenChannel this_ptr_conv;
7548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7549         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7550         LDKPublicKey val_ref;
7551         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7552         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7553         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7554 }
7555
7556 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7557         LDKOpenChannel this_ptr_conv;
7558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7559         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7560         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7561         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
7562         return arg_arr;
7563 }
7564
7565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7566         LDKOpenChannel this_ptr_conv;
7567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7568         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7569         LDKPublicKey val_ref;
7570         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7571         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7572         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7573 }
7574
7575 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7576         LDKOpenChannel this_ptr_conv;
7577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7578         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7579         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7580         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
7581         return arg_arr;
7582 }
7583
7584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7585         LDKOpenChannel this_ptr_conv;
7586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7587         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7588         LDKPublicKey val_ref;
7589         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7590         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7591         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7592 }
7593
7594 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
7595         LDKOpenChannel this_ptr_conv;
7596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7597         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7598         jbyte ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
7599         return ret_val;
7600 }
7601
7602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
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         OpenChannel_set_channel_flags(&this_ptr_conv, val);
7607 }
7608
7609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7610         LDKAcceptChannel this_ptr_conv;
7611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7612         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7613         AcceptChannel_free(this_ptr_conv);
7614 }
7615
7616 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7617         LDKAcceptChannel orig_conv;
7618         orig_conv.inner = (void*)(orig & (~1));
7619         orig_conv.is_owned = (orig & 1) || (orig == 0);
7620         LDKAcceptChannel ret = AcceptChannel_clone(&orig_conv);
7621         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7622 }
7623
7624 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7625         LDKAcceptChannel this_ptr_conv;
7626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7627         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7628         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7629         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
7630         return ret_arr;
7631 }
7632
7633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7634         LDKAcceptChannel this_ptr_conv;
7635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7636         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7637         LDKThirtyTwoBytes val_ref;
7638         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7639         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7640         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7641 }
7642
7643 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7644         LDKAcceptChannel this_ptr_conv;
7645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7646         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7647         jlong ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
7648         return ret_val;
7649 }
7650
7651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7652         LDKAcceptChannel this_ptr_conv;
7653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7654         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7655         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7656 }
7657
7658 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7659         LDKAcceptChannel this_ptr_conv;
7660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7661         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7662         jlong ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7663         return ret_val;
7664 }
7665
7666 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) {
7667         LDKAcceptChannel this_ptr_conv;
7668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7669         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7670         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7671 }
7672
7673 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7674         LDKAcceptChannel this_ptr_conv;
7675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7676         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7677         jlong ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7678         return ret_val;
7679 }
7680
7681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7682         LDKAcceptChannel this_ptr_conv;
7683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7684         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7685         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7686 }
7687
7688 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7689         LDKAcceptChannel this_ptr_conv;
7690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7691         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7692         jlong ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
7693         return ret_val;
7694 }
7695
7696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7697         LDKAcceptChannel this_ptr_conv;
7698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7699         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7700         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7701 }
7702
7703 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
7704         LDKAcceptChannel this_ptr_conv;
7705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7706         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7707         jint ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
7708         return ret_val;
7709 }
7710
7711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7712         LDKAcceptChannel this_ptr_conv;
7713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7715         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
7716 }
7717
7718 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
7719         LDKAcceptChannel this_ptr_conv;
7720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7721         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7722         jshort ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
7723         return ret_val;
7724 }
7725
7726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7727         LDKAcceptChannel this_ptr_conv;
7728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7729         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7730         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
7731 }
7732
7733 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
7734         LDKAcceptChannel this_ptr_conv;
7735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7736         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7737         jshort ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
7738         return ret_val;
7739 }
7740
7741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7742         LDKAcceptChannel this_ptr_conv;
7743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7744         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7745         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7746 }
7747
7748 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
7749         LDKAcceptChannel this_ptr_conv;
7750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7751         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7752         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7753         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
7754         return arg_arr;
7755 }
7756
7757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
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         LDKPublicKey val_ref;
7762         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7763         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7764         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7765 }
7766
7767 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7768         LDKAcceptChannel this_ptr_conv;
7769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7770         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7771         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7772         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
7773         return arg_arr;
7774 }
7775
7776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7777         LDKAcceptChannel this_ptr_conv;
7778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7779         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7780         LDKPublicKey val_ref;
7781         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7782         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7783         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7784 }
7785
7786 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7787         LDKAcceptChannel this_ptr_conv;
7788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7789         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7790         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7791         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
7792         return arg_arr;
7793 }
7794
7795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray 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         LDKPublicKey val_ref;
7800         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7801         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7802         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
7803 }
7804
7805 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7806         LDKAcceptChannel this_ptr_conv;
7807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7808         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7809         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7810         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
7811         return arg_arr;
7812 }
7813
7814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7815         LDKAcceptChannel this_ptr_conv;
7816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7817         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7818         LDKPublicKey val_ref;
7819         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7820         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7821         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7822 }
7823
7824 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7825         LDKAcceptChannel this_ptr_conv;
7826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7827         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7828         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7829         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
7830         return arg_arr;
7831 }
7832
7833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7834         LDKAcceptChannel this_ptr_conv;
7835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7836         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7837         LDKPublicKey val_ref;
7838         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7839         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7840         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7841 }
7842
7843 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7844         LDKAcceptChannel this_ptr_conv;
7845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7846         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7847         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7848         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
7849         return arg_arr;
7850 }
7851
7852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7853         LDKAcceptChannel this_ptr_conv;
7854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7855         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7856         LDKPublicKey val_ref;
7857         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7858         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7859         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7860 }
7861
7862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7863         LDKFundingCreated this_ptr_conv;
7864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7865         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7866         FundingCreated_free(this_ptr_conv);
7867 }
7868
7869 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7870         LDKFundingCreated orig_conv;
7871         orig_conv.inner = (void*)(orig & (~1));
7872         orig_conv.is_owned = (orig & 1) || (orig == 0);
7873         LDKFundingCreated ret = FundingCreated_clone(&orig_conv);
7874         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7875 }
7876
7877 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7878         LDKFundingCreated this_ptr_conv;
7879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7880         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7881         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7882         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
7883         return ret_arr;
7884 }
7885
7886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7887         LDKFundingCreated this_ptr_conv;
7888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7889         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7890         LDKThirtyTwoBytes val_ref;
7891         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7892         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7893         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
7894 }
7895
7896 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
7897         LDKFundingCreated this_ptr_conv;
7898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7899         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7900         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7901         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
7902         return ret_arr;
7903 }
7904
7905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7906         LDKFundingCreated this_ptr_conv;
7907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7908         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7909         LDKThirtyTwoBytes val_ref;
7910         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7911         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7912         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
7913 }
7914
7915 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
7916         LDKFundingCreated this_ptr_conv;
7917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7918         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7919         jshort ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
7920         return ret_val;
7921 }
7922
7923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7924         LDKFundingCreated this_ptr_conv;
7925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7926         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7927         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
7928 }
7929
7930 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7931         LDKFundingCreated this_ptr_conv;
7932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7933         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7934         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
7935         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
7936         return arg_arr;
7937 }
7938
7939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7940         LDKFundingCreated this_ptr_conv;
7941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7942         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7943         LDKSignature val_ref;
7944         CHECK((*_env)->GetArrayLength (_env, val) == 64);
7945         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
7946         FundingCreated_set_signature(&this_ptr_conv, val_ref);
7947 }
7948
7949 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) {
7950         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
7951         CHECK((*_env)->GetArrayLength (_env, temporary_channel_id_arg) == 32);
7952         (*_env)->GetByteArrayRegion (_env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
7953         LDKThirtyTwoBytes funding_txid_arg_ref;
7954         CHECK((*_env)->GetArrayLength (_env, funding_txid_arg) == 32);
7955         (*_env)->GetByteArrayRegion (_env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
7956         LDKSignature signature_arg_ref;
7957         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
7958         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
7959         LDKFundingCreated ret = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
7960         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7961 }
7962
7963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7964         LDKFundingSigned this_ptr_conv;
7965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7966         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7967         FundingSigned_free(this_ptr_conv);
7968 }
7969
7970 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7971         LDKFundingSigned orig_conv;
7972         orig_conv.inner = (void*)(orig & (~1));
7973         orig_conv.is_owned = (orig & 1) || (orig == 0);
7974         LDKFundingSigned ret = FundingSigned_clone(&orig_conv);
7975         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7976 }
7977
7978 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7979         LDKFundingSigned this_ptr_conv;
7980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7981         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7982         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7983         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
7984         return ret_arr;
7985 }
7986
7987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7988         LDKFundingSigned this_ptr_conv;
7989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7990         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7991         LDKThirtyTwoBytes val_ref;
7992         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7993         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7994         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
7995 }
7996
7997 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7998         LDKFundingSigned this_ptr_conv;
7999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8000         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8001         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8002         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
8003         return arg_arr;
8004 }
8005
8006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8007         LDKFundingSigned this_ptr_conv;
8008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8009         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8010         LDKSignature val_ref;
8011         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8012         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8013         FundingSigned_set_signature(&this_ptr_conv, val_ref);
8014 }
8015
8016 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray signature_arg) {
8017         LDKThirtyTwoBytes channel_id_arg_ref;
8018         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8019         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8020         LDKSignature signature_arg_ref;
8021         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8022         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8023         LDKFundingSigned ret = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
8024         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8025 }
8026
8027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8028         LDKFundingLocked this_ptr_conv;
8029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8030         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8031         FundingLocked_free(this_ptr_conv);
8032 }
8033
8034 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8035         LDKFundingLocked orig_conv;
8036         orig_conv.inner = (void*)(orig & (~1));
8037         orig_conv.is_owned = (orig & 1) || (orig == 0);
8038         LDKFundingLocked ret = FundingLocked_clone(&orig_conv);
8039         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8040 }
8041
8042 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8043         LDKFundingLocked this_ptr_conv;
8044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8045         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8046         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8047         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
8048         return ret_arr;
8049 }
8050
8051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8052         LDKFundingLocked this_ptr_conv;
8053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8054         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8055         LDKThirtyTwoBytes val_ref;
8056         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8057         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8058         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
8059 }
8060
8061 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8062         LDKFundingLocked this_ptr_conv;
8063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8064         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8065         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8066         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
8067         return arg_arr;
8068 }
8069
8070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8071         LDKFundingLocked this_ptr_conv;
8072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8073         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8074         LDKPublicKey val_ref;
8075         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8076         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8077         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
8078 }
8079
8080 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray next_per_commitment_point_arg) {
8081         LDKThirtyTwoBytes channel_id_arg_ref;
8082         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8083         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8084         LDKPublicKey next_per_commitment_point_arg_ref;
8085         CHECK((*_env)->GetArrayLength (_env, next_per_commitment_point_arg) == 33);
8086         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
8087         LDKFundingLocked ret = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
8088         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8089 }
8090
8091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8092         LDKShutdown this_ptr_conv;
8093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8094         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8095         Shutdown_free(this_ptr_conv);
8096 }
8097
8098 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8099         LDKShutdown orig_conv;
8100         orig_conv.inner = (void*)(orig & (~1));
8101         orig_conv.is_owned = (orig & 1) || (orig == 0);
8102         LDKShutdown ret = Shutdown_clone(&orig_conv);
8103         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8104 }
8105
8106 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8107         LDKShutdown this_ptr_conv;
8108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8109         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8110         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8111         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
8112         return ret_arr;
8113 }
8114
8115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8116         LDKShutdown this_ptr_conv;
8117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8118         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8119         LDKThirtyTwoBytes val_ref;
8120         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8121         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8122         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
8123 }
8124
8125 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
8126         LDKShutdown this_ptr_conv;
8127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8128         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8129         LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
8130         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
8131         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
8132         return arg_arr;
8133 }
8134
8135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8136         LDKShutdown 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         LDKCVec_u8Z val_ref;
8140         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
8141         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
8142         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
8143         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
8144 }
8145
8146 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray scriptpubkey_arg) {
8147         LDKThirtyTwoBytes channel_id_arg_ref;
8148         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8149         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8150         LDKCVec_u8Z scriptpubkey_arg_ref;
8151         scriptpubkey_arg_ref.data = (*_env)->GetByteArrayElements (_env, scriptpubkey_arg, NULL);
8152         scriptpubkey_arg_ref.datalen = (*_env)->GetArrayLength (_env, scriptpubkey_arg);
8153         LDKShutdown ret = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
8154         (*_env)->ReleaseByteArrayElements(_env, scriptpubkey_arg, (int8_t*)scriptpubkey_arg_ref.data, 0);
8155         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8156 }
8157
8158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8159         LDKClosingSigned this_ptr_conv;
8160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8161         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8162         ClosingSigned_free(this_ptr_conv);
8163 }
8164
8165 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8166         LDKClosingSigned orig_conv;
8167         orig_conv.inner = (void*)(orig & (~1));
8168         orig_conv.is_owned = (orig & 1) || (orig == 0);
8169         LDKClosingSigned ret = ClosingSigned_clone(&orig_conv);
8170         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8171 }
8172
8173 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8174         LDKClosingSigned this_ptr_conv;
8175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8176         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8177         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8178         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
8179         return ret_arr;
8180 }
8181
8182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8183         LDKClosingSigned this_ptr_conv;
8184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8185         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8186         LDKThirtyTwoBytes val_ref;
8187         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8188         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8189         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
8190 }
8191
8192 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
8193         LDKClosingSigned this_ptr_conv;
8194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8195         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8196         jlong ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
8197         return ret_val;
8198 }
8199
8200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8201         LDKClosingSigned this_ptr_conv;
8202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8203         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8204         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
8205 }
8206
8207 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8208         LDKClosingSigned this_ptr_conv;
8209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8210         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8211         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8212         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
8213         return arg_arr;
8214 }
8215
8216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8217         LDKClosingSigned this_ptr_conv;
8218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8219         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8220         LDKSignature val_ref;
8221         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8222         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8223         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
8224 }
8225
8226 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) {
8227         LDKThirtyTwoBytes channel_id_arg_ref;
8228         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8229         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8230         LDKSignature signature_arg_ref;
8231         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8232         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8233         LDKClosingSigned ret = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
8234         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8235 }
8236
8237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8238         LDKUpdateAddHTLC this_ptr_conv;
8239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8240         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8241         UpdateAddHTLC_free(this_ptr_conv);
8242 }
8243
8244 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8245         LDKUpdateAddHTLC orig_conv;
8246         orig_conv.inner = (void*)(orig & (~1));
8247         orig_conv.is_owned = (orig & 1) || (orig == 0);
8248         LDKUpdateAddHTLC ret = UpdateAddHTLC_clone(&orig_conv);
8249         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8250 }
8251
8252 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8253         LDKUpdateAddHTLC this_ptr_conv;
8254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8255         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8256         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8257         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
8258         return ret_arr;
8259 }
8260
8261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8262         LDKUpdateAddHTLC this_ptr_conv;
8263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8264         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8265         LDKThirtyTwoBytes val_ref;
8266         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8267         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8268         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
8269 }
8270
8271 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8272         LDKUpdateAddHTLC this_ptr_conv;
8273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8274         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8275         jlong ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
8276         return ret_val;
8277 }
8278
8279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8280         LDKUpdateAddHTLC this_ptr_conv;
8281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8282         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8283         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
8284 }
8285
8286 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8287         LDKUpdateAddHTLC this_ptr_conv;
8288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8289         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8290         jlong ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
8291         return ret_val;
8292 }
8293
8294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8295         LDKUpdateAddHTLC this_ptr_conv;
8296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8297         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8298         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
8299 }
8300
8301 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8302         LDKUpdateAddHTLC this_ptr_conv;
8303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8304         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8305         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8306         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
8307         return ret_arr;
8308 }
8309
8310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8311         LDKUpdateAddHTLC this_ptr_conv;
8312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8313         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8314         LDKThirtyTwoBytes val_ref;
8315         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8316         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8317         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
8318 }
8319
8320 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
8321         LDKUpdateAddHTLC this_ptr_conv;
8322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8323         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8324         jint ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
8325         return ret_val;
8326 }
8327
8328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8329         LDKUpdateAddHTLC this_ptr_conv;
8330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8331         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8332         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
8333 }
8334
8335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8336         LDKUpdateFulfillHTLC this_ptr_conv;
8337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8338         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8339         UpdateFulfillHTLC_free(this_ptr_conv);
8340 }
8341
8342 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8343         LDKUpdateFulfillHTLC orig_conv;
8344         orig_conv.inner = (void*)(orig & (~1));
8345         orig_conv.is_owned = (orig & 1) || (orig == 0);
8346         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_clone(&orig_conv);
8347         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8348 }
8349
8350 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8351         LDKUpdateFulfillHTLC this_ptr_conv;
8352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8353         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8354         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8355         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
8356         return ret_arr;
8357 }
8358
8359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8360         LDKUpdateFulfillHTLC this_ptr_conv;
8361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8362         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8363         LDKThirtyTwoBytes val_ref;
8364         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8365         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8366         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
8367 }
8368
8369 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8370         LDKUpdateFulfillHTLC this_ptr_conv;
8371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8372         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8373         jlong ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
8374         return ret_val;
8375 }
8376
8377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8378         LDKUpdateFulfillHTLC this_ptr_conv;
8379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8380         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8381         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
8382 }
8383
8384 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr) {
8385         LDKUpdateFulfillHTLC this_ptr_conv;
8386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8387         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8388         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8389         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
8390         return ret_arr;
8391 }
8392
8393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8394         LDKUpdateFulfillHTLC this_ptr_conv;
8395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8396         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8397         LDKThirtyTwoBytes val_ref;
8398         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8399         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8400         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
8401 }
8402
8403 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) {
8404         LDKThirtyTwoBytes channel_id_arg_ref;
8405         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8406         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8407         LDKThirtyTwoBytes payment_preimage_arg_ref;
8408         CHECK((*_env)->GetArrayLength (_env, payment_preimage_arg) == 32);
8409         (*_env)->GetByteArrayRegion (_env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
8410         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
8411         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8412 }
8413
8414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8415         LDKUpdateFailHTLC this_ptr_conv;
8416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8417         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8418         UpdateFailHTLC_free(this_ptr_conv);
8419 }
8420
8421 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8422         LDKUpdateFailHTLC orig_conv;
8423         orig_conv.inner = (void*)(orig & (~1));
8424         orig_conv.is_owned = (orig & 1) || (orig == 0);
8425         LDKUpdateFailHTLC ret = UpdateFailHTLC_clone(&orig_conv);
8426         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8427 }
8428
8429 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8430         LDKUpdateFailHTLC this_ptr_conv;
8431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8432         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8433         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8434         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
8435         return ret_arr;
8436 }
8437
8438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8439         LDKUpdateFailHTLC this_ptr_conv;
8440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8441         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8442         LDKThirtyTwoBytes val_ref;
8443         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8444         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8445         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
8446 }
8447
8448 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8449         LDKUpdateFailHTLC this_ptr_conv;
8450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8451         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8452         jlong ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
8453         return ret_val;
8454 }
8455
8456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8457         LDKUpdateFailHTLC this_ptr_conv;
8458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8459         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8460         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
8461 }
8462
8463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8464         LDKUpdateFailMalformedHTLC this_ptr_conv;
8465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8466         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8467         UpdateFailMalformedHTLC_free(this_ptr_conv);
8468 }
8469
8470 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8471         LDKUpdateFailMalformedHTLC orig_conv;
8472         orig_conv.inner = (void*)(orig & (~1));
8473         orig_conv.is_owned = (orig & 1) || (orig == 0);
8474         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_clone(&orig_conv);
8475         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8476 }
8477
8478 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8479         LDKUpdateFailMalformedHTLC this_ptr_conv;
8480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8481         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8482         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8483         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
8484         return ret_arr;
8485 }
8486
8487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8488         LDKUpdateFailMalformedHTLC this_ptr_conv;
8489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8490         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8491         LDKThirtyTwoBytes val_ref;
8492         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8493         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8494         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
8495 }
8496
8497 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8498         LDKUpdateFailMalformedHTLC this_ptr_conv;
8499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8500         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8501         jlong ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
8502         return ret_val;
8503 }
8504
8505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8506         LDKUpdateFailMalformedHTLC this_ptr_conv;
8507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8508         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8509         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
8510 }
8511
8512 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr) {
8513         LDKUpdateFailMalformedHTLC this_ptr_conv;
8514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8515         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8516         jshort ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
8517         return ret_val;
8518 }
8519
8520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
8521         LDKUpdateFailMalformedHTLC this_ptr_conv;
8522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8523         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8524         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
8525 }
8526
8527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8528         LDKCommitmentSigned this_ptr_conv;
8529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8530         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8531         CommitmentSigned_free(this_ptr_conv);
8532 }
8533
8534 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8535         LDKCommitmentSigned orig_conv;
8536         orig_conv.inner = (void*)(orig & (~1));
8537         orig_conv.is_owned = (orig & 1) || (orig == 0);
8538         LDKCommitmentSigned ret = CommitmentSigned_clone(&orig_conv);
8539         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8540 }
8541
8542 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8543         LDKCommitmentSigned this_ptr_conv;
8544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8545         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8546         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8547         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
8548         return ret_arr;
8549 }
8550
8551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8552         LDKCommitmentSigned this_ptr_conv;
8553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8554         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8555         LDKThirtyTwoBytes val_ref;
8556         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8557         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8558         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
8559 }
8560
8561 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8562         LDKCommitmentSigned this_ptr_conv;
8563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8564         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8565         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8566         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
8567         return arg_arr;
8568 }
8569
8570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8571         LDKCommitmentSigned this_ptr_conv;
8572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8573         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8574         LDKSignature val_ref;
8575         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8576         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8577         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
8578 }
8579
8580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jobjectArray val) {
8581         LDKCommitmentSigned this_ptr_conv;
8582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8583         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8584         LDKCVec_SignatureZ val_constr;
8585         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
8586         if (val_constr.datalen > 0)
8587                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8588         else
8589                 val_constr.data = NULL;
8590         for (size_t i = 0; i < val_constr.datalen; i++) {
8591                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, val, i);
8592                 LDKSignature arr_conv_8_ref;
8593                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
8594                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
8595                 val_constr.data[i] = arr_conv_8_ref;
8596         }
8597         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
8598 }
8599
8600 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) {
8601         LDKThirtyTwoBytes channel_id_arg_ref;
8602         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8603         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8604         LDKSignature signature_arg_ref;
8605         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8606         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8607         LDKCVec_SignatureZ htlc_signatures_arg_constr;
8608         htlc_signatures_arg_constr.datalen = (*_env)->GetArrayLength (_env, htlc_signatures_arg);
8609         if (htlc_signatures_arg_constr.datalen > 0)
8610                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8611         else
8612                 htlc_signatures_arg_constr.data = NULL;
8613         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
8614                 jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, htlc_signatures_arg, i);
8615                 LDKSignature arr_conv_8_ref;
8616                 CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64);
8617                 (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
8618                 htlc_signatures_arg_constr.data[i] = arr_conv_8_ref;
8619         }
8620         LDKCommitmentSigned ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
8621         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8622 }
8623
8624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8625         LDKRevokeAndACK this_ptr_conv;
8626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8627         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8628         RevokeAndACK_free(this_ptr_conv);
8629 }
8630
8631 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8632         LDKRevokeAndACK orig_conv;
8633         orig_conv.inner = (void*)(orig & (~1));
8634         orig_conv.is_owned = (orig & 1) || (orig == 0);
8635         LDKRevokeAndACK ret = RevokeAndACK_clone(&orig_conv);
8636         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8637 }
8638
8639 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8640         LDKRevokeAndACK this_ptr_conv;
8641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8642         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8643         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8644         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
8645         return ret_arr;
8646 }
8647
8648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8649         LDKRevokeAndACK this_ptr_conv;
8650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8651         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8652         LDKThirtyTwoBytes val_ref;
8653         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8654         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8655         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
8656 }
8657
8658 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
8659         LDKRevokeAndACK this_ptr_conv;
8660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8661         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8662         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8663         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
8664         return ret_arr;
8665 }
8666
8667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8668         LDKRevokeAndACK this_ptr_conv;
8669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8670         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8671         LDKThirtyTwoBytes val_ref;
8672         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8673         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8674         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
8675 }
8676
8677 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8678         LDKRevokeAndACK this_ptr_conv;
8679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8680         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8681         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8682         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
8683         return arg_arr;
8684 }
8685
8686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8687         LDKRevokeAndACK this_ptr_conv;
8688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8689         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8690         LDKPublicKey val_ref;
8691         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8692         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8693         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
8694 }
8695
8696 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) {
8697         LDKThirtyTwoBytes channel_id_arg_ref;
8698         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8699         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8700         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
8701         CHECK((*_env)->GetArrayLength (_env, per_commitment_secret_arg) == 32);
8702         (*_env)->GetByteArrayRegion (_env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
8703         LDKPublicKey next_per_commitment_point_arg_ref;
8704         CHECK((*_env)->GetArrayLength (_env, next_per_commitment_point_arg) == 33);
8705         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
8706         LDKRevokeAndACK ret = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
8707         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8708 }
8709
8710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8711         LDKUpdateFee this_ptr_conv;
8712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8713         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8714         UpdateFee_free(this_ptr_conv);
8715 }
8716
8717 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8718         LDKUpdateFee orig_conv;
8719         orig_conv.inner = (void*)(orig & (~1));
8720         orig_conv.is_owned = (orig & 1) || (orig == 0);
8721         LDKUpdateFee ret = UpdateFee_clone(&orig_conv);
8722         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8723 }
8724
8725 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8726         LDKUpdateFee this_ptr_conv;
8727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8728         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8729         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8730         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
8731         return ret_arr;
8732 }
8733
8734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8735         LDKUpdateFee this_ptr_conv;
8736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8737         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8738         LDKThirtyTwoBytes val_ref;
8739         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8740         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8741         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
8742 }
8743
8744 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
8745         LDKUpdateFee this_ptr_conv;
8746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8747         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8748         jint ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
8749         return ret_val;
8750 }
8751
8752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8753         LDKUpdateFee this_ptr_conv;
8754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8755         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8756         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
8757 }
8758
8759 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jint feerate_per_kw_arg) {
8760         LDKThirtyTwoBytes channel_id_arg_ref;
8761         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8762         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8763         LDKUpdateFee ret = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
8764         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8765 }
8766
8767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8768         LDKDataLossProtect this_ptr_conv;
8769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8770         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8771         DataLossProtect_free(this_ptr_conv);
8772 }
8773
8774 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8775         LDKDataLossProtect orig_conv;
8776         orig_conv.inner = (void*)(orig & (~1));
8777         orig_conv.is_owned = (orig & 1) || (orig == 0);
8778         LDKDataLossProtect ret = DataLossProtect_clone(&orig_conv);
8779         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8780 }
8781
8782 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
8783         LDKDataLossProtect this_ptr_conv;
8784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8785         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8786         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8787         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
8788         return ret_arr;
8789 }
8790
8791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8792         LDKDataLossProtect this_ptr_conv;
8793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8794         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8795         LDKThirtyTwoBytes val_ref;
8796         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8797         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8798         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
8799 }
8800
8801 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8802         LDKDataLossProtect this_ptr_conv;
8803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8804         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8805         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8806         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
8807         return arg_arr;
8808 }
8809
8810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8811         LDKDataLossProtect this_ptr_conv;
8812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8813         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8814         LDKPublicKey val_ref;
8815         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8816         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8817         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
8818 }
8819
8820 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) {
8821         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
8822         CHECK((*_env)->GetArrayLength (_env, your_last_per_commitment_secret_arg) == 32);
8823         (*_env)->GetByteArrayRegion (_env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
8824         LDKPublicKey my_current_per_commitment_point_arg_ref;
8825         CHECK((*_env)->GetArrayLength (_env, my_current_per_commitment_point_arg) == 33);
8826         (*_env)->GetByteArrayRegion (_env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
8827         LDKDataLossProtect ret = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
8828         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8829 }
8830
8831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8832         LDKChannelReestablish this_ptr_conv;
8833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8834         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8835         ChannelReestablish_free(this_ptr_conv);
8836 }
8837
8838 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8839         LDKChannelReestablish orig_conv;
8840         orig_conv.inner = (void*)(orig & (~1));
8841         orig_conv.is_owned = (orig & 1) || (orig == 0);
8842         LDKChannelReestablish ret = ChannelReestablish_clone(&orig_conv);
8843         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8844 }
8845
8846 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8847         LDKChannelReestablish this_ptr_conv;
8848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8849         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8850         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8851         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
8852         return ret_arr;
8853 }
8854
8855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8856         LDKChannelReestablish this_ptr_conv;
8857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8858         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8859         LDKThirtyTwoBytes val_ref;
8860         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8861         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8862         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
8863 }
8864
8865 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
8866         LDKChannelReestablish this_ptr_conv;
8867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8868         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8869         jlong ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
8870         return ret_val;
8871 }
8872
8873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8874         LDKChannelReestablish this_ptr_conv;
8875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8876         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8877         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
8878 }
8879
8880 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
8881         LDKChannelReestablish this_ptr_conv;
8882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8883         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8884         jlong ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
8885         return ret_val;
8886 }
8887
8888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8889         LDKChannelReestablish this_ptr_conv;
8890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8891         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8892         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
8893 }
8894
8895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8896         LDKAnnouncementSignatures this_ptr_conv;
8897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8898         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8899         AnnouncementSignatures_free(this_ptr_conv);
8900 }
8901
8902 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8903         LDKAnnouncementSignatures orig_conv;
8904         orig_conv.inner = (void*)(orig & (~1));
8905         orig_conv.is_owned = (orig & 1) || (orig == 0);
8906         LDKAnnouncementSignatures ret = AnnouncementSignatures_clone(&orig_conv);
8907         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8908 }
8909
8910 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8911         LDKAnnouncementSignatures this_ptr_conv;
8912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8913         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8914         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8915         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
8916         return ret_arr;
8917 }
8918
8919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8920         LDKAnnouncementSignatures this_ptr_conv;
8921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8922         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8923         LDKThirtyTwoBytes val_ref;
8924         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8925         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8926         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
8927 }
8928
8929 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8930         LDKAnnouncementSignatures this_ptr_conv;
8931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8932         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8933         jlong ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
8934         return ret_val;
8935 }
8936
8937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8938         LDKAnnouncementSignatures this_ptr_conv;
8939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8940         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8941         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
8942 }
8943
8944 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8945         LDKAnnouncementSignatures this_ptr_conv;
8946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8947         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8948         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8949         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
8950         return arg_arr;
8951 }
8952
8953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8954         LDKAnnouncementSignatures this_ptr_conv;
8955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8956         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8957         LDKSignature val_ref;
8958         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8959         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8960         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
8961 }
8962
8963 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8964         LDKAnnouncementSignatures this_ptr_conv;
8965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8966         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8967         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8968         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
8969         return arg_arr;
8970 }
8971
8972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8973         LDKAnnouncementSignatures 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         LDKSignature val_ref;
8977         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8978         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8979         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
8980 }
8981
8982 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) {
8983         LDKThirtyTwoBytes channel_id_arg_ref;
8984         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8985         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8986         LDKSignature node_signature_arg_ref;
8987         CHECK((*_env)->GetArrayLength (_env, node_signature_arg) == 64);
8988         (*_env)->GetByteArrayRegion (_env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
8989         LDKSignature bitcoin_signature_arg_ref;
8990         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_arg) == 64);
8991         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
8992         LDKAnnouncementSignatures ret = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
8993         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8994 }
8995
8996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8997         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
8998         FREE((void*)this_ptr);
8999         NetAddress_free(this_ptr_conv);
9000 }
9001
9002 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9003         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
9004         LDKNetAddress* ret = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9005         *ret = NetAddress_clone(orig_conv);
9006         return (long)ret;
9007 }
9008
9009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9010         LDKUnsignedNodeAnnouncement this_ptr_conv;
9011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9012         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9013         UnsignedNodeAnnouncement_free(this_ptr_conv);
9014 }
9015
9016 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9017         LDKUnsignedNodeAnnouncement orig_conv;
9018         orig_conv.inner = (void*)(orig & (~1));
9019         orig_conv.is_owned = (orig & 1) || (orig == 0);
9020         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_clone(&orig_conv);
9021         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9022 }
9023
9024 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9025         LDKUnsignedNodeAnnouncement this_ptr_conv;
9026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9027         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9028         LDKNodeFeatures ret = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
9029         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9030 }
9031
9032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9033         LDKUnsignedNodeAnnouncement this_ptr_conv;
9034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9035         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9036         LDKNodeFeatures val_conv;
9037         val_conv.inner = (void*)(val & (~1));
9038         val_conv.is_owned = (val & 1) || (val == 0);
9039         // Warning: we may need a move here but can't clone!
9040         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
9041 }
9042
9043 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
9044         LDKUnsignedNodeAnnouncement this_ptr_conv;
9045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9046         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9047         jint ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
9048         return ret_val;
9049 }
9050
9051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9052         LDKUnsignedNodeAnnouncement this_ptr_conv;
9053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9054         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9055         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
9056 }
9057
9058 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9059         LDKUnsignedNodeAnnouncement this_ptr_conv;
9060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9061         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9062         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9063         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
9064         return arg_arr;
9065 }
9066
9067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9068         LDKUnsignedNodeAnnouncement this_ptr_conv;
9069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9070         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9071         LDKPublicKey val_ref;
9072         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9073         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9074         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
9075 }
9076
9077 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
9078         LDKUnsignedNodeAnnouncement this_ptr_conv;
9079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9080         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9081         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
9082         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
9083         return ret_arr;
9084 }
9085
9086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
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         LDKThreeBytes val_ref;
9091         CHECK((*_env)->GetArrayLength (_env, val) == 3);
9092         (*_env)->GetByteArrayRegion (_env, val, 0, 3, val_ref.data);
9093         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
9094 }
9095
9096 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
9097         LDKUnsignedNodeAnnouncement this_ptr_conv;
9098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9099         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9100         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9101         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
9102         return ret_arr;
9103 }
9104
9105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9106         LDKUnsignedNodeAnnouncement this_ptr_conv;
9107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9108         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9109         LDKThirtyTwoBytes val_ref;
9110         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9111         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9112         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
9113 }
9114
9115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9116         LDKUnsignedNodeAnnouncement this_ptr_conv;
9117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9118         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9119         LDKCVec_NetAddressZ val_constr;
9120         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9121         if (val_constr.datalen > 0)
9122                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
9123         else
9124                 val_constr.data = NULL;
9125         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9126         for (size_t m = 0; m < val_constr.datalen; m++) {
9127                 long arr_conv_12 = val_vals[m];
9128                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
9129                 FREE((void*)arr_conv_12);
9130                 val_constr.data[m] = arr_conv_12_conv;
9131         }
9132         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
9133         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
9134 }
9135
9136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9137         LDKNodeAnnouncement this_ptr_conv;
9138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9139         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9140         NodeAnnouncement_free(this_ptr_conv);
9141 }
9142
9143 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9144         LDKNodeAnnouncement orig_conv;
9145         orig_conv.inner = (void*)(orig & (~1));
9146         orig_conv.is_owned = (orig & 1) || (orig == 0);
9147         LDKNodeAnnouncement ret = NodeAnnouncement_clone(&orig_conv);
9148         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9149 }
9150
9151 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
9152         LDKNodeAnnouncement this_ptr_conv;
9153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9154         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9155         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9156         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
9157         return arg_arr;
9158 }
9159
9160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9161         LDKNodeAnnouncement this_ptr_conv;
9162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9163         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9164         LDKSignature val_ref;
9165         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9166         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9167         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
9168 }
9169
9170 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9171         LDKNodeAnnouncement this_ptr_conv;
9172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9173         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9174         LDKUnsignedNodeAnnouncement ret = NodeAnnouncement_get_contents(&this_ptr_conv);
9175         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9176 }
9177
9178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9179         LDKNodeAnnouncement this_ptr_conv;
9180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9181         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9182         LDKUnsignedNodeAnnouncement val_conv;
9183         val_conv.inner = (void*)(val & (~1));
9184         val_conv.is_owned = (val & 1) || (val == 0);
9185         if (val_conv.inner != NULL)
9186                 val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
9187         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
9188 }
9189
9190 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv * _env, jclass _b, jbyteArray signature_arg, jlong contents_arg) {
9191         LDKSignature signature_arg_ref;
9192         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
9193         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
9194         LDKUnsignedNodeAnnouncement contents_arg_conv;
9195         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9196         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9197         if (contents_arg_conv.inner != NULL)
9198                 contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
9199         LDKNodeAnnouncement ret = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
9200         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9201 }
9202
9203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9204         LDKUnsignedChannelAnnouncement this_ptr_conv;
9205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9206         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9207         UnsignedChannelAnnouncement_free(this_ptr_conv);
9208 }
9209
9210 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9211         LDKUnsignedChannelAnnouncement orig_conv;
9212         orig_conv.inner = (void*)(orig & (~1));
9213         orig_conv.is_owned = (orig & 1) || (orig == 0);
9214         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_clone(&orig_conv);
9215         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9216 }
9217
9218 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9219         LDKUnsignedChannelAnnouncement this_ptr_conv;
9220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9221         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9222         LDKChannelFeatures ret = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
9223         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9224 }
9225
9226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9227         LDKUnsignedChannelAnnouncement this_ptr_conv;
9228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9229         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9230         LDKChannelFeatures val_conv;
9231         val_conv.inner = (void*)(val & (~1));
9232         val_conv.is_owned = (val & 1) || (val == 0);
9233         // Warning: we may need a move here but can't clone!
9234         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
9235 }
9236
9237 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9238         LDKUnsignedChannelAnnouncement 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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9242         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
9243         return ret_arr;
9244 }
9245
9246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9247         LDKUnsignedChannelAnnouncement this_ptr_conv;
9248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9249         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9250         LDKThirtyTwoBytes val_ref;
9251         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9252         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9253         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
9254 }
9255
9256 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9257         LDKUnsignedChannelAnnouncement this_ptr_conv;
9258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9259         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9260         jlong ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
9261         return ret_val;
9262 }
9263
9264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9265         LDKUnsignedChannelAnnouncement this_ptr_conv;
9266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9267         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9268         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
9269 }
9270
9271 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
9272         LDKUnsignedChannelAnnouncement this_ptr_conv;
9273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9274         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9275         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9276         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
9277         return arg_arr;
9278 }
9279
9280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
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         LDKPublicKey val_ref;
9285         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9286         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9287         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
9288 }
9289
9290 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
9291         LDKUnsignedChannelAnnouncement this_ptr_conv;
9292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9293         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9294         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9295         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
9296         return arg_arr;
9297 }
9298
9299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9300         LDKUnsignedChannelAnnouncement this_ptr_conv;
9301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9302         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9303         LDKPublicKey val_ref;
9304         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9305         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9306         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
9307 }
9308
9309 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
9310         LDKUnsignedChannelAnnouncement this_ptr_conv;
9311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9312         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9313         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9314         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
9315         return arg_arr;
9316 }
9317
9318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9319         LDKUnsignedChannelAnnouncement this_ptr_conv;
9320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9321         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9322         LDKPublicKey val_ref;
9323         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9324         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9325         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
9326 }
9327
9328 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
9329         LDKUnsignedChannelAnnouncement this_ptr_conv;
9330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9331         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9332         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9333         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
9334         return arg_arr;
9335 }
9336
9337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9338         LDKUnsignedChannelAnnouncement this_ptr_conv;
9339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9340         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9341         LDKPublicKey val_ref;
9342         CHECK((*_env)->GetArrayLength (_env, val) == 33);
9343         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9344         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
9345 }
9346
9347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9348         LDKChannelAnnouncement this_ptr_conv;
9349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9350         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9351         ChannelAnnouncement_free(this_ptr_conv);
9352 }
9353
9354 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9355         LDKChannelAnnouncement orig_conv;
9356         orig_conv.inner = (void*)(orig & (~1));
9357         orig_conv.is_owned = (orig & 1) || (orig == 0);
9358         LDKChannelAnnouncement ret = ChannelAnnouncement_clone(&orig_conv);
9359         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9360 }
9361
9362 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
9363         LDKChannelAnnouncement this_ptr_conv;
9364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9365         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9366         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9367         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
9368         return arg_arr;
9369 }
9370
9371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9372         LDKChannelAnnouncement this_ptr_conv;
9373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9374         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9375         LDKSignature val_ref;
9376         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9377         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9378         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
9379 }
9380
9381 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
9382         LDKChannelAnnouncement this_ptr_conv;
9383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9384         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9385         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9386         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
9387         return arg_arr;
9388 }
9389
9390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9391         LDKChannelAnnouncement this_ptr_conv;
9392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9393         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9394         LDKSignature val_ref;
9395         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9396         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9397         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
9398 }
9399
9400 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
9401         LDKChannelAnnouncement this_ptr_conv;
9402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9403         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9404         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9405         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
9406         return arg_arr;
9407 }
9408
9409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9410         LDKChannelAnnouncement this_ptr_conv;
9411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9412         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9413         LDKSignature val_ref;
9414         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9415         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9416         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
9417 }
9418
9419 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
9420         LDKChannelAnnouncement this_ptr_conv;
9421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9422         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9423         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9424         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
9425         return arg_arr;
9426 }
9427
9428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9429         LDKChannelAnnouncement this_ptr_conv;
9430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9431         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9432         LDKSignature val_ref;
9433         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9434         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9435         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
9436 }
9437
9438 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9439         LDKChannelAnnouncement this_ptr_conv;
9440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9441         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9442         LDKUnsignedChannelAnnouncement ret = ChannelAnnouncement_get_contents(&this_ptr_conv);
9443         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9444 }
9445
9446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9447         LDKChannelAnnouncement this_ptr_conv;
9448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9449         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9450         LDKUnsignedChannelAnnouncement val_conv;
9451         val_conv.inner = (void*)(val & (~1));
9452         val_conv.is_owned = (val & 1) || (val == 0);
9453         if (val_conv.inner != NULL)
9454                 val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
9455         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
9456 }
9457
9458 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) {
9459         LDKSignature node_signature_1_arg_ref;
9460         CHECK((*_env)->GetArrayLength (_env, node_signature_1_arg) == 64);
9461         (*_env)->GetByteArrayRegion (_env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
9462         LDKSignature node_signature_2_arg_ref;
9463         CHECK((*_env)->GetArrayLength (_env, node_signature_2_arg) == 64);
9464         (*_env)->GetByteArrayRegion (_env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
9465         LDKSignature bitcoin_signature_1_arg_ref;
9466         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_1_arg) == 64);
9467         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
9468         LDKSignature bitcoin_signature_2_arg_ref;
9469         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_2_arg) == 64);
9470         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
9471         LDKUnsignedChannelAnnouncement contents_arg_conv;
9472         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9473         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9474         if (contents_arg_conv.inner != NULL)
9475                 contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
9476         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);
9477         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9478 }
9479
9480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9481         LDKUnsignedChannelUpdate this_ptr_conv;
9482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9483         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9484         UnsignedChannelUpdate_free(this_ptr_conv);
9485 }
9486
9487 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9488         LDKUnsignedChannelUpdate orig_conv;
9489         orig_conv.inner = (void*)(orig & (~1));
9490         orig_conv.is_owned = (orig & 1) || (orig == 0);
9491         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_clone(&orig_conv);
9492         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9493 }
9494
9495 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9496         LDKUnsignedChannelUpdate this_ptr_conv;
9497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9498         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9499         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9500         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
9501         return ret_arr;
9502 }
9503
9504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9505         LDKUnsignedChannelUpdate this_ptr_conv;
9506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9507         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9508         LDKThirtyTwoBytes val_ref;
9509         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9510         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9511         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
9512 }
9513
9514 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9515         LDKUnsignedChannelUpdate this_ptr_conv;
9516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9517         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9518         jlong ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
9519         return ret_val;
9520 }
9521
9522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9523         LDKUnsignedChannelUpdate this_ptr_conv;
9524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9525         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9526         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
9527 }
9528
9529 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
9530         LDKUnsignedChannelUpdate this_ptr_conv;
9531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9532         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9533         jint ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
9534         return ret_val;
9535 }
9536
9537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9538         LDKUnsignedChannelUpdate this_ptr_conv;
9539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9540         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9541         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
9542 }
9543
9544 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
9545         LDKUnsignedChannelUpdate this_ptr_conv;
9546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9547         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9548         jbyte ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
9549         return ret_val;
9550 }
9551
9552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
9553         LDKUnsignedChannelUpdate this_ptr_conv;
9554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9555         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9556         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
9557 }
9558
9559 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
9560         LDKUnsignedChannelUpdate this_ptr_conv;
9561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9562         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9563         jshort ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
9564         return ret_val;
9565 }
9566
9567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
9568         LDKUnsignedChannelUpdate this_ptr_conv;
9569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9570         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9571         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
9572 }
9573
9574 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9575         LDKUnsignedChannelUpdate this_ptr_conv;
9576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9577         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9578         jlong ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
9579         return ret_val;
9580 }
9581
9582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9583         LDKUnsignedChannelUpdate this_ptr_conv;
9584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9585         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9586         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
9587 }
9588
9589 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9590         LDKUnsignedChannelUpdate this_ptr_conv;
9591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9592         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9593         jint ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
9594         return ret_val;
9595 }
9596
9597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9598         LDKUnsignedChannelUpdate this_ptr_conv;
9599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9600         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9601         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
9602 }
9603
9604 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
9605         LDKUnsignedChannelUpdate this_ptr_conv;
9606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9607         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9608         jint ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
9609         return ret_val;
9610 }
9611
9612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9613         LDKUnsignedChannelUpdate this_ptr_conv;
9614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9615         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9616         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
9617 }
9618
9619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9620         LDKChannelUpdate this_ptr_conv;
9621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9622         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9623         ChannelUpdate_free(this_ptr_conv);
9624 }
9625
9626 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9627         LDKChannelUpdate orig_conv;
9628         orig_conv.inner = (void*)(orig & (~1));
9629         orig_conv.is_owned = (orig & 1) || (orig == 0);
9630         LDKChannelUpdate ret = ChannelUpdate_clone(&orig_conv);
9631         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9632 }
9633
9634 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
9635         LDKChannelUpdate this_ptr_conv;
9636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9637         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9638         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
9639         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
9640         return arg_arr;
9641 }
9642
9643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9644         LDKChannelUpdate this_ptr_conv;
9645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9646         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9647         LDKSignature val_ref;
9648         CHECK((*_env)->GetArrayLength (_env, val) == 64);
9649         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
9650         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
9651 }
9652
9653 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
9654         LDKChannelUpdate this_ptr_conv;
9655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9656         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9657         LDKUnsignedChannelUpdate ret = ChannelUpdate_get_contents(&this_ptr_conv);
9658         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9659 }
9660
9661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9662         LDKChannelUpdate this_ptr_conv;
9663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9664         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9665         LDKUnsignedChannelUpdate val_conv;
9666         val_conv.inner = (void*)(val & (~1));
9667         val_conv.is_owned = (val & 1) || (val == 0);
9668         if (val_conv.inner != NULL)
9669                 val_conv = UnsignedChannelUpdate_clone(&val_conv);
9670         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
9671 }
9672
9673 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv * _env, jclass _b, jbyteArray signature_arg, jlong contents_arg) {
9674         LDKSignature signature_arg_ref;
9675         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
9676         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
9677         LDKUnsignedChannelUpdate contents_arg_conv;
9678         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9679         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9680         if (contents_arg_conv.inner != NULL)
9681                 contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
9682         LDKChannelUpdate ret = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
9683         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9684 }
9685
9686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9687         LDKQueryChannelRange this_ptr_conv;
9688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9689         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9690         QueryChannelRange_free(this_ptr_conv);
9691 }
9692
9693 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9694         LDKQueryChannelRange orig_conv;
9695         orig_conv.inner = (void*)(orig & (~1));
9696         orig_conv.is_owned = (orig & 1) || (orig == 0);
9697         LDKQueryChannelRange ret = QueryChannelRange_clone(&orig_conv);
9698         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9699 }
9700
9701 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9702         LDKQueryChannelRange this_ptr_conv;
9703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9704         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9705         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9706         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
9707         return ret_arr;
9708 }
9709
9710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9711         LDKQueryChannelRange this_ptr_conv;
9712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9713         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9714         LDKThirtyTwoBytes val_ref;
9715         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9716         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9717         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
9718 }
9719
9720 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
9721         LDKQueryChannelRange 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         jint ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
9725         return ret_val;
9726 }
9727
9728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9729         LDKQueryChannelRange this_ptr_conv;
9730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9731         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9732         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
9733 }
9734
9735 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
9736         LDKQueryChannelRange this_ptr_conv;
9737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9738         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9739         jint ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
9740         return ret_val;
9741 }
9742
9743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9744         LDKQueryChannelRange this_ptr_conv;
9745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9746         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9747         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
9748 }
9749
9750 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) {
9751         LDKThirtyTwoBytes chain_hash_arg_ref;
9752         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9753         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9754         LDKQueryChannelRange ret = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
9755         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9756 }
9757
9758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9759         LDKReplyChannelRange this_ptr_conv;
9760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9761         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9762         ReplyChannelRange_free(this_ptr_conv);
9763 }
9764
9765 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9766         LDKReplyChannelRange orig_conv;
9767         orig_conv.inner = (void*)(orig & (~1));
9768         orig_conv.is_owned = (orig & 1) || (orig == 0);
9769         LDKReplyChannelRange ret = ReplyChannelRange_clone(&orig_conv);
9770         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9771 }
9772
9773 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9774         LDKReplyChannelRange this_ptr_conv;
9775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9776         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9777         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9778         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
9779         return ret_arr;
9780 }
9781
9782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9783         LDKReplyChannelRange this_ptr_conv;
9784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9785         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9786         LDKThirtyTwoBytes val_ref;
9787         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9788         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9789         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
9790 }
9791
9792 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
9793         LDKReplyChannelRange this_ptr_conv;
9794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9795         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9796         jint ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
9797         return ret_val;
9798 }
9799
9800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9801         LDKReplyChannelRange this_ptr_conv;
9802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9803         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9804         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
9805 }
9806
9807 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
9808         LDKReplyChannelRange this_ptr_conv;
9809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9810         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9811         jint ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
9812         return ret_val;
9813 }
9814
9815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9816         LDKReplyChannelRange this_ptr_conv;
9817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9818         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9819         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
9820 }
9821
9822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
9823         LDKReplyChannelRange this_ptr_conv;
9824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9825         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9826         jboolean ret_val = ReplyChannelRange_get_full_information(&this_ptr_conv);
9827         return ret_val;
9828 }
9829
9830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9831         LDKReplyChannelRange this_ptr_conv;
9832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9833         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9834         ReplyChannelRange_set_full_information(&this_ptr_conv, val);
9835 }
9836
9837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9838         LDKReplyChannelRange this_ptr_conv;
9839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9840         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9841         LDKCVec_u64Z val_constr;
9842         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9843         if (val_constr.datalen > 0)
9844                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9845         else
9846                 val_constr.data = NULL;
9847         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9848         for (size_t g = 0; g < val_constr.datalen; g++) {
9849                 long arr_conv_6 = val_vals[g];
9850                 val_constr.data[g] = arr_conv_6;
9851         }
9852         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
9853         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
9854 }
9855
9856 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) {
9857         LDKThirtyTwoBytes chain_hash_arg_ref;
9858         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9859         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9860         LDKCVec_u64Z short_channel_ids_arg_constr;
9861         short_channel_ids_arg_constr.datalen = (*_env)->GetArrayLength (_env, short_channel_ids_arg);
9862         if (short_channel_ids_arg_constr.datalen > 0)
9863                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9864         else
9865                 short_channel_ids_arg_constr.data = NULL;
9866         long* short_channel_ids_arg_vals = (*_env)->GetLongArrayElements (_env, short_channel_ids_arg, NULL);
9867         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
9868                 long arr_conv_6 = short_channel_ids_arg_vals[g];
9869                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
9870         }
9871         (*_env)->ReleaseLongArrayElements (_env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
9872         LDKReplyChannelRange ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr);
9873         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9874 }
9875
9876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9877         LDKQueryShortChannelIds this_ptr_conv;
9878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9879         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9880         QueryShortChannelIds_free(this_ptr_conv);
9881 }
9882
9883 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9884         LDKQueryShortChannelIds orig_conv;
9885         orig_conv.inner = (void*)(orig & (~1));
9886         orig_conv.is_owned = (orig & 1) || (orig == 0);
9887         LDKQueryShortChannelIds ret = QueryShortChannelIds_clone(&orig_conv);
9888         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9889 }
9890
9891 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9892         LDKQueryShortChannelIds this_ptr_conv;
9893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9894         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9895         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9896         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
9897         return ret_arr;
9898 }
9899
9900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9901         LDKQueryShortChannelIds this_ptr_conv;
9902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9903         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9904         LDKThirtyTwoBytes val_ref;
9905         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9906         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9907         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
9908 }
9909
9910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
9911         LDKQueryShortChannelIds this_ptr_conv;
9912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9913         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9914         LDKCVec_u64Z val_constr;
9915         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
9916         if (val_constr.datalen > 0)
9917                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9918         else
9919                 val_constr.data = NULL;
9920         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
9921         for (size_t g = 0; g < val_constr.datalen; g++) {
9922                 long arr_conv_6 = val_vals[g];
9923                 val_constr.data[g] = arr_conv_6;
9924         }
9925         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
9926         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
9927 }
9928
9929 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlongArray short_channel_ids_arg) {
9930         LDKThirtyTwoBytes chain_hash_arg_ref;
9931         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9932         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9933         LDKCVec_u64Z short_channel_ids_arg_constr;
9934         short_channel_ids_arg_constr.datalen = (*_env)->GetArrayLength (_env, short_channel_ids_arg);
9935         if (short_channel_ids_arg_constr.datalen > 0)
9936                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
9937         else
9938                 short_channel_ids_arg_constr.data = NULL;
9939         long* short_channel_ids_arg_vals = (*_env)->GetLongArrayElements (_env, short_channel_ids_arg, NULL);
9940         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
9941                 long arr_conv_6 = short_channel_ids_arg_vals[g];
9942                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
9943         }
9944         (*_env)->ReleaseLongArrayElements (_env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
9945         LDKQueryShortChannelIds ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
9946         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9947 }
9948
9949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9950         LDKReplyShortChannelIdsEnd this_ptr_conv;
9951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9952         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9953         ReplyShortChannelIdsEnd_free(this_ptr_conv);
9954 }
9955
9956 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9957         LDKReplyShortChannelIdsEnd orig_conv;
9958         orig_conv.inner = (void*)(orig & (~1));
9959         orig_conv.is_owned = (orig & 1) || (orig == 0);
9960         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_clone(&orig_conv);
9961         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9962 }
9963
9964 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9965         LDKReplyShortChannelIdsEnd this_ptr_conv;
9966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9967         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9968         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9969         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
9970         return ret_arr;
9971 }
9972
9973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9974         LDKReplyShortChannelIdsEnd this_ptr_conv;
9975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9976         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9977         LDKThirtyTwoBytes val_ref;
9978         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9979         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9980         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
9981 }
9982
9983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
9984         LDKReplyShortChannelIdsEnd this_ptr_conv;
9985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9986         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9987         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
9988         return ret_val;
9989 }
9990
9991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9992         LDKReplyShortChannelIdsEnd this_ptr_conv;
9993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9994         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9995         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
9996 }
9997
9998 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jboolean full_information_arg) {
9999         LDKThirtyTwoBytes chain_hash_arg_ref;
10000         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
10001         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
10002         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
10003         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10004 }
10005
10006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10007         LDKGossipTimestampFilter this_ptr_conv;
10008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10009         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10010         GossipTimestampFilter_free(this_ptr_conv);
10011 }
10012
10013 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10014         LDKGossipTimestampFilter orig_conv;
10015         orig_conv.inner = (void*)(orig & (~1));
10016         orig_conv.is_owned = (orig & 1) || (orig == 0);
10017         LDKGossipTimestampFilter ret = GossipTimestampFilter_clone(&orig_conv);
10018         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10019 }
10020
10021 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
10022         LDKGossipTimestampFilter this_ptr_conv;
10023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10024         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10025         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
10026         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
10027         return ret_arr;
10028 }
10029
10030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10031         LDKGossipTimestampFilter this_ptr_conv;
10032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10033         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10034         LDKThirtyTwoBytes val_ref;
10035         CHECK((*_env)->GetArrayLength (_env, val) == 32);
10036         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
10037         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
10038 }
10039
10040 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
10041         LDKGossipTimestampFilter this_ptr_conv;
10042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10043         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10044         jint ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
10045         return ret_val;
10046 }
10047
10048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10049         LDKGossipTimestampFilter this_ptr_conv;
10050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10051         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10052         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
10053 }
10054
10055 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr) {
10056         LDKGossipTimestampFilter this_ptr_conv;
10057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10058         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10059         jint ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
10060         return ret_val;
10061 }
10062
10063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10064         LDKGossipTimestampFilter this_ptr_conv;
10065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10066         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10067         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
10068 }
10069
10070 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) {
10071         LDKThirtyTwoBytes chain_hash_arg_ref;
10072         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
10073         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
10074         LDKGossipTimestampFilter ret = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
10075         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10076 }
10077
10078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10079         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
10080         FREE((void*)this_ptr);
10081         ErrorAction_free(this_ptr_conv);
10082 }
10083
10084 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10085         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
10086         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10087         *ret = ErrorAction_clone(orig_conv);
10088         return (long)ret;
10089 }
10090
10091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10092         LDKLightningError this_ptr_conv;
10093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10094         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10095         LightningError_free(this_ptr_conv);
10096 }
10097
10098 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) {
10099         LDKLightningError 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         LDKStr _str = LightningError_get_err(&this_ptr_conv);
10103         char* _buf = MALLOC(_str.len + 1, "str conv buf");
10104         memcpy(_buf, _str.chars, _str.len);
10105         _buf[_str.len] = 0;
10106         jstring _conv = (*_env)->NewStringUTF(_env, _str.chars);
10107         FREE(_buf);
10108         return _conv;
10109 }
10110
10111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10112         LDKLightningError this_ptr_conv;
10113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10114         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10115         LDKCVec_u8Z val_ref;
10116         val_ref.data = (*_env)->GetByteArrayElements (_env, val, NULL);
10117         val_ref.datalen = (*_env)->GetArrayLength (_env, val);
10118         LightningError_set_err(&this_ptr_conv, val_ref);
10119         (*_env)->ReleaseByteArrayElements(_env, val, (int8_t*)val_ref.data, 0);
10120 }
10121
10122 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv * _env, jclass _b, jlong this_ptr) {
10123         LDKLightningError this_ptr_conv;
10124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10125         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10126         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10127         *ret = LightningError_get_action(&this_ptr_conv);
10128         return (long)ret;
10129 }
10130
10131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10132         LDKLightningError this_ptr_conv;
10133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10134         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10135         LDKErrorAction val_conv = *(LDKErrorAction*)val;
10136         FREE((void*)val);
10137         LightningError_set_action(&this_ptr_conv, val_conv);
10138 }
10139
10140 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv * _env, jclass _b, jbyteArray err_arg, jlong action_arg) {
10141         LDKCVec_u8Z err_arg_ref;
10142         err_arg_ref.data = (*_env)->GetByteArrayElements (_env, err_arg, NULL);
10143         err_arg_ref.datalen = (*_env)->GetArrayLength (_env, err_arg);
10144         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
10145         FREE((void*)action_arg);
10146         LDKLightningError ret = LightningError_new(err_arg_ref, action_arg_conv);
10147         (*_env)->ReleaseByteArrayElements(_env, err_arg, (int8_t*)err_arg_ref.data, 0);
10148         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10149 }
10150
10151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10152         LDKCommitmentUpdate this_ptr_conv;
10153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10154         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10155         CommitmentUpdate_free(this_ptr_conv);
10156 }
10157
10158 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10159         LDKCommitmentUpdate orig_conv;
10160         orig_conv.inner = (void*)(orig & (~1));
10161         orig_conv.is_owned = (orig & 1) || (orig == 0);
10162         LDKCommitmentUpdate ret = CommitmentUpdate_clone(&orig_conv);
10163         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10164 }
10165
10166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10167         LDKCommitmentUpdate this_ptr_conv;
10168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10169         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10170         LDKCVec_UpdateAddHTLCZ val_constr;
10171         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10172         if (val_constr.datalen > 0)
10173                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10174         else
10175                 val_constr.data = NULL;
10176         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10177         for (size_t p = 0; p < val_constr.datalen; p++) {
10178                 long arr_conv_15 = val_vals[p];
10179                 LDKUpdateAddHTLC arr_conv_15_conv;
10180                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10181                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10182                 if (arr_conv_15_conv.inner != NULL)
10183                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10184                 val_constr.data[p] = arr_conv_15_conv;
10185         }
10186         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10187         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
10188 }
10189
10190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10191         LDKCommitmentUpdate this_ptr_conv;
10192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10193         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10194         LDKCVec_UpdateFulfillHTLCZ val_constr;
10195         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10196         if (val_constr.datalen > 0)
10197                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10198         else
10199                 val_constr.data = NULL;
10200         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10201         for (size_t t = 0; t < val_constr.datalen; t++) {
10202                 long arr_conv_19 = val_vals[t];
10203                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10204                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
10205                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
10206                 if (arr_conv_19_conv.inner != NULL)
10207                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
10208                 val_constr.data[t] = arr_conv_19_conv;
10209         }
10210         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10211         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
10212 }
10213
10214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10215         LDKCommitmentUpdate this_ptr_conv;
10216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10217         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10218         LDKCVec_UpdateFailHTLCZ val_constr;
10219         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10220         if (val_constr.datalen > 0)
10221                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10222         else
10223                 val_constr.data = NULL;
10224         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10225         for (size_t q = 0; q < val_constr.datalen; q++) {
10226                 long arr_conv_16 = val_vals[q];
10227                 LDKUpdateFailHTLC arr_conv_16_conv;
10228                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
10229                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
10230                 if (arr_conv_16_conv.inner != NULL)
10231                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
10232                 val_constr.data[q] = arr_conv_16_conv;
10233         }
10234         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10235         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
10236 }
10237
10238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
10239         LDKCommitmentUpdate this_ptr_conv;
10240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10241         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10242         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
10243         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
10244         if (val_constr.datalen > 0)
10245                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10246         else
10247                 val_constr.data = NULL;
10248         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
10249         for (size_t z = 0; z < val_constr.datalen; z++) {
10250                 long arr_conv_25 = val_vals[z];
10251                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
10252                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
10253                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
10254                 if (arr_conv_25_conv.inner != NULL)
10255                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
10256                 val_constr.data[z] = arr_conv_25_conv;
10257         }
10258         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
10259         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
10260 }
10261
10262 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr) {
10263         LDKCommitmentUpdate this_ptr_conv;
10264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10265         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10266         LDKUpdateFee ret = CommitmentUpdate_get_update_fee(&this_ptr_conv);
10267         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10268 }
10269
10270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10271         LDKCommitmentUpdate this_ptr_conv;
10272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10273         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10274         LDKUpdateFee val_conv;
10275         val_conv.inner = (void*)(val & (~1));
10276         val_conv.is_owned = (val & 1) || (val == 0);
10277         if (val_conv.inner != NULL)
10278                 val_conv = UpdateFee_clone(&val_conv);
10279         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
10280 }
10281
10282 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr) {
10283         LDKCommitmentUpdate this_ptr_conv;
10284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10285         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10286         LDKCommitmentSigned ret = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
10287         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10288 }
10289
10290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10291         LDKCommitmentUpdate this_ptr_conv;
10292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10293         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10294         LDKCommitmentSigned val_conv;
10295         val_conv.inner = (void*)(val & (~1));
10296         val_conv.is_owned = (val & 1) || (val == 0);
10297         if (val_conv.inner != NULL)
10298                 val_conv = CommitmentSigned_clone(&val_conv);
10299         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
10300 }
10301
10302 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) {
10303         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
10304         update_add_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_add_htlcs_arg);
10305         if (update_add_htlcs_arg_constr.datalen > 0)
10306                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10307         else
10308                 update_add_htlcs_arg_constr.data = NULL;
10309         long* update_add_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_add_htlcs_arg, NULL);
10310         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
10311                 long arr_conv_15 = update_add_htlcs_arg_vals[p];
10312                 LDKUpdateAddHTLC arr_conv_15_conv;
10313                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10314                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10315                 if (arr_conv_15_conv.inner != NULL)
10316                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10317                 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
10318         }
10319         (*_env)->ReleaseLongArrayElements (_env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
10320         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
10321         update_fulfill_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fulfill_htlcs_arg);
10322         if (update_fulfill_htlcs_arg_constr.datalen > 0)
10323                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10324         else
10325                 update_fulfill_htlcs_arg_constr.data = NULL;
10326         long* update_fulfill_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fulfill_htlcs_arg, NULL);
10327         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
10328                 long arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
10329                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10330                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
10331                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
10332                 if (arr_conv_19_conv.inner != NULL)
10333                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
10334                 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
10335         }
10336         (*_env)->ReleaseLongArrayElements (_env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
10337         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
10338         update_fail_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fail_htlcs_arg);
10339         if (update_fail_htlcs_arg_constr.datalen > 0)
10340                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10341         else
10342                 update_fail_htlcs_arg_constr.data = NULL;
10343         long* update_fail_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fail_htlcs_arg, NULL);
10344         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
10345                 long arr_conv_16 = update_fail_htlcs_arg_vals[q];
10346                 LDKUpdateFailHTLC arr_conv_16_conv;
10347                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
10348                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
10349                 if (arr_conv_16_conv.inner != NULL)
10350                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
10351                 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
10352         }
10353         (*_env)->ReleaseLongArrayElements (_env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
10354         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
10355         update_fail_malformed_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fail_malformed_htlcs_arg);
10356         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
10357                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10358         else
10359                 update_fail_malformed_htlcs_arg_constr.data = NULL;
10360         long* update_fail_malformed_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fail_malformed_htlcs_arg, NULL);
10361         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
10362                 long arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
10363                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
10364                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
10365                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
10366                 if (arr_conv_25_conv.inner != NULL)
10367                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
10368                 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
10369         }
10370         (*_env)->ReleaseLongArrayElements (_env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
10371         LDKUpdateFee update_fee_arg_conv;
10372         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
10373         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
10374         if (update_fee_arg_conv.inner != NULL)
10375                 update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
10376         LDKCommitmentSigned commitment_signed_arg_conv;
10377         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
10378         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
10379         if (commitment_signed_arg_conv.inner != NULL)
10380                 commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
10381         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);
10382         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10383 }
10384
10385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10386         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
10387         FREE((void*)this_ptr);
10388         HTLCFailChannelUpdate_free(this_ptr_conv);
10389 }
10390
10391 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10392         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
10393         LDKHTLCFailChannelUpdate* ret = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
10394         *ret = HTLCFailChannelUpdate_clone(orig_conv);
10395         return (long)ret;
10396 }
10397
10398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10399         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
10400         FREE((void*)this_ptr);
10401         ChannelMessageHandler_free(this_ptr_conv);
10402 }
10403
10404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10405         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
10406         FREE((void*)this_ptr);
10407         RoutingMessageHandler_free(this_ptr_conv);
10408 }
10409
10410 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
10411         LDKAcceptChannel obj_conv;
10412         obj_conv.inner = (void*)(obj & (~1));
10413         obj_conv.is_owned = (obj & 1) || (obj == 0);
10414         LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
10415         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10416         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10417         CVec_u8Z_free(arg_var);
10418         return arg_arr;
10419 }
10420
10421 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10422         LDKu8slice ser_ref;
10423         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10424         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10425         LDKAcceptChannel ret = AcceptChannel_read(ser_ref);
10426         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10427         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10428 }
10429
10430 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv * _env, jclass _b, jlong obj) {
10431         LDKAnnouncementSignatures obj_conv;
10432         obj_conv.inner = (void*)(obj & (~1));
10433         obj_conv.is_owned = (obj & 1) || (obj == 0);
10434         LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
10435         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10436         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10437         CVec_u8Z_free(arg_var);
10438         return arg_arr;
10439 }
10440
10441 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10442         LDKu8slice ser_ref;
10443         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10444         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10445         LDKAnnouncementSignatures ret = AnnouncementSignatures_read(ser_ref);
10446         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10447         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10448 }
10449
10450 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv * _env, jclass _b, jlong obj) {
10451         LDKChannelReestablish obj_conv;
10452         obj_conv.inner = (void*)(obj & (~1));
10453         obj_conv.is_owned = (obj & 1) || (obj == 0);
10454         LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
10455         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10456         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10457         CVec_u8Z_free(arg_var);
10458         return arg_arr;
10459 }
10460
10461 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10462         LDKu8slice ser_ref;
10463         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10464         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10465         LDKChannelReestablish ret = ChannelReestablish_read(ser_ref);
10466         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10467         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10468 }
10469
10470 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10471         LDKClosingSigned obj_conv;
10472         obj_conv.inner = (void*)(obj & (~1));
10473         obj_conv.is_owned = (obj & 1) || (obj == 0);
10474         LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
10475         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10476         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10477         CVec_u8Z_free(arg_var);
10478         return arg_arr;
10479 }
10480
10481 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10482         LDKu8slice ser_ref;
10483         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10484         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10485         LDKClosingSigned ret = ClosingSigned_read(ser_ref);
10486         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10487         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10488 }
10489
10490 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10491         LDKCommitmentSigned obj_conv;
10492         obj_conv.inner = (void*)(obj & (~1));
10493         obj_conv.is_owned = (obj & 1) || (obj == 0);
10494         LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
10495         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10496         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10497         CVec_u8Z_free(arg_var);
10498         return arg_arr;
10499 }
10500
10501 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10502         LDKu8slice ser_ref;
10503         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10504         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10505         LDKCommitmentSigned ret = CommitmentSigned_read(ser_ref);
10506         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10507         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10508 }
10509
10510 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv * _env, jclass _b, jlong obj) {
10511         LDKFundingCreated obj_conv;
10512         obj_conv.inner = (void*)(obj & (~1));
10513         obj_conv.is_owned = (obj & 1) || (obj == 0);
10514         LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
10515         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10516         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10517         CVec_u8Z_free(arg_var);
10518         return arg_arr;
10519 }
10520
10521 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_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         LDKFundingCreated ret = FundingCreated_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_FundingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
10531         LDKFundingSigned obj_conv;
10532         obj_conv.inner = (void*)(obj & (~1));
10533         obj_conv.is_owned = (obj & 1) || (obj == 0);
10534         LDKCVec_u8Z arg_var = FundingSigned_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         CVec_u8Z_free(arg_var);
10538         return arg_arr;
10539 }
10540
10541 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10542         LDKu8slice ser_ref;
10543         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10544         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10545         LDKFundingSigned ret = FundingSigned_read(ser_ref);
10546         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10547         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10548 }
10549
10550 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv * _env, jclass _b, jlong obj) {
10551         LDKFundingLocked obj_conv;
10552         obj_conv.inner = (void*)(obj & (~1));
10553         obj_conv.is_owned = (obj & 1) || (obj == 0);
10554         LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
10555         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10556         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10557         CVec_u8Z_free(arg_var);
10558         return arg_arr;
10559 }
10560
10561 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10562         LDKu8slice ser_ref;
10563         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10564         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10565         LDKFundingLocked ret = FundingLocked_read(ser_ref);
10566         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10567         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10568 }
10569
10570 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv * _env, jclass _b, jlong obj) {
10571         LDKInit obj_conv;
10572         obj_conv.inner = (void*)(obj & (~1));
10573         obj_conv.is_owned = (obj & 1) || (obj == 0);
10574         LDKCVec_u8Z arg_var = Init_write(&obj_conv);
10575         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10576         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10577         CVec_u8Z_free(arg_var);
10578         return arg_arr;
10579 }
10580
10581 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10582         LDKu8slice ser_ref;
10583         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10584         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10585         LDKInit ret = Init_read(ser_ref);
10586         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10587         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10588 }
10589
10590 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
10591         LDKOpenChannel obj_conv;
10592         obj_conv.inner = (void*)(obj & (~1));
10593         obj_conv.is_owned = (obj & 1) || (obj == 0);
10594         LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
10595         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10596         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10597         CVec_u8Z_free(arg_var);
10598         return arg_arr;
10599 }
10600
10601 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10602         LDKu8slice ser_ref;
10603         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10604         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10605         LDKOpenChannel ret = OpenChannel_read(ser_ref);
10606         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10607         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10608 }
10609
10610 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv * _env, jclass _b, jlong obj) {
10611         LDKRevokeAndACK obj_conv;
10612         obj_conv.inner = (void*)(obj & (~1));
10613         obj_conv.is_owned = (obj & 1) || (obj == 0);
10614         LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
10615         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10616         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10617         CVec_u8Z_free(arg_var);
10618         return arg_arr;
10619 }
10620
10621 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10622         LDKu8slice ser_ref;
10623         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10624         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10625         LDKRevokeAndACK ret = RevokeAndACK_read(ser_ref);
10626         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10627         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10628 }
10629
10630 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv * _env, jclass _b, jlong obj) {
10631         LDKShutdown obj_conv;
10632         obj_conv.inner = (void*)(obj & (~1));
10633         obj_conv.is_owned = (obj & 1) || (obj == 0);
10634         LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
10635         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10636         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10637         CVec_u8Z_free(arg_var);
10638         return arg_arr;
10639 }
10640
10641 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10642         LDKu8slice ser_ref;
10643         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10644         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10645         LDKShutdown ret = Shutdown_read(ser_ref);
10646         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10647         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10648 }
10649
10650 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10651         LDKUpdateFailHTLC obj_conv;
10652         obj_conv.inner = (void*)(obj & (~1));
10653         obj_conv.is_owned = (obj & 1) || (obj == 0);
10654         LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
10655         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10656         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10657         CVec_u8Z_free(arg_var);
10658         return arg_arr;
10659 }
10660
10661 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10662         LDKu8slice ser_ref;
10663         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10664         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10665         LDKUpdateFailHTLC ret = UpdateFailHTLC_read(ser_ref);
10666         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10667         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10668 }
10669
10670 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10671         LDKUpdateFailMalformedHTLC obj_conv;
10672         obj_conv.inner = (void*)(obj & (~1));
10673         obj_conv.is_owned = (obj & 1) || (obj == 0);
10674         LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
10675         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10676         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10677         CVec_u8Z_free(arg_var);
10678         return arg_arr;
10679 }
10680
10681 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10682         LDKu8slice ser_ref;
10683         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10684         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10685         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_read(ser_ref);
10686         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10687         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10688 }
10689
10690 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv * _env, jclass _b, jlong obj) {
10691         LDKUpdateFee obj_conv;
10692         obj_conv.inner = (void*)(obj & (~1));
10693         obj_conv.is_owned = (obj & 1) || (obj == 0);
10694         LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
10695         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10696         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10697         CVec_u8Z_free(arg_var);
10698         return arg_arr;
10699 }
10700
10701 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10702         LDKu8slice ser_ref;
10703         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10704         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10705         LDKUpdateFee ret = UpdateFee_read(ser_ref);
10706         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10707         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10708 }
10709
10710 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10711         LDKUpdateFulfillHTLC obj_conv;
10712         obj_conv.inner = (void*)(obj & (~1));
10713         obj_conv.is_owned = (obj & 1) || (obj == 0);
10714         LDKCVec_u8Z arg_var = UpdateFulfillHTLC_write(&obj_conv);
10715         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10716         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10717         CVec_u8Z_free(arg_var);
10718         return arg_arr;
10719 }
10720
10721 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10722         LDKu8slice ser_ref;
10723         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10724         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10725         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_read(ser_ref);
10726         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10727         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10728 }
10729
10730 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
10731         LDKUpdateAddHTLC obj_conv;
10732         obj_conv.inner = (void*)(obj & (~1));
10733         obj_conv.is_owned = (obj & 1) || (obj == 0);
10734         LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
10735         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10736         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10737         CVec_u8Z_free(arg_var);
10738         return arg_arr;
10739 }
10740
10741 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10742         LDKu8slice ser_ref;
10743         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10744         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10745         LDKUpdateAddHTLC ret = UpdateAddHTLC_read(ser_ref);
10746         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10747         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10748 }
10749
10750 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv * _env, jclass _b, jlong obj) {
10751         LDKPing obj_conv;
10752         obj_conv.inner = (void*)(obj & (~1));
10753         obj_conv.is_owned = (obj & 1) || (obj == 0);
10754         LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
10755         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10756         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10757         CVec_u8Z_free(arg_var);
10758         return arg_arr;
10759 }
10760
10761 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10762         LDKu8slice ser_ref;
10763         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10764         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10765         LDKPing ret = Ping_read(ser_ref);
10766         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10767         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10768 }
10769
10770 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv * _env, jclass _b, jlong obj) {
10771         LDKPong obj_conv;
10772         obj_conv.inner = (void*)(obj & (~1));
10773         obj_conv.is_owned = (obj & 1) || (obj == 0);
10774         LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
10775         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10776         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10777         CVec_u8Z_free(arg_var);
10778         return arg_arr;
10779 }
10780
10781 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10782         LDKu8slice ser_ref;
10783         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10784         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10785         LDKPong ret = Pong_read(ser_ref);
10786         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10787         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10788 }
10789
10790 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10791         LDKUnsignedChannelAnnouncement obj_conv;
10792         obj_conv.inner = (void*)(obj & (~1));
10793         obj_conv.is_owned = (obj & 1) || (obj == 0);
10794         LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_write(&obj_conv);
10795         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10796         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10797         CVec_u8Z_free(arg_var);
10798         return arg_arr;
10799 }
10800
10801 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10802         LDKu8slice ser_ref;
10803         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10804         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10805         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_read(ser_ref);
10806         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10807         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10808 }
10809
10810 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10811         LDKChannelAnnouncement obj_conv;
10812         obj_conv.inner = (void*)(obj & (~1));
10813         obj_conv.is_owned = (obj & 1) || (obj == 0);
10814         LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
10815         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10816         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10817         CVec_u8Z_free(arg_var);
10818         return arg_arr;
10819 }
10820
10821 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10822         LDKu8slice ser_ref;
10823         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10824         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10825         LDKChannelAnnouncement ret = ChannelAnnouncement_read(ser_ref);
10826         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10827         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10828 }
10829
10830 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
10831         LDKUnsignedChannelUpdate obj_conv;
10832         obj_conv.inner = (void*)(obj & (~1));
10833         obj_conv.is_owned = (obj & 1) || (obj == 0);
10834         LDKCVec_u8Z arg_var = UnsignedChannelUpdate_write(&obj_conv);
10835         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10836         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10837         CVec_u8Z_free(arg_var);
10838         return arg_arr;
10839 }
10840
10841 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10842         LDKu8slice ser_ref;
10843         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10844         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10845         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_read(ser_ref);
10846         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10847         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10848 }
10849
10850 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
10851         LDKChannelUpdate obj_conv;
10852         obj_conv.inner = (void*)(obj & (~1));
10853         obj_conv.is_owned = (obj & 1) || (obj == 0);
10854         LDKCVec_u8Z arg_var = ChannelUpdate_write(&obj_conv);
10855         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10856         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10857         CVec_u8Z_free(arg_var);
10858         return arg_arr;
10859 }
10860
10861 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10862         LDKu8slice ser_ref;
10863         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10864         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10865         LDKChannelUpdate ret = ChannelUpdate_read(ser_ref);
10866         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10867         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10868 }
10869
10870 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv * _env, jclass _b, jlong obj) {
10871         LDKErrorMessage obj_conv;
10872         obj_conv.inner = (void*)(obj & (~1));
10873         obj_conv.is_owned = (obj & 1) || (obj == 0);
10874         LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
10875         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10876         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10877         CVec_u8Z_free(arg_var);
10878         return arg_arr;
10879 }
10880
10881 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10882         LDKu8slice ser_ref;
10883         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10884         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10885         LDKErrorMessage ret = ErrorMessage_read(ser_ref);
10886         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10887         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10888 }
10889
10890 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10891         LDKUnsignedNodeAnnouncement obj_conv;
10892         obj_conv.inner = (void*)(obj & (~1));
10893         obj_conv.is_owned = (obj & 1) || (obj == 0);
10894         LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_write(&obj_conv);
10895         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10896         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10897         CVec_u8Z_free(arg_var);
10898         return arg_arr;
10899 }
10900
10901 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_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         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_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_NodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
10911         LDKNodeAnnouncement obj_conv;
10912         obj_conv.inner = (void*)(obj & (~1));
10913         obj_conv.is_owned = (obj & 1) || (obj == 0);
10914         LDKCVec_u8Z arg_var = NodeAnnouncement_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         CVec_u8Z_free(arg_var);
10918         return arg_arr;
10919 }
10920
10921 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10922         LDKu8slice ser_ref;
10923         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10924         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10925         LDKNodeAnnouncement ret = NodeAnnouncement_read(ser_ref);
10926         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10927         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10928 }
10929
10930 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10931         LDKu8slice ser_ref;
10932         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10933         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10934         LDKQueryShortChannelIds ret = QueryShortChannelIds_read(ser_ref);
10935         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10936         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10937 }
10938
10939 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv * _env, jclass _b, jlong obj) {
10940         LDKQueryShortChannelIds obj_conv;
10941         obj_conv.inner = (void*)(obj & (~1));
10942         obj_conv.is_owned = (obj & 1) || (obj == 0);
10943         LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
10944         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10945         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10946         CVec_u8Z_free(arg_var);
10947         return arg_arr;
10948 }
10949
10950 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10951         LDKu8slice ser_ref;
10952         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10953         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10954         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_read(ser_ref);
10955         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10956         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10957 }
10958
10959 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv * _env, jclass _b, jlong obj) {
10960         LDKReplyShortChannelIdsEnd obj_conv;
10961         obj_conv.inner = (void*)(obj & (~1));
10962         obj_conv.is_owned = (obj & 1) || (obj == 0);
10963         LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
10964         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10965         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10966         CVec_u8Z_free(arg_var);
10967         return arg_arr;
10968 }
10969
10970 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10971         LDKu8slice ser_ref;
10972         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10973         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10974         LDKQueryChannelRange ret = QueryChannelRange_read(ser_ref);
10975         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10976         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10977 }
10978
10979 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
10980         LDKQueryChannelRange obj_conv;
10981         obj_conv.inner = (void*)(obj & (~1));
10982         obj_conv.is_owned = (obj & 1) || (obj == 0);
10983         LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
10984         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
10985         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
10986         CVec_u8Z_free(arg_var);
10987         return arg_arr;
10988 }
10989
10990 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
10991         LDKu8slice ser_ref;
10992         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
10993         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
10994         LDKReplyChannelRange ret = ReplyChannelRange_read(ser_ref);
10995         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
10996         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10997 }
10998
10999 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
11000         LDKReplyChannelRange obj_conv;
11001         obj_conv.inner = (void*)(obj & (~1));
11002         obj_conv.is_owned = (obj & 1) || (obj == 0);
11003         LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
11004         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11005         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11006         CVec_u8Z_free(arg_var);
11007         return arg_arr;
11008 }
11009
11010 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11011         LDKu8slice ser_ref;
11012         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11013         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11014         LDKGossipTimestampFilter ret = GossipTimestampFilter_read(ser_ref);
11015         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11016         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11017 }
11018
11019 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv * _env, jclass _b, jlong obj) {
11020         LDKGossipTimestampFilter obj_conv;
11021         obj_conv.inner = (void*)(obj & (~1));
11022         obj_conv.is_owned = (obj & 1) || (obj == 0);
11023         LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
11024         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11025         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11026         CVec_u8Z_free(arg_var);
11027         return arg_arr;
11028 }
11029
11030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11031         LDKMessageHandler this_ptr_conv;
11032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11033         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11034         MessageHandler_free(this_ptr_conv);
11035 }
11036
11037 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
11038         LDKMessageHandler this_ptr_conv;
11039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11040         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11041         long ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
11042         return ret;
11043 }
11044
11045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11046         LDKMessageHandler this_ptr_conv;
11047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11048         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11049         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
11050         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
11051                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11052                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
11053         }
11054         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
11055 }
11056
11057 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
11058         LDKMessageHandler this_ptr_conv;
11059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11060         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11061         long ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
11062         return ret;
11063 }
11064
11065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11066         LDKMessageHandler this_ptr_conv;
11067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11068         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11069         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
11070         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11071                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11072                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
11073         }
11074         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
11075 }
11076
11077 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv * _env, jclass _b, jlong chan_handler_arg, jlong route_handler_arg) {
11078         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
11079         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
11080                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11081                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
11082         }
11083         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
11084         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11085                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11086                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
11087         }
11088         LDKMessageHandler ret = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
11089         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11090 }
11091
11092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11093         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
11094         FREE((void*)this_ptr);
11095         SocketDescriptor_free(this_ptr_conv);
11096 }
11097
11098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11099         LDKPeerHandleError this_ptr_conv;
11100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11101         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11102         PeerHandleError_free(this_ptr_conv);
11103 }
11104
11105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr) {
11106         LDKPeerHandleError this_ptr_conv;
11107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11108         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11109         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
11110         return ret_val;
11111 }
11112
11113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
11114         LDKPeerHandleError this_ptr_conv;
11115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11116         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11117         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
11118 }
11119
11120 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv * _env, jclass _b, jboolean no_connection_possible_arg) {
11121         LDKPeerHandleError ret = PeerHandleError_new(no_connection_possible_arg);
11122         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11123 }
11124
11125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11126         LDKPeerManager this_ptr_conv;
11127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11128         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11129         PeerManager_free(this_ptr_conv);
11130 }
11131
11132 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) {
11133         LDKMessageHandler message_handler_conv;
11134         message_handler_conv.inner = (void*)(message_handler & (~1));
11135         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
11136         // Warning: we may need a move here but can't clone!
11137         LDKSecretKey our_node_secret_ref;
11138         CHECK((*_env)->GetArrayLength (_env, our_node_secret) == 32);
11139         (*_env)->GetByteArrayRegion (_env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
11140         unsigned char ephemeral_random_data_arr[32];
11141         CHECK((*_env)->GetArrayLength (_env, ephemeral_random_data) == 32);
11142         (*_env)->GetByteArrayRegion (_env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
11143         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
11144         LDKLogger logger_conv = *(LDKLogger*)logger;
11145         if (logger_conv.free == LDKLogger_JCalls_free) {
11146                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11147                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11148         }
11149         LDKPeerManager ret = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
11150         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11151 }
11152
11153 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) {
11154         LDKPeerManager this_arg_conv;
11155         this_arg_conv.inner = (void*)(this_arg & (~1));
11156         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11157         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
11158         jobjectArray ret_arr = (*_env)->NewObjectArray(_env, ret_var.datalen, NULL, NULL);
11159         for (size_t i = 0; i < ret_var.datalen; i++) {
11160                 jbyteArray arr_conv_8_arr = (*_env)->NewByteArray(_env, 33);
11161                 (*_env)->SetByteArrayRegion(_env, arr_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
11162                 (*_env)->SetObjectArrayElement(_env, ret_arr, i, arr_conv_8_arr);
11163         }
11164         CVec_PublicKeyZ_free(ret_var);
11165         return ret_arr;
11166 }
11167
11168 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) {
11169         LDKPeerManager this_arg_conv;
11170         this_arg_conv.inner = (void*)(this_arg & (~1));
11171         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11172         LDKPublicKey their_node_id_ref;
11173         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
11174         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11175         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
11176         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
11177                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11178                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
11179         }
11180         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11181         *ret = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
11182         return (long)ret;
11183 }
11184
11185 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
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         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
11190         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
11191                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11192                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
11193         }
11194         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11195         *ret = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
11196         return (long)ret;
11197 }
11198
11199 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
11200         LDKPeerManager this_arg_conv;
11201         this_arg_conv.inner = (void*)(this_arg & (~1));
11202         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11203         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
11204         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11205         *ret = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
11206         return (long)ret;
11207 }
11208
11209 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv * _env, jclass _b, jlong this_arg, jlong peer_descriptor, jbyteArray data) {
11210         LDKPeerManager this_arg_conv;
11211         this_arg_conv.inner = (void*)(this_arg & (~1));
11212         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11213         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
11214         LDKu8slice data_ref;
11215         data_ref.data = (*_env)->GetByteArrayElements (_env, data, NULL);
11216         data_ref.datalen = (*_env)->GetArrayLength (_env, data);
11217         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11218         *ret = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
11219         (*_env)->ReleaseByteArrayElements(_env, data, (int8_t*)data_ref.data, 0);
11220         return (long)ret;
11221 }
11222
11223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
11224         LDKPeerManager this_arg_conv;
11225         this_arg_conv.inner = (void*)(this_arg & (~1));
11226         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11227         PeerManager_process_events(&this_arg_conv);
11228 }
11229
11230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
11231         LDKPeerManager this_arg_conv;
11232         this_arg_conv.inner = (void*)(this_arg & (~1));
11233         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11234         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
11235         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
11236 }
11237
11238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv * _env, jclass _b, jlong this_arg) {
11239         LDKPeerManager this_arg_conv;
11240         this_arg_conv.inner = (void*)(this_arg & (~1));
11241         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11242         PeerManager_timer_tick_occured(&this_arg_conv);
11243 }
11244
11245 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv * _env, jclass _b, jbyteArray commitment_seed, jlong idx) {
11246         unsigned char commitment_seed_arr[32];
11247         CHECK((*_env)->GetArrayLength (_env, commitment_seed) == 32);
11248         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_arr);
11249         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
11250         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
11251         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
11252         return arg_arr;
11253 }
11254
11255 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_secret) {
11256         LDKPublicKey per_commitment_point_ref;
11257         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11258         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11259         unsigned char base_secret_arr[32];
11260         CHECK((*_env)->GetArrayLength (_env, base_secret) == 32);
11261         (*_env)->GetByteArrayRegion (_env, base_secret, 0, 32, base_secret_arr);
11262         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
11263         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
11264         *ret = derive_private_key(per_commitment_point_ref, base_secret_ref);
11265         return (long)ret;
11266 }
11267
11268 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_point) {
11269         LDKPublicKey per_commitment_point_ref;
11270         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11271         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11272         LDKPublicKey base_point_ref;
11273         CHECK((*_env)->GetArrayLength (_env, base_point) == 33);
11274         (*_env)->GetByteArrayRegion (_env, base_point, 0, 33, base_point_ref.compressed_form);
11275         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
11276         *ret = derive_public_key(per_commitment_point_ref, base_point_ref);
11277         return (long)ret;
11278 }
11279
11280 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) {
11281         unsigned char per_commitment_secret_arr[32];
11282         CHECK((*_env)->GetArrayLength (_env, per_commitment_secret) == 32);
11283         (*_env)->GetByteArrayRegion (_env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
11284         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
11285         unsigned char countersignatory_revocation_base_secret_arr[32];
11286         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base_secret) == 32);
11287         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
11288         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
11289         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
11290         *ret = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
11291         return (long)ret;
11292 }
11293
11294 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) {
11295         LDKPublicKey per_commitment_point_ref;
11296         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11297         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11298         LDKPublicKey countersignatory_revocation_base_point_ref;
11299         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base_point) == 33);
11300         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
11301         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
11302         *ret = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
11303         return (long)ret;
11304 }
11305
11306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11307         LDKTxCreationKeys this_ptr_conv;
11308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11309         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11310         TxCreationKeys_free(this_ptr_conv);
11311 }
11312
11313 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11314         LDKTxCreationKeys orig_conv;
11315         orig_conv.inner = (void*)(orig & (~1));
11316         orig_conv.is_owned = (orig & 1) || (orig == 0);
11317         LDKTxCreationKeys ret = TxCreationKeys_clone(&orig_conv);
11318         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11319 }
11320
11321 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
11322         LDKTxCreationKeys this_ptr_conv;
11323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11324         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11325         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11326         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
11327         return arg_arr;
11328 }
11329
11330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11331         LDKTxCreationKeys this_ptr_conv;
11332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11333         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11334         LDKPublicKey val_ref;
11335         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11336         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11337         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
11338 }
11339
11340 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11341         LDKTxCreationKeys this_ptr_conv;
11342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11343         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11344         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11345         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
11346         return arg_arr;
11347 }
11348
11349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11350         LDKTxCreationKeys this_ptr_conv;
11351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11352         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11353         LDKPublicKey val_ref;
11354         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11355         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11356         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
11357 }
11358
11359 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11360         LDKTxCreationKeys this_ptr_conv;
11361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11362         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11363         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11364         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
11365         return arg_arr;
11366 }
11367
11368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11369         LDKTxCreationKeys this_ptr_conv;
11370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11371         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11372         LDKPublicKey val_ref;
11373         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11374         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11375         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
11376 }
11377
11378 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11379         LDKTxCreationKeys this_ptr_conv;
11380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11381         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11382         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11383         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
11384         return arg_arr;
11385 }
11386
11387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11388         LDKTxCreationKeys this_ptr_conv;
11389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11390         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11391         LDKPublicKey val_ref;
11392         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11393         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11394         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
11395 }
11396
11397 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
11398         LDKTxCreationKeys this_ptr_conv;
11399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11400         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11401         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11402         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
11403         return arg_arr;
11404 }
11405
11406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11407         LDKTxCreationKeys this_ptr_conv;
11408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11409         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11410         LDKPublicKey val_ref;
11411         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11412         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11413         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
11414 }
11415
11416 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) {
11417         LDKPublicKey per_commitment_point_arg_ref;
11418         CHECK((*_env)->GetArrayLength (_env, per_commitment_point_arg) == 33);
11419         (*_env)->GetByteArrayRegion (_env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
11420         LDKPublicKey revocation_key_arg_ref;
11421         CHECK((*_env)->GetArrayLength (_env, revocation_key_arg) == 33);
11422         (*_env)->GetByteArrayRegion (_env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
11423         LDKPublicKey broadcaster_htlc_key_arg_ref;
11424         CHECK((*_env)->GetArrayLength (_env, broadcaster_htlc_key_arg) == 33);
11425         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
11426         LDKPublicKey countersignatory_htlc_key_arg_ref;
11427         CHECK((*_env)->GetArrayLength (_env, countersignatory_htlc_key_arg) == 33);
11428         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
11429         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
11430         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key_arg) == 33);
11431         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
11432         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);
11433         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11434 }
11435
11436 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
11437         LDKTxCreationKeys obj_conv;
11438         obj_conv.inner = (void*)(obj & (~1));
11439         obj_conv.is_owned = (obj & 1) || (obj == 0);
11440         LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
11441         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11442         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11443         CVec_u8Z_free(arg_var);
11444         return arg_arr;
11445 }
11446
11447 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11448         LDKu8slice ser_ref;
11449         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11450         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11451         LDKTxCreationKeys ret = TxCreationKeys_read(ser_ref);
11452         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11453         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11454 }
11455
11456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11457         LDKPreCalculatedTxCreationKeys this_ptr_conv;
11458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11459         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11460         PreCalculatedTxCreationKeys_free(this_ptr_conv);
11461 }
11462
11463 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1new(JNIEnv * _env, jclass _b, jlong keys) {
11464         LDKTxCreationKeys keys_conv;
11465         keys_conv.inner = (void*)(keys & (~1));
11466         keys_conv.is_owned = (keys & 1) || (keys == 0);
11467         if (keys_conv.inner != NULL)
11468                 keys_conv = TxCreationKeys_clone(&keys_conv);
11469         LDKPreCalculatedTxCreationKeys ret = PreCalculatedTxCreationKeys_new(keys_conv);
11470         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11471 }
11472
11473 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
11474         LDKPreCalculatedTxCreationKeys this_arg_conv;
11475         this_arg_conv.inner = (void*)(this_arg & (~1));
11476         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11477         LDKTxCreationKeys ret = PreCalculatedTxCreationKeys_trust_key_derivation(&this_arg_conv);
11478         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11479 }
11480
11481 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg) {
11482         LDKPreCalculatedTxCreationKeys this_arg_conv;
11483         this_arg_conv.inner = (void*)(this_arg & (~1));
11484         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11485         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11486         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, PreCalculatedTxCreationKeys_per_commitment_point(&this_arg_conv).compressed_form);
11487         return arg_arr;
11488 }
11489
11490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11491         LDKChannelPublicKeys this_ptr_conv;
11492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11493         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11494         ChannelPublicKeys_free(this_ptr_conv);
11495 }
11496
11497 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11498         LDKChannelPublicKeys orig_conv;
11499         orig_conv.inner = (void*)(orig & (~1));
11500         orig_conv.is_owned = (orig & 1) || (orig == 0);
11501         LDKChannelPublicKeys ret = ChannelPublicKeys_clone(&orig_conv);
11502         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11503 }
11504
11505 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
11506         LDKChannelPublicKeys this_ptr_conv;
11507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11508         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11509         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11510         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
11511         return arg_arr;
11512 }
11513
11514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11515         LDKChannelPublicKeys this_ptr_conv;
11516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11517         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11518         LDKPublicKey val_ref;
11519         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11520         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11521         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
11522 }
11523
11524 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
11525         LDKChannelPublicKeys this_ptr_conv;
11526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11527         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11528         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11529         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
11530         return arg_arr;
11531 }
11532
11533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11534         LDKChannelPublicKeys this_ptr_conv;
11535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11536         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11537         LDKPublicKey val_ref;
11538         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11539         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11540         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
11541 }
11542
11543 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11548         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
11549         return arg_arr;
11550 }
11551
11552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11553         LDKChannelPublicKeys this_ptr_conv;
11554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11555         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11556         LDKPublicKey val_ref;
11557         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11558         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11559         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
11560 }
11561
11562 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11567         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
11568         return arg_arr;
11569 }
11570
11571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11572         LDKChannelPublicKeys this_ptr_conv;
11573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11574         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11575         LDKPublicKey val_ref;
11576         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11577         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11578         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
11579 }
11580
11581 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11586         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
11587         return arg_arr;
11588 }
11589
11590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11591         LDKChannelPublicKeys this_ptr_conv;
11592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11593         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11594         LDKPublicKey val_ref;
11595         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11596         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11597         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
11598 }
11599
11600 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) {
11601         LDKPublicKey funding_pubkey_arg_ref;
11602         CHECK((*_env)->GetArrayLength (_env, funding_pubkey_arg) == 33);
11603         (*_env)->GetByteArrayRegion (_env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
11604         LDKPublicKey revocation_basepoint_arg_ref;
11605         CHECK((*_env)->GetArrayLength (_env, revocation_basepoint_arg) == 33);
11606         (*_env)->GetByteArrayRegion (_env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
11607         LDKPublicKey payment_point_arg_ref;
11608         CHECK((*_env)->GetArrayLength (_env, payment_point_arg) == 33);
11609         (*_env)->GetByteArrayRegion (_env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
11610         LDKPublicKey delayed_payment_basepoint_arg_ref;
11611         CHECK((*_env)->GetArrayLength (_env, delayed_payment_basepoint_arg) == 33);
11612         (*_env)->GetByteArrayRegion (_env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
11613         LDKPublicKey htlc_basepoint_arg_ref;
11614         CHECK((*_env)->GetArrayLength (_env, htlc_basepoint_arg) == 33);
11615         (*_env)->GetByteArrayRegion (_env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
11616         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);
11617         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11618 }
11619
11620 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
11621         LDKChannelPublicKeys obj_conv;
11622         obj_conv.inner = (void*)(obj & (~1));
11623         obj_conv.is_owned = (obj & 1) || (obj == 0);
11624         LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
11625         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11626         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11627         CVec_u8Z_free(arg_var);
11628         return arg_arr;
11629 }
11630
11631 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11632         LDKu8slice ser_ref;
11633         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11634         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11635         LDKChannelPublicKeys ret = ChannelPublicKeys_read(ser_ref);
11636         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11637         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11638 }
11639
11640 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) {
11641         LDKPublicKey per_commitment_point_ref;
11642         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
11643         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
11644         LDKPublicKey broadcaster_delayed_payment_base_ref;
11645         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_base) == 33);
11646         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
11647         LDKPublicKey broadcaster_htlc_base_ref;
11648         CHECK((*_env)->GetArrayLength (_env, broadcaster_htlc_base) == 33);
11649         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
11650         LDKPublicKey countersignatory_revocation_base_ref;
11651         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base) == 33);
11652         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
11653         LDKPublicKey countersignatory_htlc_base_ref;
11654         CHECK((*_env)->GetArrayLength (_env, countersignatory_htlc_base) == 33);
11655         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
11656         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
11657         *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);
11658         return (long)ret;
11659 }
11660
11661 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) {
11662         LDKPublicKey revocation_key_ref;
11663         CHECK((*_env)->GetArrayLength (_env, revocation_key) == 33);
11664         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
11665         LDKPublicKey broadcaster_delayed_payment_key_ref;
11666         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key) == 33);
11667         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
11668         LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
11669         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11670         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11671         CVec_u8Z_free(arg_var);
11672         return arg_arr;
11673 }
11674
11675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11676         LDKHTLCOutputInCommitment this_ptr_conv;
11677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11678         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11679         HTLCOutputInCommitment_free(this_ptr_conv);
11680 }
11681
11682 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11683         LDKHTLCOutputInCommitment orig_conv;
11684         orig_conv.inner = (void*)(orig & (~1));
11685         orig_conv.is_owned = (orig & 1) || (orig == 0);
11686         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_clone(&orig_conv);
11687         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11688 }
11689
11690 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv * _env, jclass _b, jlong this_ptr) {
11691         LDKHTLCOutputInCommitment this_ptr_conv;
11692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11693         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11694         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
11695         return ret_val;
11696 }
11697
11698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
11699         LDKHTLCOutputInCommitment this_ptr_conv;
11700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11701         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11702         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
11703 }
11704
11705 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
11706         LDKHTLCOutputInCommitment this_ptr_conv;
11707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11708         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11709         jlong ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
11710         return ret_val;
11711 }
11712
11713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11714         LDKHTLCOutputInCommitment this_ptr_conv;
11715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11716         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11717         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
11718 }
11719
11720 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
11721         LDKHTLCOutputInCommitment this_ptr_conv;
11722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11723         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11724         jint ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
11725         return ret_val;
11726 }
11727
11728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11729         LDKHTLCOutputInCommitment this_ptr_conv;
11730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11731         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11732         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
11733 }
11734
11735 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
11736         LDKHTLCOutputInCommitment this_ptr_conv;
11737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11738         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11739         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
11740         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
11741         return ret_arr;
11742 }
11743
11744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11745         LDKHTLCOutputInCommitment this_ptr_conv;
11746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11747         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11748         LDKThirtyTwoBytes val_ref;
11749         CHECK((*_env)->GetArrayLength (_env, val) == 32);
11750         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
11751         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
11752 }
11753
11754 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv * _env, jclass _b, jlong obj) {
11755         LDKHTLCOutputInCommitment obj_conv;
11756         obj_conv.inner = (void*)(obj & (~1));
11757         obj_conv.is_owned = (obj & 1) || (obj == 0);
11758         LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
11759         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11760         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11761         CVec_u8Z_free(arg_var);
11762         return arg_arr;
11763 }
11764
11765 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
11766         LDKu8slice ser_ref;
11767         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
11768         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
11769         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_read(ser_ref);
11770         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
11771         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11772 }
11773
11774 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv * _env, jclass _b, jlong htlc, jlong keys) {
11775         LDKHTLCOutputInCommitment htlc_conv;
11776         htlc_conv.inner = (void*)(htlc & (~1));
11777         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
11778         LDKTxCreationKeys keys_conv;
11779         keys_conv.inner = (void*)(keys & (~1));
11780         keys_conv.is_owned = (keys & 1) || (keys == 0);
11781         LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
11782         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11783         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11784         CVec_u8Z_free(arg_var);
11785         return arg_arr;
11786 }
11787
11788 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv * _env, jclass _b, jbyteArray broadcaster, jbyteArray countersignatory) {
11789         LDKPublicKey broadcaster_ref;
11790         CHECK((*_env)->GetArrayLength (_env, broadcaster) == 33);
11791         (*_env)->GetByteArrayRegion (_env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
11792         LDKPublicKey countersignatory_ref;
11793         CHECK((*_env)->GetArrayLength (_env, countersignatory) == 33);
11794         (*_env)->GetByteArrayRegion (_env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
11795         LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
11796         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11797         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11798         CVec_u8Z_free(arg_var);
11799         return arg_arr;
11800 }
11801
11802 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) {
11803         unsigned char prev_hash_arr[32];
11804         CHECK((*_env)->GetArrayLength (_env, prev_hash) == 32);
11805         (*_env)->GetByteArrayRegion (_env, prev_hash, 0, 32, prev_hash_arr);
11806         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
11807         LDKHTLCOutputInCommitment htlc_conv;
11808         htlc_conv.inner = (void*)(htlc & (~1));
11809         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
11810         LDKPublicKey broadcaster_delayed_payment_key_ref;
11811         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key) == 33);
11812         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
11813         LDKPublicKey revocation_key_ref;
11814         CHECK((*_env)->GetArrayLength (_env, revocation_key) == 33);
11815         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
11816         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
11817         *ret = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
11818         return (long)ret;
11819 }
11820
11821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11822         LDKHolderCommitmentTransaction this_ptr_conv;
11823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11824         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11825         HolderCommitmentTransaction_free(this_ptr_conv);
11826 }
11827
11828 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11829         LDKHolderCommitmentTransaction orig_conv;
11830         orig_conv.inner = (void*)(orig & (~1));
11831         orig_conv.is_owned = (orig & 1) || (orig == 0);
11832         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_clone(&orig_conv);
11833         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11834 }
11835
11836 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr) {
11837         LDKHolderCommitmentTransaction this_ptr_conv;
11838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11839         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11840         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
11841         *ret = HolderCommitmentTransaction_get_unsigned_tx(&this_ptr_conv);
11842         return (long)ret;
11843 }
11844
11845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
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         LDKTransaction val_conv = *(LDKTransaction*)val;
11850         FREE((void*)val);
11851         HolderCommitmentTransaction_set_unsigned_tx(&this_ptr_conv, val_conv);
11852 }
11853
11854 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr) {
11855         LDKHolderCommitmentTransaction this_ptr_conv;
11856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11857         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11858         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
11859         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
11860         return arg_arr;
11861 }
11862
11863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11864         LDKHolderCommitmentTransaction this_ptr_conv;
11865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11866         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11867         LDKSignature val_ref;
11868         CHECK((*_env)->GetArrayLength (_env, val) == 64);
11869         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
11870         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
11871 }
11872
11873 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
11874         LDKHolderCommitmentTransaction this_ptr_conv;
11875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11876         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11877         jint ret_val = HolderCommitmentTransaction_get_feerate_per_kw(&this_ptr_conv);
11878         return ret_val;
11879 }
11880
11881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11882         LDKHolderCommitmentTransaction this_ptr_conv;
11883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11884         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11885         HolderCommitmentTransaction_set_feerate_per_kw(&this_ptr_conv, val);
11886 }
11887
11888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
11889         LDKHolderCommitmentTransaction this_ptr_conv;
11890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11891         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11892         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_constr;
11893         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
11894         if (val_constr.datalen > 0)
11895                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
11896         else
11897                 val_constr.data = NULL;
11898         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
11899         for (size_t q = 0; q < val_constr.datalen; q++) {
11900                 long arr_conv_42 = val_vals[q];
11901                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
11902                 FREE((void*)arr_conv_42);
11903                 val_constr.data[q] = arr_conv_42_conv;
11904         }
11905         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
11906         HolderCommitmentTransaction_set_per_htlc(&this_ptr_conv, val_constr);
11907 }
11908
11909 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) {
11910         LDKTransaction unsigned_tx_conv = *(LDKTransaction*)unsigned_tx;
11911         FREE((void*)unsigned_tx);
11912         LDKSignature counterparty_sig_ref;
11913         CHECK((*_env)->GetArrayLength (_env, counterparty_sig) == 64);
11914         (*_env)->GetByteArrayRegion (_env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
11915         LDKPublicKey holder_funding_key_ref;
11916         CHECK((*_env)->GetArrayLength (_env, holder_funding_key) == 33);
11917         (*_env)->GetByteArrayRegion (_env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
11918         LDKPublicKey counterparty_funding_key_ref;
11919         CHECK((*_env)->GetArrayLength (_env, counterparty_funding_key) == 33);
11920         (*_env)->GetByteArrayRegion (_env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
11921         LDKTxCreationKeys keys_conv;
11922         keys_conv.inner = (void*)(keys & (~1));
11923         keys_conv.is_owned = (keys & 1) || (keys == 0);
11924         if (keys_conv.inner != NULL)
11925                 keys_conv = TxCreationKeys_clone(&keys_conv);
11926         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_constr;
11927         htlc_data_constr.datalen = (*_env)->GetArrayLength (_env, htlc_data);
11928         if (htlc_data_constr.datalen > 0)
11929                 htlc_data_constr.data = MALLOC(htlc_data_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements");
11930         else
11931                 htlc_data_constr.data = NULL;
11932         long* htlc_data_vals = (*_env)->GetLongArrayElements (_env, htlc_data, NULL);
11933         for (size_t q = 0; q < htlc_data_constr.datalen; q++) {
11934                 long arr_conv_42 = htlc_data_vals[q];
11935                 LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42;
11936                 FREE((void*)arr_conv_42);
11937                 htlc_data_constr.data[q] = arr_conv_42_conv;
11938         }
11939         (*_env)->ReleaseLongArrayElements (_env, htlc_data, htlc_data_vals, 0);
11940         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);
11941         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11942 }
11943
11944 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
11945         LDKHolderCommitmentTransaction this_arg_conv;
11946         this_arg_conv.inner = (void*)(this_arg & (~1));
11947         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11948         LDKTxCreationKeys ret = HolderCommitmentTransaction_trust_key_derivation(&this_arg_conv);
11949         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11950 }
11951
11952 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1txid(JNIEnv * _env, jclass _b, jlong this_arg) {
11953         LDKHolderCommitmentTransaction this_arg_conv;
11954         this_arg_conv.inner = (void*)(this_arg & (~1));
11955         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11956         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
11957         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, HolderCommitmentTransaction_txid(&this_arg_conv).data);
11958         return arg_arr;
11959 }
11960
11961 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) {
11962         LDKHolderCommitmentTransaction this_arg_conv;
11963         this_arg_conv.inner = (void*)(this_arg & (~1));
11964         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11965         unsigned char funding_key_arr[32];
11966         CHECK((*_env)->GetArrayLength (_env, funding_key) == 32);
11967         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_arr);
11968         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
11969         LDKu8slice funding_redeemscript_ref;
11970         funding_redeemscript_ref.data = (*_env)->GetByteArrayElements (_env, funding_redeemscript, NULL);
11971         funding_redeemscript_ref.datalen = (*_env)->GetArrayLength (_env, funding_redeemscript);
11972         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
11973         (*_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);
11974         (*_env)->ReleaseByteArrayElements(_env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
11975         return arg_arr;
11976 }
11977
11978 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) {
11979         LDKHolderCommitmentTransaction this_arg_conv;
11980         this_arg_conv.inner = (void*)(this_arg & (~1));
11981         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11982         unsigned char htlc_base_key_arr[32];
11983         CHECK((*_env)->GetArrayLength (_env, htlc_base_key) == 32);
11984         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_arr);
11985         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
11986         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11987         *ret = HolderCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, counterparty_selected_contest_delay);
11988         return (long)ret;
11989 }
11990
11991 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv * _env, jclass _b, jlong obj) {
11992         LDKHolderCommitmentTransaction obj_conv;
11993         obj_conv.inner = (void*)(obj & (~1));
11994         obj_conv.is_owned = (obj & 1) || (obj == 0);
11995         LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
11996         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
11997         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
11998         CVec_u8Z_free(arg_var);
11999         return arg_arr;
12000 }
12001
12002 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12003         LDKu8slice ser_ref;
12004         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12005         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12006         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_read(ser_ref);
12007         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12008         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12009 }
12010
12011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12012         LDKInitFeatures this_ptr_conv;
12013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12014         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12015         InitFeatures_free(this_ptr_conv);
12016 }
12017
12018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12019         LDKNodeFeatures this_ptr_conv;
12020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12021         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12022         NodeFeatures_free(this_ptr_conv);
12023 }
12024
12025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12026         LDKChannelFeatures this_ptr_conv;
12027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12028         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12029         ChannelFeatures_free(this_ptr_conv);
12030 }
12031
12032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12033         LDKRouteHop this_ptr_conv;
12034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12035         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12036         RouteHop_free(this_ptr_conv);
12037 }
12038
12039 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12040         LDKRouteHop orig_conv;
12041         orig_conv.inner = (void*)(orig & (~1));
12042         orig_conv.is_owned = (orig & 1) || (orig == 0);
12043         LDKRouteHop ret = RouteHop_clone(&orig_conv);
12044         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12045 }
12046
12047 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
12048         LDKRouteHop this_ptr_conv;
12049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12050         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12051         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12052         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
12053         return arg_arr;
12054 }
12055
12056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12057         LDKRouteHop this_ptr_conv;
12058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12059         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12060         LDKPublicKey val_ref;
12061         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12062         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12063         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
12064 }
12065
12066 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12067         LDKRouteHop this_ptr_conv;
12068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12069         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12070         LDKNodeFeatures ret = RouteHop_get_node_features(&this_ptr_conv);
12071         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12072 }
12073
12074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12075         LDKRouteHop this_ptr_conv;
12076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12077         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12078         LDKNodeFeatures val_conv;
12079         val_conv.inner = (void*)(val & (~1));
12080         val_conv.is_owned = (val & 1) || (val == 0);
12081         // Warning: we may need a move here but can't clone!
12082         RouteHop_set_node_features(&this_ptr_conv, val_conv);
12083 }
12084
12085 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12086         LDKRouteHop this_ptr_conv;
12087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12088         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12089         jlong ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
12090         return ret_val;
12091 }
12092
12093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12094         LDKRouteHop this_ptr_conv;
12095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12096         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12097         RouteHop_set_short_channel_id(&this_ptr_conv, val);
12098 }
12099
12100 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12101         LDKRouteHop this_ptr_conv;
12102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12103         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12104         LDKChannelFeatures ret = RouteHop_get_channel_features(&this_ptr_conv);
12105         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12106 }
12107
12108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
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         LDKChannelFeatures val_conv;
12113         val_conv.inner = (void*)(val & (~1));
12114         val_conv.is_owned = (val & 1) || (val == 0);
12115         // Warning: we may need a move here but can't clone!
12116         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
12117 }
12118
12119 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12120         LDKRouteHop this_ptr_conv;
12121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12122         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12123         jlong ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
12124         return ret_val;
12125 }
12126
12127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12128         LDKRouteHop this_ptr_conv;
12129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12130         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12131         RouteHop_set_fee_msat(&this_ptr_conv, val);
12132 }
12133
12134 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
12135         LDKRouteHop this_ptr_conv;
12136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12137         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12138         jint ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
12139         return ret_val;
12140 }
12141
12142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
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         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
12147 }
12148
12149 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) {
12150         LDKPublicKey pubkey_arg_ref;
12151         CHECK((*_env)->GetArrayLength (_env, pubkey_arg) == 33);
12152         (*_env)->GetByteArrayRegion (_env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
12153         LDKNodeFeatures node_features_arg_conv;
12154         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
12155         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
12156         // Warning: we may need a move here but can't clone!
12157         LDKChannelFeatures channel_features_arg_conv;
12158         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
12159         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
12160         // Warning: we may need a move here but can't clone!
12161         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);
12162         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12163 }
12164
12165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12166         LDKRoute 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         Route_free(this_ptr_conv);
12170 }
12171
12172 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12173         LDKRoute orig_conv;
12174         orig_conv.inner = (void*)(orig & (~1));
12175         orig_conv.is_owned = (orig & 1) || (orig == 0);
12176         LDKRoute ret = Route_clone(&orig_conv);
12177         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12178 }
12179
12180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jobjectArray val) {
12181         LDKRoute this_ptr_conv;
12182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12183         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12184         LDKCVec_CVec_RouteHopZZ val_constr;
12185         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
12186         if (val_constr.datalen > 0)
12187                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12188         else
12189                 val_constr.data = NULL;
12190         for (size_t m = 0; m < val_constr.datalen; m++) {
12191                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, val, m);
12192                 LDKCVec_RouteHopZ arr_conv_12_constr;
12193                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
12194                 if (arr_conv_12_constr.datalen > 0)
12195                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12196                 else
12197                         arr_conv_12_constr.data = NULL;
12198                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
12199                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
12200                         long arr_conv_10 = arr_conv_12_vals[k];
12201                         LDKRouteHop arr_conv_10_conv;
12202                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
12203                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
12204                         if (arr_conv_10_conv.inner != NULL)
12205                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
12206                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
12207                 }
12208                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
12209                 val_constr.data[m] = arr_conv_12_constr;
12210         }
12211         Route_set_paths(&this_ptr_conv, val_constr);
12212 }
12213
12214 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jobjectArray paths_arg) {
12215         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
12216         paths_arg_constr.datalen = (*_env)->GetArrayLength (_env, paths_arg);
12217         if (paths_arg_constr.datalen > 0)
12218                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12219         else
12220                 paths_arg_constr.data = NULL;
12221         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
12222                 jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, paths_arg, m);
12223                 LDKCVec_RouteHopZ arr_conv_12_constr;
12224                 arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12);
12225                 if (arr_conv_12_constr.datalen > 0)
12226                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12227                 else
12228                         arr_conv_12_constr.data = NULL;
12229                 long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL);
12230                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
12231                         long arr_conv_10 = arr_conv_12_vals[k];
12232                         LDKRouteHop arr_conv_10_conv;
12233                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
12234                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
12235                         if (arr_conv_10_conv.inner != NULL)
12236                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
12237                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
12238                 }
12239                 (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0);
12240                 paths_arg_constr.data[m] = arr_conv_12_constr;
12241         }
12242         LDKRoute ret = Route_new(paths_arg_constr);
12243         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12244 }
12245
12246 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv * _env, jclass _b, jlong obj) {
12247         LDKRoute obj_conv;
12248         obj_conv.inner = (void*)(obj & (~1));
12249         obj_conv.is_owned = (obj & 1) || (obj == 0);
12250         LDKCVec_u8Z arg_var = Route_write(&obj_conv);
12251         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12252         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12253         CVec_u8Z_free(arg_var);
12254         return arg_arr;
12255 }
12256
12257 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12258         LDKu8slice ser_ref;
12259         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12260         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12261         LDKRoute ret = Route_read(ser_ref);
12262         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12263         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12264 }
12265
12266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12267         LDKRouteHint this_ptr_conv;
12268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12269         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12270         RouteHint_free(this_ptr_conv);
12271 }
12272
12273 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12274         LDKRouteHint orig_conv;
12275         orig_conv.inner = (void*)(orig & (~1));
12276         orig_conv.is_owned = (orig & 1) || (orig == 0);
12277         LDKRouteHint ret = RouteHint_clone(&orig_conv);
12278         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12279 }
12280
12281 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12282         LDKRouteHint this_ptr_conv;
12283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12284         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12285         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12286         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
12287         return arg_arr;
12288 }
12289
12290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12291         LDKRouteHint this_ptr_conv;
12292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12293         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12294         LDKPublicKey val_ref;
12295         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12296         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12297         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
12298 }
12299
12300 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
12301         LDKRouteHint this_ptr_conv;
12302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12303         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12304         jlong ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
12305         return ret_val;
12306 }
12307
12308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12309         LDKRouteHint this_ptr_conv;
12310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12311         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12312         RouteHint_set_short_channel_id(&this_ptr_conv, val);
12313 }
12314
12315 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
12316         LDKRouteHint this_ptr_conv;
12317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12318         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12319         LDKRoutingFees ret = RouteHint_get_fees(&this_ptr_conv);
12320         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12321 }
12322
12323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12324         LDKRouteHint this_ptr_conv;
12325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12326         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12327         LDKRoutingFees val_conv;
12328         val_conv.inner = (void*)(val & (~1));
12329         val_conv.is_owned = (val & 1) || (val == 0);
12330         if (val_conv.inner != NULL)
12331                 val_conv = RoutingFees_clone(&val_conv);
12332         RouteHint_set_fees(&this_ptr_conv, val_conv);
12333 }
12334
12335 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
12336         LDKRouteHint this_ptr_conv;
12337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12338         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12339         jshort ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
12340         return ret_val;
12341 }
12342
12343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
12344         LDKRouteHint this_ptr_conv;
12345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12346         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12347         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
12348 }
12349
12350 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12351         LDKRouteHint this_ptr_conv;
12352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12353         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12354         jlong ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
12355         return ret_val;
12356 }
12357
12358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12359         LDKRouteHint this_ptr_conv;
12360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12361         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12362         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
12363 }
12364
12365 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) {
12366         LDKPublicKey src_node_id_arg_ref;
12367         CHECK((*_env)->GetArrayLength (_env, src_node_id_arg) == 33);
12368         (*_env)->GetByteArrayRegion (_env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
12369         LDKRoutingFees fees_arg_conv;
12370         fees_arg_conv.inner = (void*)(fees_arg & (~1));
12371         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
12372         if (fees_arg_conv.inner != NULL)
12373                 fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
12374         LDKRouteHint ret = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
12375         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12376 }
12377
12378 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) {
12379         LDKPublicKey our_node_id_ref;
12380         CHECK((*_env)->GetArrayLength (_env, our_node_id) == 33);
12381         (*_env)->GetByteArrayRegion (_env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
12382         LDKNetworkGraph network_conv;
12383         network_conv.inner = (void*)(network & (~1));
12384         network_conv.is_owned = (network & 1) || (network == 0);
12385         LDKPublicKey target_ref;
12386         CHECK((*_env)->GetArrayLength (_env, target) == 33);
12387         (*_env)->GetByteArrayRegion (_env, target, 0, 33, target_ref.compressed_form);
12388         LDKCVec_ChannelDetailsZ first_hops_constr;
12389         first_hops_constr.datalen = (*_env)->GetArrayLength (_env, first_hops);
12390         if (first_hops_constr.datalen > 0)
12391                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12392         else
12393                 first_hops_constr.data = NULL;
12394         long* first_hops_vals = (*_env)->GetLongArrayElements (_env, first_hops, NULL);
12395         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
12396                 long arr_conv_16 = first_hops_vals[q];
12397                 LDKChannelDetails arr_conv_16_conv;
12398                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
12399                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
12400                 first_hops_constr.data[q] = arr_conv_16_conv;
12401         }
12402         (*_env)->ReleaseLongArrayElements (_env, first_hops, first_hops_vals, 0);
12403         LDKCVec_RouteHintZ last_hops_constr;
12404         last_hops_constr.datalen = (*_env)->GetArrayLength (_env, last_hops);
12405         if (last_hops_constr.datalen > 0)
12406                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12407         else
12408                 last_hops_constr.data = NULL;
12409         long* last_hops_vals = (*_env)->GetLongArrayElements (_env, last_hops, NULL);
12410         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
12411                 long arr_conv_11 = last_hops_vals[l];
12412                 LDKRouteHint arr_conv_11_conv;
12413                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
12414                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
12415                 if (arr_conv_11_conv.inner != NULL)
12416                         arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
12417                 last_hops_constr.data[l] = arr_conv_11_conv;
12418         }
12419         (*_env)->ReleaseLongArrayElements (_env, last_hops, last_hops_vals, 0);
12420         LDKLogger logger_conv = *(LDKLogger*)logger;
12421         if (logger_conv.free == LDKLogger_JCalls_free) {
12422                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12423                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12424         }
12425         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12426         *ret = get_route(our_node_id_ref, &network_conv, target_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
12427         FREE(first_hops_constr.data);
12428         return (long)ret;
12429 }
12430
12431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12432         LDKNetworkGraph this_ptr_conv;
12433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12434         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12435         NetworkGraph_free(this_ptr_conv);
12436 }
12437
12438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12439         LDKLockedNetworkGraph this_ptr_conv;
12440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12441         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12442         LockedNetworkGraph_free(this_ptr_conv);
12443 }
12444
12445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12446         LDKNetGraphMsgHandler this_ptr_conv;
12447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12448         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12449         NetGraphMsgHandler_free(this_ptr_conv);
12450 }
12451
12452 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger) {
12453         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
12454         LDKLogger logger_conv = *(LDKLogger*)logger;
12455         if (logger_conv.free == LDKLogger_JCalls_free) {
12456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12457                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12458         }
12459         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_new(chain_access_conv, logger_conv);
12460         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12461 }
12462
12463 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger, jlong network_graph) {
12464         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
12465         LDKLogger logger_conv = *(LDKLogger*)logger;
12466         if (logger_conv.free == LDKLogger_JCalls_free) {
12467                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12468                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12469         }
12470         LDKNetworkGraph network_graph_conv;
12471         network_graph_conv.inner = (void*)(network_graph & (~1));
12472         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
12473         // Warning: we may need a move here but can't clone!
12474         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
12475         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12476 }
12477
12478 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
12479         LDKNetGraphMsgHandler this_arg_conv;
12480         this_arg_conv.inner = (void*)(this_arg & (~1));
12481         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12482         LDKLockedNetworkGraph ret = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
12483         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12484 }
12485
12486 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
12487         LDKLockedNetworkGraph this_arg_conv;
12488         this_arg_conv.inner = (void*)(this_arg & (~1));
12489         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12490         LDKNetworkGraph ret = LockedNetworkGraph_graph(&this_arg_conv);
12491         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12492 }
12493
12494 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
12495         LDKNetGraphMsgHandler this_arg_conv;
12496         this_arg_conv.inner = (void*)(this_arg & (~1));
12497         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
12498         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
12499         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
12500         return (long)ret;
12501 }
12502
12503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12504         LDKDirectionalChannelInfo this_ptr_conv;
12505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12506         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12507         DirectionalChannelInfo_free(this_ptr_conv);
12508 }
12509
12510 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
12511         LDKDirectionalChannelInfo this_ptr_conv;
12512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12513         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12514         jint ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
12515         return ret_val;
12516 }
12517
12518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12519         LDKDirectionalChannelInfo this_ptr_conv;
12520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12521         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12522         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
12523 }
12524
12525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(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         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
12530         return ret_val;
12531 }
12532
12533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
12534         LDKDirectionalChannelInfo this_ptr_conv;
12535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12536         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12537         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
12538 }
12539
12540 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jshort ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
12545         return ret_val;
12546 }
12547
12548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
12549         LDKDirectionalChannelInfo this_ptr_conv;
12550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12551         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12552         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
12553 }
12554
12555 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         jlong ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
12560         return ret_val;
12561 }
12562
12563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12564         LDKDirectionalChannelInfo this_ptr_conv;
12565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12566         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12567         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
12568 }
12569
12570 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         LDKChannelUpdate ret = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
12575         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12576 }
12577
12578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12579         LDKDirectionalChannelInfo this_ptr_conv;
12580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12581         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12582         LDKChannelUpdate val_conv;
12583         val_conv.inner = (void*)(val & (~1));
12584         val_conv.is_owned = (val & 1) || (val == 0);
12585         if (val_conv.inner != NULL)
12586                 val_conv = ChannelUpdate_clone(&val_conv);
12587         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
12588 }
12589
12590 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
12591         LDKDirectionalChannelInfo obj_conv;
12592         obj_conv.inner = (void*)(obj & (~1));
12593         obj_conv.is_owned = (obj & 1) || (obj == 0);
12594         LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
12595         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12596         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12597         CVec_u8Z_free(arg_var);
12598         return arg_arr;
12599 }
12600
12601 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12602         LDKu8slice ser_ref;
12603         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12604         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12605         LDKDirectionalChannelInfo ret = DirectionalChannelInfo_read(ser_ref);
12606         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12607         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12608 }
12609
12610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12611         LDKChannelInfo this_ptr_conv;
12612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12613         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12614         ChannelInfo_free(this_ptr_conv);
12615 }
12616
12617 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12618         LDKChannelInfo this_ptr_conv;
12619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12620         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12621         LDKChannelFeatures ret = ChannelInfo_get_features(&this_ptr_conv);
12622         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12623 }
12624
12625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12626         LDKChannelInfo this_ptr_conv;
12627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12628         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12629         LDKChannelFeatures val_conv;
12630         val_conv.inner = (void*)(val & (~1));
12631         val_conv.is_owned = (val & 1) || (val == 0);
12632         // Warning: we may need a move here but can't clone!
12633         ChannelInfo_set_features(&this_ptr_conv, val_conv);
12634 }
12635
12636 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
12637         LDKChannelInfo this_ptr_conv;
12638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12639         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12640         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12641         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
12642         return arg_arr;
12643 }
12644
12645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12646         LDKChannelInfo this_ptr_conv;
12647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12648         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12649         LDKPublicKey val_ref;
12650         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12651         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12652         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
12653 }
12654
12655 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
12656         LDKChannelInfo this_ptr_conv;
12657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12658         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12659         LDKDirectionalChannelInfo ret = ChannelInfo_get_one_to_two(&this_ptr_conv);
12660         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12661 }
12662
12663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12664         LDKChannelInfo this_ptr_conv;
12665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12666         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12667         LDKDirectionalChannelInfo val_conv;
12668         val_conv.inner = (void*)(val & (~1));
12669         val_conv.is_owned = (val & 1) || (val == 0);
12670         // Warning: we may need a move here but can't clone!
12671         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
12672 }
12673
12674 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
12675         LDKChannelInfo this_ptr_conv;
12676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12677         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12678         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
12679         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
12680         return arg_arr;
12681 }
12682
12683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12684         LDKChannelInfo this_ptr_conv;
12685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12686         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12687         LDKPublicKey val_ref;
12688         CHECK((*_env)->GetArrayLength (_env, val) == 33);
12689         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
12690         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
12691 }
12692
12693 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
12694         LDKChannelInfo this_ptr_conv;
12695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12696         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12697         LDKDirectionalChannelInfo ret = ChannelInfo_get_two_to_one(&this_ptr_conv);
12698         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12699 }
12700
12701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12702         LDKChannelInfo this_ptr_conv;
12703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12704         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12705         LDKDirectionalChannelInfo val_conv;
12706         val_conv.inner = (void*)(val & (~1));
12707         val_conv.is_owned = (val & 1) || (val == 0);
12708         // Warning: we may need a move here but can't clone!
12709         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
12710 }
12711
12712 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
12713         LDKChannelInfo this_ptr_conv;
12714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12715         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12716         LDKChannelAnnouncement ret = ChannelInfo_get_announcement_message(&this_ptr_conv);
12717         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12718 }
12719
12720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12721         LDKChannelInfo this_ptr_conv;
12722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12723         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12724         LDKChannelAnnouncement val_conv;
12725         val_conv.inner = (void*)(val & (~1));
12726         val_conv.is_owned = (val & 1) || (val == 0);
12727         if (val_conv.inner != NULL)
12728                 val_conv = ChannelAnnouncement_clone(&val_conv);
12729         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
12730 }
12731
12732 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
12733         LDKChannelInfo obj_conv;
12734         obj_conv.inner = (void*)(obj & (~1));
12735         obj_conv.is_owned = (obj & 1) || (obj == 0);
12736         LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
12737         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12738         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12739         CVec_u8Z_free(arg_var);
12740         return arg_arr;
12741 }
12742
12743 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12744         LDKu8slice ser_ref;
12745         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12746         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12747         LDKChannelInfo ret = ChannelInfo_read(ser_ref);
12748         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12749         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12750 }
12751
12752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12753         LDKRoutingFees this_ptr_conv;
12754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12755         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12756         RoutingFees_free(this_ptr_conv);
12757 }
12758
12759 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv * _env, jclass _b, jlong orig) {
12760         LDKRoutingFees orig_conv;
12761         orig_conv.inner = (void*)(orig & (~1));
12762         orig_conv.is_owned = (orig & 1) || (orig == 0);
12763         LDKRoutingFees ret = RoutingFees_clone(&orig_conv);
12764         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12765 }
12766
12767 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
12768         LDKRoutingFees this_ptr_conv;
12769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12770         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12771         jint ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
12772         return ret_val;
12773 }
12774
12775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12776         LDKRoutingFees this_ptr_conv;
12777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12778         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12779         RoutingFees_set_base_msat(&this_ptr_conv, val);
12780 }
12781
12782 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
12783         LDKRoutingFees this_ptr_conv;
12784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12785         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12786         jint ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
12787         return ret_val;
12788 }
12789
12790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
12791         LDKRoutingFees this_ptr_conv;
12792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12793         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12794         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
12795 }
12796
12797 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv * _env, jclass _b, jint base_msat_arg, jint proportional_millionths_arg) {
12798         LDKRoutingFees ret = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
12799         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12800 }
12801
12802 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12803         LDKu8slice ser_ref;
12804         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12805         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12806         LDKRoutingFees ret = RoutingFees_read(ser_ref);
12807         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12808         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12809 }
12810
12811 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv * _env, jclass _b, jlong obj) {
12812         LDKRoutingFees obj_conv;
12813         obj_conv.inner = (void*)(obj & (~1));
12814         obj_conv.is_owned = (obj & 1) || (obj == 0);
12815         LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
12816         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12817         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12818         CVec_u8Z_free(arg_var);
12819         return arg_arr;
12820 }
12821
12822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12823         LDKNodeAnnouncementInfo this_ptr_conv;
12824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12825         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12826         NodeAnnouncementInfo_free(this_ptr_conv);
12827 }
12828
12829 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
12830         LDKNodeAnnouncementInfo this_ptr_conv;
12831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12832         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12833         LDKNodeFeatures ret = NodeAnnouncementInfo_get_features(&this_ptr_conv);
12834         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12835 }
12836
12837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12838         LDKNodeAnnouncementInfo this_ptr_conv;
12839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12840         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12841         LDKNodeFeatures val_conv;
12842         val_conv.inner = (void*)(val & (~1));
12843         val_conv.is_owned = (val & 1) || (val == 0);
12844         // Warning: we may need a move here but can't clone!
12845         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
12846 }
12847
12848 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(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         jint ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
12853         return ret_val;
12854 }
12855
12856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint 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         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
12861 }
12862
12863 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
12864         LDKNodeAnnouncementInfo this_ptr_conv;
12865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12866         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12867         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
12868         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
12869         return ret_arr;
12870 }
12871
12872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
12873         LDKNodeAnnouncementInfo this_ptr_conv;
12874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12875         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12876         LDKThreeBytes val_ref;
12877         CHECK((*_env)->GetArrayLength (_env, val) == 3);
12878         (*_env)->GetByteArrayRegion (_env, val, 0, 3, val_ref.data);
12879         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
12880 }
12881
12882 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(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, 32);
12887         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
12888         return ret_arr;
12889 }
12890
12891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(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         LDKThirtyTwoBytes val_ref;
12896         CHECK((*_env)->GetArrayLength (_env, val) == 32);
12897         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
12898         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
12899 }
12900
12901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
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         LDKCVec_NetAddressZ val_constr;
12906         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
12907         if (val_constr.datalen > 0)
12908                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12909         else
12910                 val_constr.data = NULL;
12911         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
12912         for (size_t m = 0; m < val_constr.datalen; m++) {
12913                 long arr_conv_12 = val_vals[m];
12914                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
12915                 FREE((void*)arr_conv_12);
12916                 val_constr.data[m] = arr_conv_12_conv;
12917         }
12918         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
12919         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
12920 }
12921
12922 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
12923         LDKNodeAnnouncementInfo this_ptr_conv;
12924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12925         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12926         LDKNodeAnnouncement ret = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
12927         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12928 }
12929
12930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
12931         LDKNodeAnnouncementInfo this_ptr_conv;
12932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12933         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12934         LDKNodeAnnouncement val_conv;
12935         val_conv.inner = (void*)(val & (~1));
12936         val_conv.is_owned = (val & 1) || (val == 0);
12937         if (val_conv.inner != NULL)
12938                 val_conv = NodeAnnouncement_clone(&val_conv);
12939         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
12940 }
12941
12942 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) {
12943         LDKNodeFeatures features_arg_conv;
12944         features_arg_conv.inner = (void*)(features_arg & (~1));
12945         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
12946         // Warning: we may need a move here but can't clone!
12947         LDKThreeBytes rgb_arg_ref;
12948         CHECK((*_env)->GetArrayLength (_env, rgb_arg) == 3);
12949         (*_env)->GetByteArrayRegion (_env, rgb_arg, 0, 3, rgb_arg_ref.data);
12950         LDKThirtyTwoBytes alias_arg_ref;
12951         CHECK((*_env)->GetArrayLength (_env, alias_arg) == 32);
12952         (*_env)->GetByteArrayRegion (_env, alias_arg, 0, 32, alias_arg_ref.data);
12953         LDKCVec_NetAddressZ addresses_arg_constr;
12954         addresses_arg_constr.datalen = (*_env)->GetArrayLength (_env, addresses_arg);
12955         if (addresses_arg_constr.datalen > 0)
12956                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12957         else
12958                 addresses_arg_constr.data = NULL;
12959         long* addresses_arg_vals = (*_env)->GetLongArrayElements (_env, addresses_arg, NULL);
12960         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
12961                 long arr_conv_12 = addresses_arg_vals[m];
12962                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
12963                 FREE((void*)arr_conv_12);
12964                 addresses_arg_constr.data[m] = arr_conv_12_conv;
12965         }
12966         (*_env)->ReleaseLongArrayElements (_env, addresses_arg, addresses_arg_vals, 0);
12967         LDKNodeAnnouncement announcement_message_arg_conv;
12968         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
12969         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
12970         if (announcement_message_arg_conv.inner != NULL)
12971                 announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
12972         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
12973         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12974 }
12975
12976 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
12977         LDKNodeAnnouncementInfo obj_conv;
12978         obj_conv.inner = (void*)(obj & (~1));
12979         obj_conv.is_owned = (obj & 1) || (obj == 0);
12980         LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
12981         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
12982         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
12983         CVec_u8Z_free(arg_var);
12984         return arg_arr;
12985 }
12986
12987 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
12988         LDKu8slice ser_ref;
12989         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
12990         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
12991         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_read(ser_ref);
12992         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
12993         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
12994 }
12995
12996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
12997         LDKNodeInfo this_ptr_conv;
12998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12999         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13000         NodeInfo_free(this_ptr_conv);
13001 }
13002
13003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) {
13004         LDKNodeInfo this_ptr_conv;
13005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13006         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13007         LDKCVec_u64Z val_constr;
13008         val_constr.datalen = (*_env)->GetArrayLength (_env, val);
13009         if (val_constr.datalen > 0)
13010                 val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
13011         else
13012                 val_constr.data = NULL;
13013         long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL);
13014         for (size_t g = 0; g < val_constr.datalen; g++) {
13015                 long arr_conv_6 = val_vals[g];
13016                 val_constr.data[g] = arr_conv_6;
13017         }
13018         (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0);
13019         NodeInfo_set_channels(&this_ptr_conv, val_constr);
13020 }
13021
13022 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
13023         LDKNodeInfo this_ptr_conv;
13024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13025         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13026         LDKRoutingFees ret = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
13027         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13028 }
13029
13030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
13031         LDKNodeInfo this_ptr_conv;
13032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13033         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13034         LDKRoutingFees val_conv;
13035         val_conv.inner = (void*)(val & (~1));
13036         val_conv.is_owned = (val & 1) || (val == 0);
13037         if (val_conv.inner != NULL)
13038                 val_conv = RoutingFees_clone(&val_conv);
13039         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
13040 }
13041
13042 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr) {
13043         LDKNodeInfo this_ptr_conv;
13044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13045         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13046         LDKNodeAnnouncementInfo ret = NodeInfo_get_announcement_info(&this_ptr_conv);
13047         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13048 }
13049
13050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
13051         LDKNodeInfo this_ptr_conv;
13052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13053         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13054         LDKNodeAnnouncementInfo val_conv;
13055         val_conv.inner = (void*)(val & (~1));
13056         val_conv.is_owned = (val & 1) || (val == 0);
13057         // Warning: we may need a move here but can't clone!
13058         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
13059 }
13060
13061 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) {
13062         LDKCVec_u64Z channels_arg_constr;
13063         channels_arg_constr.datalen = (*_env)->GetArrayLength (_env, channels_arg);
13064         if (channels_arg_constr.datalen > 0)
13065                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements");
13066         else
13067                 channels_arg_constr.data = NULL;
13068         long* channels_arg_vals = (*_env)->GetLongArrayElements (_env, channels_arg, NULL);
13069         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
13070                 long arr_conv_6 = channels_arg_vals[g];
13071                 channels_arg_constr.data[g] = arr_conv_6;
13072         }
13073         (*_env)->ReleaseLongArrayElements (_env, channels_arg, channels_arg_vals, 0);
13074         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
13075         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
13076         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
13077         if (lowest_inbound_channel_fees_arg_conv.inner != NULL)
13078                 lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
13079         LDKNodeAnnouncementInfo announcement_info_arg_conv;
13080         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
13081         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
13082         // Warning: we may need a move here but can't clone!
13083         LDKNodeInfo ret = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
13084         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13085 }
13086
13087 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
13088         LDKNodeInfo obj_conv;
13089         obj_conv.inner = (void*)(obj & (~1));
13090         obj_conv.is_owned = (obj & 1) || (obj == 0);
13091         LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
13092         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
13093         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
13094         CVec_u8Z_free(arg_var);
13095         return arg_arr;
13096 }
13097
13098 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
13099         LDKu8slice ser_ref;
13100         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
13101         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
13102         LDKNodeInfo ret = NodeInfo_read(ser_ref);
13103         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
13104         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13105 }
13106
13107 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv * _env, jclass _b, jlong obj) {
13108         LDKNetworkGraph obj_conv;
13109         obj_conv.inner = (void*)(obj & (~1));
13110         obj_conv.is_owned = (obj & 1) || (obj == 0);
13111         LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
13112         jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen);
13113         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data);
13114         CVec_u8Z_free(arg_var);
13115         return arg_arr;
13116 }
13117
13118 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _env, jclass _b, jbyteArray ser) {
13119         LDKu8slice ser_ref;
13120         ser_ref.data = (*_env)->GetByteArrayElements (_env, ser, NULL);
13121         ser_ref.datalen = (*_env)->GetArrayLength (_env, ser);
13122         LDKNetworkGraph ret = NetworkGraph_read(ser_ref);
13123         (*_env)->ReleaseByteArrayElements(_env, ser, (int8_t*)ser_ref.data, 0);
13124         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13125 }
13126
13127 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv * _env, jclass _b) {
13128         LDKNetworkGraph ret = NetworkGraph_new();
13129         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
13130 }
13131
13132 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) {
13133         LDKNetworkGraph this_arg_conv;
13134         this_arg_conv.inner = (void*)(this_arg & (~1));
13135         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
13136         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
13137 }
13138